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 | |
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')
-rw-r--r-- | libsolidity/codegen/CompilerUtils.cpp | 14 | ||||
-rw-r--r-- | libsolidity/codegen/ContractCompiler.cpp | 2 |
2 files changed, 15 insertions, 1 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."); diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 4d33927d..9d6129a3 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -42,7 +42,7 @@ class StackHeightChecker public: StackHeightChecker(CompilerContext const& _context): m_context(_context), stackHeight(m_context.stackHeight()) {} - void check() { solAssert(m_context.stackHeight() == stackHeight, "I sense a disturbance in the stack."); } + void check() { solAssert(m_context.stackHeight() == stackHeight, std::string("I sense a disturbance in the stack: ") + std::to_string(m_context.stackHeight()) + " vs " + std::to_string(stackHeight)); } private: CompilerContext const& m_context; unsigned stackHeight; |