aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-02-07 06:11:19 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-02-11 06:40:42 +0800
commitf3158f92d6070b6088c6a1b32f2934b9cd7dde1b (patch)
tree06ce91bd693a16055aaba7437d60b6f68fa51fb4 /libsolidity
parent148f9233516ff5ad94d81aba9bc9c0440d3afc7b (diff)
downloaddexon-solidity-f3158f92d6070b6088c6a1b32f2934b9cd7dde1b.tar.gz
dexon-solidity-f3158f92d6070b6088c6a1b32f2934b9cd7dde1b.tar.zst
dexon-solidity-f3158f92d6070b6088c6a1b32f2934b9cd7dde1b.zip
Support revert()
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/GlobalContext.cpp4
-rw-r--r--libsolidity/ast/Types.cpp1
-rw-r--r--libsolidity/ast/Types.h1
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp5
4 files changed, 10 insertions, 1 deletions
diff --git a/libsolidity/analysis/GlobalContext.cpp b/libsolidity/analysis/GlobalContext.cpp
index cc418c5e..4f100cd0 100644
--- a/libsolidity/analysis/GlobalContext.cpp
+++ b/libsolidity/analysis/GlobalContext.cpp
@@ -67,7 +67,9 @@ m_magicVariables(vector<shared_ptr<MagicVariableDeclaration const>>{make_shared<
make_shared<MagicVariableDeclaration>("ripemd160",
make_shared<FunctionType>(strings(), strings{"bytes20"}, FunctionType::Location::RIPEMD160, true)),
make_shared<MagicVariableDeclaration>("assert",
- make_shared<FunctionType>(strings{"bool"}, strings{}, FunctionType::Location::Assert))})
+ make_shared<FunctionType>(strings{"bool"}, strings{}, FunctionType::Location::Assert)),
+ make_shared<MagicVariableDeclaration>("revert",
+ make_shared<FunctionType>(strings(), strings(), FunctionType::Location::Revert))})
{
}
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 4a64b4c8..5b7b4a2c 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -2095,6 +2095,7 @@ string FunctionType::identifier() const
case Location::Send: id += "send"; break;
case Location::SHA3: id += "sha3"; break;
case Location::Selfdestruct: id += "selfdestruct"; break;
+ case Location::Revert: id += "revert"; break;
case Location::ECRecover: id += "ecrecover"; break;
case Location::SHA256: id += "sha256"; break;
case Location::RIPEMD160: id += "ripemd160"; break;
diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h
index 83d840e0..3546e522 100644
--- a/libsolidity/ast/Types.h
+++ b/libsolidity/ast/Types.h
@@ -828,6 +828,7 @@ public:
Send, ///< CALL, but without data and gas
SHA3, ///< SHA3
Selfdestruct, ///< SELFDESTRUCT
+ Revert, ///< REVERT
ECRecover, ///< CALL to special contract for ecrecover
SHA256, ///< CALL to special contract for sha256
RIPEMD160, ///< CALL to special contract for ripemd160
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;