3 public class LoopNode extends BlockStatementNode {
5 ExpressionNode condition;
9 public static int FORLOOP=1;
10 public static int WHILELOOP=2;
11 public static int DOWHILELOOP=3;
14 public LoopNode(BlockNode initializer,ExpressionNode condition, BlockNode update, BlockNode body, String label) {
15 this.initializer=initializer;
16 this.condition=condition;
19 initializer.setStyle(BlockNode.EXPRLIST);
20 update.setStyle(BlockNode.EXPRLIST);
25 public LoopNode(ExpressionNode condition, BlockNode body, int type, String label) {
26 this.condition=condition;
32 public BlockNode getInitializer() {
36 public ExpressionNode getCondition() {
40 public BlockNode getUpdate() {
44 public BlockNode getBody() {
48 public String printNode(int indent) {
50 return "for("+initializer.printNode(0)+";"+condition.printNode(0)+
51 ";"+update.printNode(0)+") "+body.printNode(indent)+"\n";
52 } else if (type==WHILELOOP) {
53 return "while("+condition.printNode(0)+") "+body.printNode(indent+INDENT)+"\n";
54 } else if (type==DOWHILELOOP) {
55 return "do "+ body.printNode(indent+INDENT)+
56 "while("+condition.printNode(0)+")\n";
57 } else throw new Error();
60 public int getType() {
68 public void setLabel(String l) {
72 public String getLabel() {