|
|
@ -381,7 +381,19 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
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
|
|
|
|
@Override
|
|
|
|
public Void analyze(ForStmt node) {
|
|
|
|
public Void analyze(ForStmt node) {
|
|
|
|
// control flow
|
|
|
|
// control flow
|
|
|
@ -415,11 +427,7 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Void analyze(WhileStmt node) {
|
|
|
|
|
|
|
|
// control flow
|
|
|
|
|
|
|
|
return defaultAction(node);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|