aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-05-10 16:26:53 +0800
committerchriseth <c@ethdev.com>2016-05-11 01:40:35 +0800
commit80c368dac1529994e736360812e2519e987e26b1 (patch)
tree297ea96b25c4bb704d6107772b622eb34ac42ec5 /libsolidity/ast
parentaf354d75552b79144e771799b904e1c87931de90 (diff)
downloaddexon-solidity-80c368dac1529994e736360812e2519e987e26b1.tar.gz
dexon-solidity-80c368dac1529994e736360812e2519e987e26b1.tar.zst
dexon-solidity-80c368dac1529994e736360812e2519e987e26b1.zip
Prefer mobileType() to check rational range.
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/Types.cpp13
-rw-r--r--libsolidity/ast/Types.h2
2 files changed, 5 insertions, 10 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 1dbb70e2..c2ebecb5 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -766,20 +766,15 @@ u256 RationalNumberType::literalValue(Literal const*) const
TypePointer RationalNumberType::mobileType() const
{
if (m_value.denominator() == 1)
- {
- auto intType = integerType();
- solAssert(!!intType, "mobileType called with invalid integer constant " + toString(false));
- return intType;
- }
- auto fixType = fixedPointType();
- solAssert(!!fixType, "mobileType called with invalid fixed constant " + toString(false));
- return fixType;
+ return integerType();
+ else
+ return fixedPointType();
}
//TODO: combine integerType() and fixedPointType() into one function
shared_ptr<IntegerType const> RationalNumberType::integerType() const
{
- solAssert(m_value.denominator() == 1, "Non integer type found.");
+ solAssert(m_value.denominator() == 1, "integerType() called for fractional number.");
bigint value = integerPart();
bool negative = (value < 0);
if (negative) // convert to positive number of same bit requirements
diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h
index 5e826684..c3095c97 100644
--- a/libsolidity/ast/Types.h
+++ b/libsolidity/ast/Types.h
@@ -205,7 +205,7 @@ public:
virtual unsigned sizeOnStack() const { return 1; }
/// @returns the mobile (in contrast to static) type corresponding to the given type.
/// This returns the corresponding integer type for ConstantTypes and the pointer type
- /// for storage reference types.
+ /// for storage reference types. Might return a null pointer if there is no fitting type.
virtual TypePointer mobileType() const { return shared_from_this(); }
/// @returns true if this is a non-value type and the data of this type is stored at the
/// given location.