| JDoStatement.java |
1 // Copyright 2012- Bill Campbell, Swami Iyer and Bahar Akbal-Delibas
2
3 package jminusminus;
4
5 import static jminusminus.CLConstants.*;
6
7 /**
8 * The AST node for a do-statement.
9 */
10 public class JDoStatement extends JStatement {
11 // Body.
12 private JStatement body;
13
14 // Test expression.
15 private JExpression condition;
16
17 /**
18 * Constructs an AST node for a do-statement.
19 *
20 * @param line line in which the do-statement occurs in the source file.
21 * @param body the body.
22 * @param condition test expression.
23 */
24 public JDoStatement(int line, JStatement body, JExpression condition) {
25 super(line);
26 this.body = body;
27 this.condition = condition;
28 }
29
30 /**
31 * {@inheritDoc}
32 */
33 public JStatement analyze(Context context) {
34 // TODO
35 return this;
36 }
37
38 /**
39 * {@inheritDoc}
40 */
41 public void codegen(CLEmitter output) {
42 // TODO
43 }
44
45 /**
46 * {@inheritDoc}
47 */
48 public void toJSON(JSONElement json) {
49 JSONElement e = new JSONElement();
50 json.addChild("JDoStatement:" + line, e);
51 JSONElement e1 = new JSONElement();
52 e.addChild("Body", e1);
53 body.toJSON(e1);
54 JSONElement e2 = new JSONElement();
55 e.addChild("Condition", e2);
56 condition.toJSON(e2);
57 }
58 }
59