aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-03-11 01:22:19 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-03-12 19:53:00 +0800
commitb2fadf6b933e9034d5edb49608329fb0f7d015dd (patch)
treea0f606a88174cbdb99dcab2d3ee9a23fe47ae8d6 /Types.cpp
parent73ce24ae75554b18a342e1e510f37f99057fdb1d (diff)
downloaddexon-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.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/Types.cpp b/Types.cpp
index 6039895a..8524cb8b 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -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;
}