diff options
author | chriseth <chris@ethereum.org> | 2018-07-01 00:09:13 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-08-15 16:45:16 +0800 |
commit | 9328ea4c3c023950e59405941cfc25ec4c0ed1b4 (patch) | |
tree | e2481f85477a18b935d0fb43d7901ef501175347 /libsolidity/codegen | |
parent | 3c5226cefb9f883277530decedc08e2e48ed3050 (diff) | |
download | dexon-solidity-9328ea4c3c023950e59405941cfc25ec4c0ed1b4.tar.gz dexon-solidity-9328ea4c3c023950e59405941cfc25ec4c0ed1b4.tar.zst dexon-solidity-9328ea4c3c023950e59405941cfc25ec4c0ed1b4.zip |
Add abi.decode(bytes data, (...))
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 412a7255..7a4548f5 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1070,6 +1070,27 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) // stack now: <memory pointer> break; } + case FunctionType::Kind::ABIDecode: + { + arguments.front()->accept(*this); + TypePointer firstArgType = arguments.front()->annotation().type; + TypePointers const& targetTypes = dynamic_cast<TupleType const&>(*_functionCall.annotation().type).components(); + if ( + *firstArgType == ArrayType(DataLocation::CallData) || + *firstArgType == ArrayType(DataLocation::CallData, true) + ) + utils().abiDecode(targetTypes, false); + else + { + utils().convertType(*firstArgType, ArrayType(DataLocation::Memory)); + m_context << Instruction::DUP1 << u256(32) << Instruction::ADD; + m_context << Instruction::SWAP1 << Instruction::MLOAD; + // stack now: <mem_pos> <length> + + utils().abiDecode(targetTypes, true); + } + break; + } case FunctionType::Kind::GasLeft: m_context << Instruction::GAS; break; |