While loop
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user