Reverse if and else body.

This commit is contained in:
chriseth 2015-05-12 17:50:41 +02:00
parent 78a343d2ff
commit da121c9a26

View File

@ -377,12 +377,16 @@ bool Compiler::visit(IfStatement const& _ifStatement)
StackHeightChecker checker(m_context); StackHeightChecker checker(m_context);
CompilerContext::LocationSetter locationSetter(m_context, _ifStatement); CompilerContext::LocationSetter locationSetter(m_context, _ifStatement);
compileExpression(_ifStatement.getCondition()); compileExpression(_ifStatement.getCondition());
eth::AssemblyItem trueTag = m_context.appendConditionalJump(); m_context << eth::Instruction::ISZERO;
if (_ifStatement.getFalseStatement()) eth::AssemblyItem falseTag = m_context.appendConditionalJump();
_ifStatement.getFalseStatement()->accept(*this); eth::AssemblyItem endTag = falseTag;
eth::AssemblyItem endTag = m_context.appendJumpToNew();
m_context << trueTag;
_ifStatement.getTrueStatement().accept(*this); _ifStatement.getTrueStatement().accept(*this);
if (_ifStatement.getFalseStatement())
{
endTag = m_context.appendJumpToNew();
m_context << falseTag;
_ifStatement.getFalseStatement()->accept(*this);
}
m_context << endTag; m_context << endTag;
checker.check(); checker.check();