diff options
author | chriseth <chris@ethereum.org> | 2017-06-14 21:35:51 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-06-16 18:29:40 +0800 |
commit | ce5ef08e05667d74283f18f79c3bb5970f39e946 (patch) | |
tree | f32fc9c0dbc6c24e32e3e18a662191b1beae0f29 /libjulia/backends/evm | |
parent | ea0a86a9954c63c47234b55f53a7ca9df26e1efe (diff) | |
download | dexon-solidity-ce5ef08e05667d74283f18f79c3bb5970f39e946.tar.gz dexon-solidity-ce5ef08e05667d74283f18f79c3bb5970f39e946.tar.zst dexon-solidity-ce5ef08e05667d74283f18f79c3bb5970f39e946.zip |
Helper for visiting statements.
Diffstat (limited to 'libjulia/backends/evm')
-rw-r--r-- | libjulia/backends/evm/EVMCodeTransform.cpp | 11 | ||||
-rw-r--r-- | libjulia/backends/evm/EVMCodeTransform.h | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/libjulia/backends/evm/EVMCodeTransform.cpp b/libjulia/backends/evm/EVMCodeTransform.cpp index a50af9af..c543a507 100644 --- a/libjulia/backends/evm/EVMCodeTransform.cpp +++ b/libjulia/backends/evm/EVMCodeTransform.cpp @@ -345,8 +345,7 @@ void CodeTransform::operator()(ForLoop const& _forLoop) m_scope = m_info.scopes.at(&_forLoop.pre).get(); int stackStartHeight = m_assembly.stackHeight(); - for (auto const& statement: _forLoop.pre.statements) - boost::apply_visitor(*this, statement); + visitStatements(_forLoop.pre.statements); // TODO: When we implement break and continue, the labels and the stack heights at that point // have to be stored in a stack. @@ -382,7 +381,7 @@ void CodeTransform::operator()(Block const& _block) m_scope = m_info.scopes.at(&_block).get(); int blockStartStackHeight = m_assembly.stackHeight(); - std::for_each(_block.statements.begin(), _block.statements.end(), boost::apply_visitor(*this)); + visitStatements(_block.statements); finalizeBlock(_block, blockStartStackHeight); m_scope = originalScope; @@ -426,6 +425,12 @@ void CodeTransform::visitExpression(Statement const& _expression) expectDeposit(1, height); } +void CodeTransform::visitStatements(vector<Statement> const& _statements) +{ + for (auto const& statement: _statements) + boost::apply_visitor(*this, statement); +} + void CodeTransform::finalizeBlock(Block const& _block, int blockStartStackHeight) { m_assembly.setSourceLocation(_block.location); diff --git a/libjulia/backends/evm/EVMCodeTransform.h b/libjulia/backends/evm/EVMCodeTransform.h index 57bd4ca5..d09ee87b 100644 --- a/libjulia/backends/evm/EVMCodeTransform.h +++ b/libjulia/backends/evm/EVMCodeTransform.h @@ -110,6 +110,8 @@ private: /// Generates code for an expression that is supposed to return a single value. void visitExpression(solidity::assembly::Statement const& _expression); + void visitStatements(std::vector<solidity::assembly::Statement> const& _statements); + /// Pops all variables declared in the block and checks that the stack height is equal /// to @a _blackStartStackHeight. void finalizeBlock(solidity::assembly::Block const& _block, int _blockStartStackHeight); |