diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-03-11 01:22:19 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-03-12 19:53:00 +0800 |
commit | b2fadf6b933e9034d5edb49608329fb0f7d015dd (patch) | |
tree | a0f606a88174cbdb99dcab2d3ee9a23fe47ae8d6 /Types.cpp | |
parent | 73ce24ae75554b18a342e1e510f37f99057fdb1d (diff) | |
download | dexon-solidity-b2fadf6b933e9034d5edb49608329fb0f7d015dd.tar.gz dexon-solidity-b2fadf6b933e9034d5edb49608329fb0f7d015dd.tar.zst dexon-solidity-b2fadf6b933e9034d5edb49608329fb0f7d015dd.zip |
Conversion changes after renaming Hash/String to Bytes.
- Almost all end to end tests pass. Still needs a little bit of work
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -175,14 +175,10 @@ bool IntegerType::isImplicitlyConvertibleTo(Type const& _convertTo) const bool IntegerType::isExplicitlyConvertibleTo(Type const& _convertTo) const { - if (_convertTo.getCategory() == Category::FixedBytes) - { - FixedBytesType const& convertTo = dynamic_cast<FixedBytesType const&>(_convertTo); - return (m_bits == convertTo.getNumBytes() * 8); - } return _convertTo.getCategory() == getCategory() || _convertTo.getCategory() == Category::Contract || - _convertTo.getCategory() == Category::Enum; + _convertTo.getCategory() == Category::Enum || + _convertTo.getCategory() == Category::FixedBytes; } TypePointer IntegerType::unaryOperatorResult(Token::Value _operator) const @@ -284,7 +280,15 @@ IntegerConstantType::IntegerConstantType(Literal const& _literal) bool IntegerConstantType::isImplicitlyConvertibleTo(Type const& _convertTo) const { - TypePointer integerType = getIntegerType(); + auto integerType = getIntegerType(); + if (_convertTo.getCategory() == Category::FixedBytes) + { + FixedBytesType const& convertTo = dynamic_cast<FixedBytesType const&>(_convertTo); + if (convertTo.getNumBytes() * 8 >= integerType->getNumBits()) + return true; + return false; + } + return integerType && integerType->isImplicitlyConvertibleTo(_convertTo); } @@ -461,7 +465,7 @@ bool FixedBytesType::isExplicitlyConvertibleTo(Type const& _convertTo) const if (_convertTo.getCategory() == Category::Integer) { IntegerType const& convertTo = dynamic_cast<IntegerType const&>(_convertTo); - if (m_bytes * 8 == convertTo.getNumBits()) + if (m_bytes * 8 <= convertTo.getNumBits()) return true; } |