| JThrowStatement.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 * An AST node for a throw-statement.
9 */
10 class JThrowStatement extends JStatement {
11 // The thrown exception.
12 private JExpression expr;
13
14 /**
15 * Constructs an AST node for a throw-statement.
16 *
17 * @param line line in which the throw-statement appears in the source file.
18 * @param expr the returned expression.
19 */
20 public JThrowStatement(int line, JExpression expr) {
21 super(line);
22 this.expr = expr;
23 }
24
25 /**
26 * {@inheritDoc}
27 */
28 public JStatement analyze(Context context) {
29 // TODO
30 return this;
31 }
32
33 /**
34 * {@inheritDoc}
35 */
36 public void codegen(CLEmitter output) {
37 // TODO
38 }
39
40 /**
41 * {@inheritDoc}
42 */
43 public void toJSON(JSONElement json) {
44 JSONElement e = new JSONElement();
45 json.addChild("JThrowStatement:" + line, e);
46 JSONElement e1 = new JSONElement();
47 e.addChild("Expression", e1);
48 expr.toJSON(e1);
49 }
50 }
51