diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-02-02 06:17:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-02 06:17:44 +0800 |
commit | 5225a5bb5e9a23657f496e6638146746594e9bf9 (patch) | |
tree | c8cd95b2eb13808f2b6ff3c07c5c70398fcc5cb7 /libsolidity/codegen/CompilerUtils.cpp | |
parent | c1a675da4f01728784c9b7e1d82665bb8dfbcc99 (diff) | |
parent | ee147e14d392e62dae92d345735ec768bd486633 (diff) | |
download | dexon-solidity-5225a5bb5e9a23657f496e6638146746594e9bf9.tar dexon-solidity-5225a5bb5e9a23657f496e6638146746594e9bf9.tar.gz dexon-solidity-5225a5bb5e9a23657f496e6638146746594e9bf9.tar.bz2 dexon-solidity-5225a5bb5e9a23657f496e6638146746594e9bf9.tar.lz dexon-solidity-5225a5bb5e9a23657f496e6638146746594e9bf9.tar.xz dexon-solidity-5225a5bb5e9a23657f496e6638146746594e9bf9.tar.zst dexon-solidity-5225a5bb5e9a23657f496e6638146746594e9bf9.zip |
Merge pull request #1630 from ethereum/function-to-address
Explicit external function type to address conversion
Diffstat (limited to 'libsolidity/codegen/CompilerUtils.cpp')
-rw-r--r-- | libsolidity/codegen/CompilerUtils.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index 477f021a..9f019d27 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -787,6 +787,20 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp if (_cleanupNeeded) m_context << Instruction::ISZERO << Instruction::ISZERO; break; + case Type::Category::Function: + { + if (targetTypeCategory == Type::Category::Integer) + { + IntegerType const& targetType = dynamic_cast<IntegerType const&>(_targetType); + solAssert(targetType.isAddress(), "Function type can only be converted to address."); + FunctionType const& typeOnStack = dynamic_cast<FunctionType const&>(_typeOnStack); + solAssert(typeOnStack.location() == FunctionType::Location::External, "Only external function type can be converted."); + + // stack: <address> <function_id> + m_context << Instruction::POP; + break; + } + } default: // All other types should not be convertible to non-equal types. solAssert(_typeOnStack == _targetType, "Invalid type conversion requested."); |