master
Apoorva Ranade 3 years ago
parent f92308238b
commit 1fb6f3f085

@ -381,7 +381,19 @@ public class CodeGenImpl extends CodeGenBase
{
return null;
}
@Override
public Void analyze(WhileStmt node)
{
Label startLoop = generateLocalLabel();
backend.emitLocalLabel(startLoop, "Beginning of while loop");
node.condition.dispatch(this);
Label endLoop = elseBlock;
for(Stmt stmt:node.body)
stmt.dispatch(this);
backend.emitJ(startLoop, "Jump to beginning of loop");
backend.emitLocalLabel(endLoop, "End of while loop");
return null;
}
@Override
public Void analyze(ForStmt node) {
// control flow
@ -415,11 +427,7 @@ public class CodeGenImpl extends CodeGenBase
@Override
public Void analyze(WhileStmt node) {
// control flow
return defaultAction(node);
}
}
/**

Loading…
Cancel
Save