diff options
author | Liana Husikyan <liana@ethdev.com> | 2015-06-04 18:42:55 +0800 |
---|---|---|
committer | Liana Husikyan <liana@ethdev.com> | 2015-06-04 18:42:55 +0800 |
commit | 89aab7e234e3c96bbae2e4066cfa1249f5d1793e (patch) | |
tree | dbc713a4b503515c09fafd0231dca7c1eb7c4e0a | |
parent | 382ac85aa5e8bbcfa48e274d7aec0923b79666d4 (diff) | |
download | dexon-solidity-89aab7e234e3c96bbae2e4066cfa1249f5d1793e.tar dexon-solidity-89aab7e234e3c96bbae2e4066cfa1249f5d1793e.tar.gz dexon-solidity-89aab7e234e3c96bbae2e4066cfa1249f5d1793e.tar.bz2 dexon-solidity-89aab7e234e3c96bbae2e4066cfa1249f5d1793e.tar.lz dexon-solidity-89aab7e234e3c96bbae2e4066cfa1249f5d1793e.tar.xz dexon-solidity-89aab7e234e3c96bbae2e4066cfa1249f5d1793e.tar.zst dexon-solidity-89aab7e234e3c96bbae2e4066cfa1249f5d1793e.zip |
- style fixes
- added test for uint8 = -1 which doesn't fail; todo: fix that
-rw-r--r-- | AST.cpp | 15 | ||||
-rw-r--r-- | Types.cpp | 11 |
2 files changed, 12 insertions, 14 deletions
@@ -686,14 +686,13 @@ void Expression::expectType(Type const& _expectedType) checkTypeRequirements(nullptr); Type const& type = *getType(); if (!type.isImplicitlyConvertibleTo(_expectedType)) - BOOST_THROW_EXCEPTION( - createTypeError( - "Type " + - type.toString() + - " is not implicitly convertible to expected type " + - _expectedType.toString() + - "." - ) + BOOST_THROW_EXCEPTION(createTypeError( + "Type " + + type.toString() + + " is not implicitly convertible to expected type " + + _expectedType.toString() + + "." + ) ); } @@ -361,22 +361,21 @@ IntegerConstantType::IntegerConstantType(Literal const& _literal) bool IntegerConstantType::isImplicitlyConvertibleTo(Type const& _convertTo) const { - if (IntegerType const* integerType = dynamic_cast<IntegerType const*>(&_convertTo)) + if (auto targetType = dynamic_cast<IntegerType const*>(&_convertTo)) { if (m_value == 0) return true; - int forSignBit = (integerType->isSigned() ? 1 : 0); + int forSignBit = (targetType->isSigned() ? 1 : 0); if (m_value > 0) { - if (m_value <= (u256(-1) >> (256 - integerType->getNumBits() + forSignBit))) + if (m_value <= (u256(-1) >> (256 - targetType->getNumBits() + forSignBit))) return true; } - else if (-m_value <= (u256(1) << (integerType->getNumBits() - forSignBit))) + else if (-m_value <= (u256(1) << (targetType->getNumBits() - forSignBit))) return true; return false; } - else - if (_convertTo.getCategory() == Category::FixedBytes) + else if (_convertTo.getCategory() == Category::FixedBytes) { FixedBytesType const& fixedBytes = dynamic_cast<FixedBytesType const&>(_convertTo); return fixedBytes.getNumBytes() * 8 >= getIntegerType()->getNumBits(); |