aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/CompilerContext.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-01-27 21:10:22 +0800
committerGitHub <noreply@github.com>2017-01-27 21:10:22 +0800
commitb2c35fb41a65dc996189b890f292103d9318b53e (patch)
treecd2a2fd222994c64d5ad946dfb8210848e2fc5e6 /libsolidity/codegen/CompilerContext.cpp
parent636e480156130ec44c5b85890ebe0c3792a75061 (diff)
parentbff8fc23e6cc602511b52aaa665e63b948eba068 (diff)
downloaddexon-solidity-b2c35fb41a65dc996189b890f292103d9318b53e.tar
dexon-solidity-b2c35fb41a65dc996189b890f292103d9318b53e.tar.gz
dexon-solidity-b2c35fb41a65dc996189b890f292103d9318b53e.tar.bz2
dexon-solidity-b2c35fb41a65dc996189b890f292103d9318b53e.tar.lz
dexon-solidity-b2c35fb41a65dc996189b890f292103d9318b53e.tar.xz
dexon-solidity-b2c35fb41a65dc996189b890f292103d9318b53e.tar.zst
dexon-solidity-b2c35fb41a65dc996189b890f292103d9318b53e.zip
Merge pull request #1598 from wuestholz/develop
Change translation of implicit throws
Diffstat (limited to 'libsolidity/codegen/CompilerContext.cpp')
-rw-r--r--libsolidity/codegen/CompilerContext.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp
index e26f96e8..a8316109 100644
--- a/libsolidity/codegen/CompilerContext.cpp
+++ b/libsolidity/codegen/CompilerContext.cpp
@@ -70,19 +70,30 @@ void CompilerContext::callLowLevelFunction(
eth::AssemblyItem retTag = pushNewTag();
CompilerUtils(*this).moveIntoStack(_inArgs);
+ *this << lowLevelFunctionTag(_name, _inArgs, _outArgs, _generator);
+
+ appendJump(eth::AssemblyItem::JumpType::IntoFunction);
+ adjustStackOffset(int(_outArgs) - 1 - _inArgs);
+ *this << retTag.tag();
+}
+
+eth::AssemblyItem CompilerContext::lowLevelFunctionTag(
+ string const& _name,
+ unsigned _inArgs,
+ unsigned _outArgs,
+ function<void(CompilerContext&)> const& _generator
+)
+{
auto it = m_lowLevelFunctions.find(_name);
if (it == m_lowLevelFunctions.end())
{
eth::AssemblyItem tag = newTag().pushTag();
m_lowLevelFunctions.insert(make_pair(_name, tag));
m_lowLevelFunctionGenerationQueue.push(make_tuple(_name, _inArgs, _outArgs, _generator));
- *this << tag;
+ return tag;
}
else
- *this << it->second;
- appendJump(eth::AssemblyItem::JumpType::IntoFunction);
- adjustStackOffset(int(_outArgs) - 1 - _inArgs);
- *this << retTag.tag();
+ return it->second;
}
void CompilerContext::appendMissingLowLevelFunctions()
@@ -215,6 +226,20 @@ CompilerContext& CompilerContext::appendJump(eth::AssemblyItem::JumpType _jumpTy
return *this << item;
}
+CompilerContext& CompilerContext::appendInvalid()
+{
+ return *this << Instruction::INVALID;
+}
+
+CompilerContext& CompilerContext::appendConditionalInvalid()
+{
+ *this << Instruction::ISZERO;
+ eth::AssemblyItem afterTag = appendConditionalJump();
+ *this << Instruction::INVALID;
+ *this << afterTag;
+ return *this;
+}
+
void CompilerContext::resetVisitedNodes(ASTNode const* _node)
{
stack<ASTNode const*> newStack;