Fixing while

master
Apoorva Ranade 4 years ago
parent ade63910b8
commit 54b792ba10

@ -718,13 +718,13 @@ public class CodeGenImpl extends CodeGenBase
{
Label startLoop = generateLocalLabel();
backend.emitLocalLabel(startLoop, "Beginning of while loop");
node.condition.dispatch(this);
Register result = node.condition.dispatch(this);
Label endLoop = elseBlock;
backend.emitBEQZ(result, endLoop,"Jump to beginning of loop");
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;
}

Loading…
Cancel
Save