aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/ContractCompiler.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-05-24 00:11:20 +0800
committerGitHub <noreply@github.com>2018-05-24 00:11:20 +0800
commit5ee2ce353edfddbf925e775b321247246d150593 (patch)
tree5803f4c77e989f9b778d3702e82cdcfc8a897e0a /libsolidity/codegen/ContractCompiler.cpp
parent6d08341942763730ba19c882520a4f45bb350b20 (diff)
parent87a838583290d66f4d4d78149a6d7398a41750ec (diff)
downloaddexon-solidity-5ee2ce353edfddbf925e775b321247246d150593.tar
dexon-solidity-5ee2ce353edfddbf925e775b321247246d150593.tar.gz
dexon-solidity-5ee2ce353edfddbf925e775b321247246d150593.tar.bz2
dexon-solidity-5ee2ce353edfddbf925e775b321247246d150593.tar.lz
dexon-solidity-5ee2ce353edfddbf925e775b321247246d150593.tar.xz
dexon-solidity-5ee2ce353edfddbf925e775b321247246d150593.tar.zst
dexon-solidity-5ee2ce353edfddbf925e775b321247246d150593.zip
Merge pull request #4067 from ethereum/050
[BREAKING] Version 0.5.0
Diffstat (limited to 'libsolidity/codegen/ContractCompiler.cpp')
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp28
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();