diff options
author | chriseth <c@ethdev.com> | 2016-05-10 20:30:24 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-05-11 01:40:37 +0800 |
commit | 656405240e08e47fce40a2f62af93abc758bd2d2 (patch) | |
tree | ad1139d8209d5f98b41dee7eb82ebbd2d7d78495 /libsolidity/analysis | |
parent | cf226f0607386d1e6d9c75ebc7ce24e733ca4315 (diff) | |
download | dexon-solidity-656405240e08e47fce40a2f62af93abc758bd2d2.tar dexon-solidity-656405240e08e47fce40a2f62af93abc758bd2d2.tar.gz dexon-solidity-656405240e08e47fce40a2f62af93abc758bd2d2.tar.bz2 dexon-solidity-656405240e08e47fce40a2f62af93abc758bd2d2.tar.lz dexon-solidity-656405240e08e47fce40a2f62af93abc758bd2d2.tar.xz dexon-solidity-656405240e08e47fce40a2f62af93abc758bd2d2.tar.zst dexon-solidity-656405240e08e47fce40a2f62af93abc758bd2d2.zip |
Simplify interface of RationalNumber.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r-- | libsolidity/analysis/ReferencesResolver.cpp | 2 | ||||
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 9f83971b..a7b9e8b8 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -104,7 +104,7 @@ void ReferencesResolver::endVisit(ArrayTypeName const& _typeName) if (!length->annotation().type) ConstantEvaluator e(*length); auto const* lengthType = dynamic_cast<RationalNumberType const*>(length->annotation().type.get()); - if (!lengthType || lengthType->denominator() != 1) + if (!lengthType || lengthType->isFractional()) fatalTypeError(length->location(), "Invalid array length, expected integer literal."); else _typeName.annotation().type = make_shared<ArrayType>(DataLocation::Storage, baseType, lengthType->literalValue(nullptr)); diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index f28e08ab..6df9aae0 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -792,7 +792,7 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) { if ( valueComponentType->category() == Type::Category::RationalNumber && - dynamic_cast<RationalNumberType const&>(*valueComponentType).denominator() != 1 && + dynamic_cast<RationalNumberType const&>(*valueComponentType).isFractional() && valueComponentType->mobileType() ) typeError( @@ -1366,9 +1366,9 @@ bool TypeChecker::visit(IndexAccess const& _access) expectType(*index, IntegerType(256)); if (auto numberType = dynamic_cast<RationalNumberType const*>(type(*index).get())) { - solAssert(!numberType->denominator() != 1 ,"Invalid type for array access."); - if (!actualType.isDynamicallySized() && actualType.length() <= numberType->literalValue(nullptr)) - typeError(_access.location(), "Out of bounds array access."); + if (!numberType->isFractional()) // error is reported above + if (!actualType.isDynamicallySized() && actualType.length() <= numberType->literalValue(nullptr)) + typeError(_access.location(), "Out of bounds array access."); } } resultType = actualType.baseType(); @@ -1522,7 +1522,7 @@ void TypeChecker::expectType(Expression const& _expression, Type const& _expecte { if ( type(_expression)->category() == Type::Category::RationalNumber && - dynamic_pointer_cast<RationalNumberType const>(type(_expression))->denominator() != 1 && + dynamic_pointer_cast<RationalNumberType const>(type(_expression))->isFractional() && type(_expression)->mobileType() ) typeError( |