|
1 |
| package edu.rice.cs.javalanglevels.tree; |
|
2 |
| |
|
3 |
| import edu.rice.cs.javalanglevels.SourceInfo; |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| public class ForStatement extends Statement { |
|
11 |
| private final ForInitI _init; |
|
12 |
| private final ForConditionI _condition; |
|
13 |
| private final UnparenthesizedExpressionList _update; |
|
14 |
| private final Statement _code; |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
13
| public ForStatement(SourceInfo in_sourceInfo, ForInitI in_init, ForConditionI in_condition, UnparenthesizedExpressionList in_update, Statement in_code) {
|
|
21 |
13
| super(in_sourceInfo);
|
|
22 |
| |
|
23 |
13
| if (in_init == null) {
|
|
24 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'init' to the ForStatement constructor was null. This class may not have null field values.");
|
|
25 |
| } |
|
26 |
13
| _init = in_init;
|
|
27 |
| |
|
28 |
13
| if (in_condition == null) {
|
|
29 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'condition' to the ForStatement constructor was null. This class may not have null field values.");
|
|
30 |
| } |
|
31 |
13
| _condition = in_condition;
|
|
32 |
| |
|
33 |
13
| if (in_update == null) {
|
|
34 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'update' to the ForStatement constructor was null. This class may not have null field values.");
|
|
35 |
| } |
|
36 |
13
| _update = in_update;
|
|
37 |
| |
|
38 |
13
| if (in_code == null) {
|
|
39 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'code' to the ForStatement constructor was null. This class may not have null field values.");
|
|
40 |
| } |
|
41 |
13
| _code = in_code;
|
|
42 |
| } |
|
43 |
| |
|
44 |
14
| final public ForInitI getInit() { return _init; }
|
|
45 |
24
| final public ForConditionI getCondition() { return _condition; }
|
|
46 |
14
| final public UnparenthesizedExpressionList getUpdate() { return _update; }
|
|
47 |
14
| final public Statement getCode() { return _code; }
|
|
48 |
| |
|
49 |
10
| public <RetType> RetType visit(JExpressionIFVisitor<RetType> visitor) { return visitor.forForStatement(this); }
|
|
50 |
0
| public void visit(JExpressionIFVisitor_void visitor) { visitor.forForStatement(this); }
|
|
51 |
| |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
| |
|
56 |
0
| public java.lang.String toString() {
|
|
57 |
0
| java.io.StringWriter w = new java.io.StringWriter();
|
|
58 |
0
| output(w);
|
|
59 |
0
| return w.toString();
|
|
60 |
| } |
|
61 |
| |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
0
| public void output(java.io.Writer writer) {
|
|
66 |
0
| outputHelp(new TabPrintWriter(writer, 2));
|
|
67 |
| } |
|
68 |
| |
|
69 |
4
| public void outputHelp(TabPrintWriter writer) {
|
|
70 |
4
| writer.print("ForStatement" + ":");
|
|
71 |
4
| writer.indent();
|
|
72 |
| |
|
73 |
4
| writer.startLine("");
|
|
74 |
4
| writer.print("sourceInfo = ");
|
|
75 |
4
| SourceInfo temp_sourceInfo = getSourceInfo();
|
|
76 |
4
| if (temp_sourceInfo == null) {
|
|
77 |
0
| writer.print("null");
|
|
78 |
| } else { |
|
79 |
4
| writer.print(temp_sourceInfo);
|
|
80 |
| } |
|
81 |
| |
|
82 |
4
| writer.startLine("");
|
|
83 |
4
| writer.print("init = ");
|
|
84 |
4
| ForInitI temp_init = getInit();
|
|
85 |
4
| if (temp_init == null) {
|
|
86 |
0
| writer.print("null");
|
|
87 |
| } else { |
|
88 |
4
| temp_init.outputHelp(writer);
|
|
89 |
| } |
|
90 |
| |
|
91 |
4
| writer.startLine("");
|
|
92 |
4
| writer.print("condition = ");
|
|
93 |
4
| ForConditionI temp_condition = getCondition();
|
|
94 |
4
| if (temp_condition == null) {
|
|
95 |
0
| writer.print("null");
|
|
96 |
| } else { |
|
97 |
4
| temp_condition.outputHelp(writer);
|
|
98 |
| } |
|
99 |
| |
|
100 |
4
| writer.startLine("");
|
|
101 |
4
| writer.print("update = ");
|
|
102 |
4
| UnparenthesizedExpressionList temp_update = getUpdate();
|
|
103 |
4
| if (temp_update == null) {
|
|
104 |
0
| writer.print("null");
|
|
105 |
| } else { |
|
106 |
4
| temp_update.outputHelp(writer);
|
|
107 |
| } |
|
108 |
| |
|
109 |
4
| writer.startLine("");
|
|
110 |
4
| writer.print("code = ");
|
|
111 |
4
| Statement temp_code = getCode();
|
|
112 |
4
| if (temp_code == null) {
|
|
113 |
0
| writer.print("null");
|
|
114 |
| } else { |
|
115 |
4
| temp_code.outputHelp(writer);
|
|
116 |
| } |
|
117 |
4
| writer.unindent();
|
|
118 |
| } |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
| |
|
125 |
0
| public boolean equals(java.lang.Object obj) {
|
|
126 |
0
| if (obj == null) return false;
|
|
127 |
0
| if ((obj.getClass() != this.getClass()) || (obj.hashCode() != this.hashCode())) {
|
|
128 |
0
| return false;
|
|
129 |
| } else { |
|
130 |
0
| ForStatement casted = (ForStatement) obj;
|
|
131 |
0
| if (! (getInit().equals(casted.getInit()))) return false;
|
|
132 |
0
| if (! (getCondition().equals(casted.getCondition()))) return false;
|
|
133 |
0
| if (! (getUpdate().equals(casted.getUpdate()))) return false;
|
|
134 |
0
| if (! (getCode().equals(casted.getCode()))) return false;
|
|
135 |
0
| return true;
|
|
136 |
| } |
|
137 |
| } |
|
138 |
| |
|
139 |
| |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
| |
|
145 |
0
| protected int generateHashCode() {
|
|
146 |
0
| int code = getClass().hashCode();
|
|
147 |
0
| code ^= 0;
|
|
148 |
0
| code ^= getInit().hashCode();
|
|
149 |
0
| code ^= getCondition().hashCode();
|
|
150 |
0
| code ^= getUpdate().hashCode();
|
|
151 |
0
| code ^= getCode().hashCode();
|
|
152 |
0
| return code;
|
|
153 |
| } |
|
154 |
| } |