diff options
author | chriseth <c@ethdev.com> | 2017-01-26 23:35:51 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2017-01-26 23:39:07 +0800 |
commit | d9fbb83861153499b4aec5525db85ec59445abd1 (patch) | |
tree | eae595b95caf1b280ed99f74b5c4f18ec5317de3 /libsolidity/codegen/CompilerContext.cpp | |
parent | 390bebaaf9e2af51c7e2f72337d1e7b23f51486a (diff) | |
download | dexon-solidity-d9fbb83861153499b4aec5525db85ec59445abd1.tar.gz dexon-solidity-d9fbb83861153499b4aec5525db85ec59445abd1.tar.zst dexon-solidity-d9fbb83861153499b4aec5525db85ec59445abd1.zip |
Allow inserting low-level functions without calling them.
Diffstat (limited to 'libsolidity/codegen/CompilerContext.cpp')
-rw-r--r-- | libsolidity/codegen/CompilerContext.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index 7577a606..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() |