mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix continue inside do-while.
This commit is contained in:
committed by
chriseth
parent
90528a2867
commit
f627dc77d0
@@ -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())
|
||||
{
|
||||
compileExpression(_whileStatement.condition());
|
||||
m_context << Instruction::ISZERO;
|
||||
m_context.appendConditionalJumpTo(loopEnd);
|
||||
}
|
||||
|
||||
_whileStatement.body().accept(*this);
|
||||
|
||||
// Do-while loops have the condition appended
|
||||
if (_whileStatement.isDoWhile())
|
||||
{
|
||||
eth::AssemblyItem condition = m_context.newTag();
|
||||
m_continueTags.push_back(condition);
|
||||
|
||||
_whileStatement.body().accept(*this);
|
||||
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user