diff options
author | chriseth <chris@ethereum.org> | 2018-05-15 21:04:19 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-05-17 00:32:48 +0800 |
commit | 22ff3b736a9bd3a44dbe2c3f31ad4505babd2248 (patch) | |
tree | 22d81baf4fcb7f24f356b037a2c57fb69cd0bf18 /libsolidity/codegen/ContractCompiler.cpp | |
parent | 90528a2867033359afc25cdc0915b76b21e3ff58 (diff) | |
parent | 1cbc037a45b7aaab20a61750a196f956e9962eb7 (diff) | |
download | dexon-solidity-22ff3b736a9bd3a44dbe2c3f31ad4505babd2248.tar dexon-solidity-22ff3b736a9bd3a44dbe2c3f31ad4505babd2248.tar.gz dexon-solidity-22ff3b736a9bd3a44dbe2c3f31ad4505babd2248.tar.bz2 dexon-solidity-22ff3b736a9bd3a44dbe2c3f31ad4505babd2248.tar.lz dexon-solidity-22ff3b736a9bd3a44dbe2c3f31ad4505babd2248.tar.xz dexon-solidity-22ff3b736a9bd3a44dbe2c3f31ad4505babd2248.tar.zst dexon-solidity-22ff3b736a9bd3a44dbe2c3f31ad4505babd2248.zip |
Merge pull request #4129 from ethereum/doWhileContinue
[BREAKING] Fix continue inside do-while.
Diffstat (limited to 'libsolidity/codegen/ContractCompiler.cpp')
-rw-r--r-- | libsolidity/codegen/ContractCompiler.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 0889ac7c..f195b416 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -666,32 +666,36 @@ bool ContractCompiler::visit(WhileStatement const& _whileStatement) { StackHeightChecker checker(m_context); CompilerContext::LocationSetter locationSetter(m_context, _whileStatement); + eth::AssemblyItem loopStart = m_context.newTag(); eth::AssemblyItem loopEnd = m_context.newTag(); - m_continueTags.push_back(loopStart); m_breakTags.push_back(loopEnd); m_context << loopStart; - // While loops have the condition prepended - if (!_whileStatement.isDoWhile()) + if (_whileStatement.isDoWhile()) { - compileExpression(_whileStatement.condition()); - m_context << Instruction::ISZERO; - m_context.appendConditionalJumpTo(loopEnd); - } + eth::AssemblyItem condition = m_context.newTag(); + m_continueTags.push_back(condition); - _whileStatement.body().accept(*this); + _whileStatement.body().accept(*this); - // Do-while loops have the condition appended - if (_whileStatement.isDoWhile()) + m_context << condition; + compileExpression(_whileStatement.condition()); + m_context << Instruction::ISZERO << Instruction::ISZERO; + m_context.appendConditionalJumpTo(loopStart); + } + else { + m_continueTags.push_back(loopStart); compileExpression(_whileStatement.condition()); m_context << Instruction::ISZERO; m_context.appendConditionalJumpTo(loopEnd); - } - m_context.appendJumpTo(loopStart); + _whileStatement.body().accept(*this); + + m_context.appendJumpTo(loopStart); + } m_context << loopEnd; m_continueTags.pop_back(); |