From f3158f92d6070b6088c6a1b32f2934b9cd7dde1b Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 6 Feb 2017 22:11:19 +0000 Subject: Support revert() --- libsolidity/codegen/ExpressionCompiler.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libsolidity/codegen/ExpressionCompiler.cpp') diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index f69d61db..316ae888 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -650,6 +650,11 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) utils().convertType(*arguments.front()->annotation().type, *function.parameterTypes().front(), true); m_context << Instruction::SELFDESTRUCT; break; + case Location::Revert: + // memory offset returned - zero length + m_context << u256(0) << u256(0); + m_context << Instruction::REVERT; + break; case Location::SHA3: { TypePointers argumentTypes; -- cgit v1.2.3 From c8ec79548b8f8825735ee96f1768e7fc5313d19e Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 10 Feb 2017 22:53:32 +0000 Subject: Use the revert opcode in assert() --- libsolidity/codegen/ExpressionCompiler.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libsolidity/codegen/ExpressionCompiler.cpp') diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 316ae888..2ed19a83 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -872,8 +872,14 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) { arguments.front()->accept(*this); utils().convertType(*arguments.front()->annotation().type, *function.parameterTypes().front(), false); - m_context << Instruction::ISZERO; - m_context.appendConditionalJumpTo(m_context.errorTag()); + // jump if condition was met + m_context << Instruction::ISZERO << Instruction::ISZERO; + auto success = m_context.appendConditionalJump(); + // condition was not met, abort + m_context << u256(0) << u256(0); + m_context << Instruction::REVERT; + // the success branch + m_context << success; break; } default: -- cgit v1.2.3