diff options
author | chriseth <chris@ethereum.org> | 2017-12-30 20:47:51 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-04-12 19:09:37 +0800 |
commit | 012ab37fe3984a692dcdda6ef516e4588a8721b3 (patch) | |
tree | edf1f76a47fda1bc5a26076503b0797526c5cf63 /libsolidity/codegen | |
parent | 8ab7dc036aafd5781118fc16f05df5b0a8a5550e (diff) | |
download | dexon-solidity-012ab37fe3984a692dcdda6ef516e4588a8721b3.tar dexon-solidity-012ab37fe3984a692dcdda6ef516e4588a8721b3.tar.gz dexon-solidity-012ab37fe3984a692dcdda6ef516e4588a8721b3.tar.bz2 dexon-solidity-012ab37fe3984a692dcdda6ef516e4588a8721b3.tar.lz dexon-solidity-012ab37fe3984a692dcdda6ef516e4588a8721b3.tar.xz dexon-solidity-012ab37fe3984a692dcdda6ef516e4588a8721b3.tar.zst dexon-solidity-012ab37fe3984a692dcdda6ef516e4588a8721b3.zip |
Code generator for revert with reason string.
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 57d49ac6..dc9fae21 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -680,8 +680,25 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) m_context << Instruction::SELFDESTRUCT; break; case FunctionType::Kind::Revert: - m_context.appendRevert(); + { + if (!arguments.empty()) + { + solAssert(arguments.size() == 1, ""); + solAssert(function.parameterTypes().size() == 1, ""); + m_context << u256(0); + arguments.front()->accept(*this); + utils().fetchFreeMemoryPointer(); + utils().abiEncode( + {make_shared<IntegerType>(256), arguments.front()->annotation().type}, + {make_shared<IntegerType>(256), make_shared<ArrayType>(DataLocation::Memory, true)} + ); + utils().toSizeAfterFreeMemoryPointer(); + m_context << Instruction::REVERT; + } + else + m_context.appendRevert(); break; + } case FunctionType::Kind::SHA3: { TypePointers argumentTypes; |