Fixing while
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user