1
3 package jminusminus;
4
5 import java.util.ArrayList;
6
7 import static jminusminus.CLConstants.*;
8
9
12 class JForStatement extends JStatement {
13 private ArrayList<JStatement> init;
15
16 private JExpression condition;
18
19 private ArrayList<JStatement> update;
21
22 private JStatement body;
24
25
34 public JForStatement(int line, ArrayList<JStatement> init, JExpression condition,
35 ArrayList<JStatement> update, JStatement body) {
36 super(line);
37 this.init = init;
38 this.condition = condition;
39 this.update = update;
40 this.body = body;
41 }
42
43
46 public JForStatement analyze(Context context) {
47 return this;
49 }
50
51
54 public void codegen(CLEmitter output) {
55 }
57
58
61 public void toJSON(JSONElement json) {
62 JSONElement e = new JSONElement();
63 json.addChild("JForStatement:" + line, e);
64 if (init != null) {
65 JSONElement e1 = new JSONElement();
66 e.addChild("Init", e1);
67 for (JStatement stmt : init) {
68 stmt.toJSON(e1);
69 }
70 }
71 if (condition != null) {
72 JSONElement e1 = new JSONElement();
73 e.addChild("Condition", e1);
74 condition.toJSON(e1);
75 }
76 if (update != null) {
77 JSONElement e1 = new JSONElement();
78 e.addChild("Update", e1);
79 for (JStatement stmt : update) {
80 stmt.toJSON(e1);
81 }
82 }
83 if (body != null) {
84 JSONElement e1 = new JSONElement();
85 e.addChild("Body", e1);
86 body.toJSON(e1);
87 }
88 }
89 }
90