Fixed Ifs
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user