master
Apoorva Ranade 4 years ago
parent 54b792ba10
commit 9e2b344bd2

@ -415,8 +415,9 @@ public class CodeGenImpl extends CodeGenBase
@Override
public Register analyze(IfExpr node)
{
node.condition.dispatch(this);
Register result = node.condition.dispatch(this);
Label ln = generateLocalLabel();
backend.emitBEQZ(result, ln,"Jump to beginning of loop");
node.thenExpr.dispatch(this);
backend.emitJ(ln, "Jump to end of if expression");
backend.emitLocalLabel(elseBlock, "Else part of if expression");
@ -428,8 +429,9 @@ public class CodeGenImpl extends CodeGenBase
@Override
public Register analyze(IfStmt node)
{
node.condition.dispatch(this);
Register result = node.condition.dispatch(this);
Label ln = generateLocalLabel();
backend.emitBEQZ(result, ln,"Jump to beginning of loop");
for(Stmt s:node.thenBody)
s.dispatch(this);
backend.emitJ(ln, "Jump to end of if statement");

Loading…
Cancel
Save