diff options
author | chriseth <chris@ethereum.org> | 2018-09-06 03:40:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-06 03:40:49 +0800 |
commit | 08a7a51f071e2ef30db011fb36d505c7615785ec (patch) | |
tree | 603e8a79d31e552c9e308a87e3d90f3fcccb854d /libsolidity/codegen/ABIFunctions.cpp | |
parent | 9cb72fe6ca0260e465ed3a1700cc4a890480df4f (diff) | |
parent | 87804b6419a5894601441efe511015adda5fb119 (diff) | |
download | dexon-solidity-08a7a51f071e2ef30db011fb36d505c7615785ec.tar dexon-solidity-08a7a51f071e2ef30db011fb36d505c7615785ec.tar.gz dexon-solidity-08a7a51f071e2ef30db011fb36d505c7615785ec.tar.bz2 dexon-solidity-08a7a51f071e2ef30db011fb36d505c7615785ec.tar.lz dexon-solidity-08a7a51f071e2ef30db011fb36d505c7615785ec.tar.xz dexon-solidity-08a7a51f071e2ef30db011fb36d505c7615785ec.tar.zst dexon-solidity-08a7a51f071e2ef30db011fb36d505c7615785ec.zip |
Merge pull request #4887 from ethereum/addressSplit
Split IntegerType into IntegerType and AddressType.
Diffstat (limited to 'libsolidity/codegen/ABIFunctions.cpp')
-rw-r--r-- | libsolidity/codegen/ABIFunctions.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp index dda77958..5e5fe84a 100644 --- a/libsolidity/codegen/ABIFunctions.cpp +++ b/libsolidity/codegen/ABIFunctions.cpp @@ -197,6 +197,9 @@ string ABIFunctions::cleanupFunction(Type const& _type, bool _revertOnFailure) templ("functionName", functionName); switch (_type.category()) { + case Type::Category::Address: + templ("body", "cleaned := " + cleanupFunction(IntegerType(160)) + "(value)"); + break; case Type::Category::Integer: { IntegerType const& type = dynamic_cast<IntegerType const&>(_type); @@ -239,7 +242,7 @@ string ABIFunctions::cleanupFunction(Type const& _type, bool _revertOnFailure) break; } case Type::Category::Contract: - templ("body", "cleaned := " + cleanupFunction(IntegerType(160, IntegerType::Modifier::Address)) + "(value)"); + templ("body", "cleaned := " + cleanupFunction(AddressType()) + "(value)"); break; case Type::Category::Enum: { @@ -284,6 +287,12 @@ string ABIFunctions::conversionFunction(Type const& _from, Type const& _to) auto fromCategory = _from.category(); switch (fromCategory) { + case Type::Category::Address: + body = + Whiskers("converted := <convert>(value)") + ("convert", conversionFunction(IntegerType(160), _to)) + .render(); + break; case Type::Category::Integer: case Type::Category::RationalNumber: case Type::Category::Contract: @@ -314,16 +323,19 @@ string ABIFunctions::conversionFunction(Type const& _from, Type const& _to) .render(); } else if (toCategory == Type::Category::FixedPoint) - { solUnimplemented("Not yet implemented - FixedPointType."); - } + else if (toCategory == Type::Category::Address) + body = + Whiskers("converted := <convert>(value)") + ("convert", conversionFunction(_from, IntegerType(160))) + .render(); else { solAssert( toCategory == Type::Category::Integer || toCategory == Type::Category::Contract, ""); - IntegerType const addressType(160, IntegerType::Modifier::Address); + IntegerType const addressType(160); IntegerType const& to = toCategory == Type::Category::Integer ? dynamic_cast<IntegerType const&>(_to) : @@ -375,6 +387,11 @@ string ABIFunctions::conversionFunction(Type const& _from, Type const& _to) ("shift", shiftRightFunction(256 - from.numBytes() * 8)) ("convert", conversionFunction(IntegerType(from.numBytes() * 8), _to)) .render(); + else if (toCategory == Type::Category::Address) + body = + Whiskers("converted := <convert>(value)") + ("convert", conversionFunction(_from, IntegerType(160))) + .render(); else { // clear for conversion to longer bytes @@ -410,7 +427,7 @@ string ABIFunctions::conversionFunction(Type const& _from, Type const& _to) solAssert(false, ""); } - solAssert(!body.empty(), ""); + solAssert(!body.empty(), _from.canonicalName() + " to " + _to.canonicalName()); templ("body", body); return templ.render(); }); |