aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-02-13 21:56:22 +0800
committerGitHub <noreply@github.com>2017-02-13 21:56:22 +0800
commit0d8a9c328910bc9a0ab18beb273c029dc9a05b15 (patch)
tree388b2cc84825e30c0753e480be1d6bb0bbc4db03 /libsolidity/codegen
parente2349f9d5db80e57558ddaf7564ea57cf3b216d8 (diff)
parentc8ec79548b8f8825735ee96f1768e7fc5313d19e (diff)
downloaddexon-solidity-0d8a9c328910bc9a0ab18beb273c029dc9a05b15.tar
dexon-solidity-0d8a9c328910bc9a0ab18beb273c029dc9a05b15.tar.gz
dexon-solidity-0d8a9c328910bc9a0ab18beb273c029dc9a05b15.tar.bz2
dexon-solidity-0d8a9c328910bc9a0ab18beb273c029dc9a05b15.tar.lz
dexon-solidity-0d8a9c328910bc9a0ab18beb273c029dc9a05b15.tar.xz
dexon-solidity-0d8a9c328910bc9a0ab18beb273c029dc9a05b15.tar.zst
dexon-solidity-0d8a9c328910bc9a0ab18beb273c029dc9a05b15.zip
Merge pull request #1661 from ethereum/asm-revert
Implement REVERT (EIP140)
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp4
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp15
2 files changed, 16 insertions, 3 deletions
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index 9d6129a3..6524bd03 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -762,7 +762,9 @@ bool ContractCompiler::visit(Return const& _return)
bool ContractCompiler::visit(Throw const& _throw)
{
CompilerContext::LocationSetter locationSetter(m_context, _throw);
- m_context.appendJumpTo(m_context.errorTag());
+ // Do not send back an error detail.
+ m_context << u256(0) << u256(0);
+ m_context << Instruction::REVERT;
return false;
}
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index f69d61db..2ed19a83 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;
@@ -867,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: