diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-05-01 05:56:30 +0800 |
---|---|---|
committer | daniel <danieljoonlee@gmail.com> | 2018-05-03 14:22:25 +0800 |
commit | b34428249a24c29e17de8636c2d3011d95d052cc (patch) | |
tree | deb52bcdc9dbafa132c1a634753c367785633d35 /libsolidity/ast | |
parent | 2c00ebbee1b40b66cfc96c65fc58e105bb41c776 (diff) | |
download | dexon-solidity-b34428249a24c29e17de8636c2d3011d95d052cc.tar.gz dexon-solidity-b34428249a24c29e17de8636c2d3011d95d052cc.tar.zst dexon-solidity-b34428249a24c29e17de8636c2d3011d95d052cc.zip |
Change numBits to unsigned IntegerType
Diffstat (limited to 'libsolidity/ast')
-rw-r--r-- | libsolidity/ast/Types.cpp | 10 | ||||
-rw-r--r-- | libsolidity/ast/Types.h | 6 |
2 files changed, 8 insertions, 8 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 56d41974..f41a4a37 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -425,14 +425,14 @@ bool isValidShiftAndAmountType(Token::Value _operator, Type const& _shiftAmountT } -IntegerType::IntegerType(int _bits, IntegerType::Modifier _modifier): +IntegerType::IntegerType(unsigned _bits, IntegerType::Modifier _modifier): m_bits(_bits), m_modifier(_modifier) { if (isAddress()) solAssert(m_bits == 160, ""); solAssert( m_bits > 0 && m_bits <= 256 && m_bits % 8 == 0, - "Invalid bit number for integer type: " + dev::toString(_bits) + "Invalid bit number for integer type: " + dev::toString(m_bits) ); } @@ -584,7 +584,7 @@ MemberList::MemberMap IntegerType::nativeMembers(ContractDefinition const*) cons { if (isAddress()) return { - {"balance", make_shared<IntegerType >(256)}, + {"balance", make_shared<IntegerType>(256)}, {"call", make_shared<FunctionType>(strings(), strings{"bool"}, FunctionType::Kind::BareCall, true, StateMutability::Payable)}, {"callcode", make_shared<FunctionType>(strings(), strings{"bool"}, FunctionType::Kind::BareCallCode, true, StateMutability::Payable)}, {"delegatecall", make_shared<FunctionType>(strings(), strings{"bool"}, FunctionType::Kind::BareDelegateCall, true)}, @@ -696,7 +696,7 @@ TypePointer FixedPointType::binaryOperatorResult(Token::Value _operator, TypePoi std::shared_ptr<IntegerType> FixedPointType::asIntegerType() const { - return std::make_shared<IntegerType>(numBits(), isSigned() ? IntegerType::Modifier::Signed : IntegerType::Modifier::Unsigned); + return make_shared<IntegerType>(numBits(), isSigned() ? IntegerType::Modifier::Signed : IntegerType::Modifier::Unsigned); } tuple<bool, rational> RationalNumberType::parseRational(string const& _value) @@ -850,7 +850,7 @@ bool RationalNumberType::isImplicitlyConvertibleTo(Type const& _convertTo) const if (isFractional()) return false; IntegerType const& targetType = dynamic_cast<IntegerType const&>(_convertTo); - int forSignBit = (targetType.isSigned() ? 1 : 0); + unsigned forSignBit = (targetType.isSigned() ? 1 : 0); if (m_value > rational(0)) { if (m_value.numerator() <= (u256(-1) >> (256 - targetType.numBits() + forSignBit))) diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 7e6a93b5..d39c395a 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -319,7 +319,7 @@ public: }; virtual Category category() const override { return Category::Integer; } - explicit IntegerType(int _bits, Modifier _modifier = Modifier::Unsigned); + explicit IntegerType(unsigned _bits, Modifier _modifier = Modifier::Unsigned); virtual std::string richIdentifier() const override; virtual bool isImplicitlyConvertibleTo(Type const& _convertTo) const override; @@ -342,7 +342,7 @@ public: virtual TypePointer encodingType() const override { return shared_from_this(); } virtual TypePointer interfaceType(bool) const override { return shared_from_this(); } - int numBits() const { return m_bits; } + unsigned numBits() const { return m_bits; } bool isAddress() const { return m_modifier == Modifier::Address; } bool isSigned() const { return m_modifier == Modifier::Signed; } @@ -350,7 +350,7 @@ public: bigint maxValue() const; private: - int m_bits; + unsigned m_bits; Modifier m_modifier; }; |