|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| package koala.dynamicjava.tree; |
|
30 |
| |
|
31 |
| import java.util.*; |
|
32 |
| |
|
33 |
| import edu.rice.cs.plt.tuple.Option; |
|
34 |
| |
|
35 |
| import koala.dynamicjava.tree.tiger.TypeParameter; |
|
36 |
| import koala.dynamicjava.tree.visitor.*; |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| public class ConstructorDeclaration extends Declaration { |
|
46 |
| private Option<List<TypeParameter>> typeParams; |
|
47 |
| private String name; |
|
48 |
| private List<FormalParameter> parameters; |
|
49 |
| private List<? extends ReferenceTypeName> exceptions; |
|
50 |
| private ConstructorCall constructorInvocation; |
|
51 |
| private List<Node> statements; |
|
52 |
| |
|
53 |
| private boolean varargs; |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
0
| public ConstructorDeclaration(ModifierSet mods, String name,
|
|
67 |
| List<FormalParameter> params, List<? extends ReferenceTypeName> excepts, |
|
68 |
| ConstructorCall eci, List<Node> stmts) { |
|
69 |
0
| this(mods, Option.<List<TypeParameter>>none(), name, params, excepts, eci, stmts, SourceInfo.NONE);
|
|
70 |
| } |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
| |
|
78 |
| |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
0
| public ConstructorDeclaration(ModifierSet mods, Option<List<TypeParameter>> tparams, String name,
|
|
85 |
| List<FormalParameter> params, List<? extends ReferenceTypeName> excepts, |
|
86 |
| ConstructorCall eci, List<Node> stmts) { |
|
87 |
0
| this(mods, tparams, name, params, excepts, eci, stmts, SourceInfo.NONE);
|
|
88 |
| } |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
| |
|
94 |
| |
|
95 |
| |
|
96 |
| |
|
97 |
| |
|
98 |
| |
|
99 |
| |
|
100 |
| |
|
101 |
0
| public ConstructorDeclaration(ModifierSet mods, String name,
|
|
102 |
| List<FormalParameter> params, List<? extends ReferenceTypeName> excepts, |
|
103 |
| ConstructorCall eci, List<Node> stmts, |
|
104 |
| SourceInfo si) { |
|
105 |
0
| this(mods, Option.<List<TypeParameter>>none(), name, params, excepts, eci, stmts, si);
|
|
106 |
| } |
|
107 |
| |
|
108 |
| |
|
109 |
| |
|
110 |
| |
|
111 |
| |
|
112 |
| |
|
113 |
| |
|
114 |
| |
|
115 |
| |
|
116 |
| |
|
117 |
| |
|
118 |
| |
|
119 |
69
| public ConstructorDeclaration(ModifierSet mods, Option<List<TypeParameter>> tparams, String name,
|
|
120 |
| List<FormalParameter> params, List<? extends ReferenceTypeName> excepts, |
|
121 |
| ConstructorCall eci, List<Node> stmts, |
|
122 |
| SourceInfo si) { |
|
123 |
69
| super(mods, si);
|
|
124 |
| |
|
125 |
69
| if (tparams == null || name == null || params == null || excepts == null || stmts == null) {
|
|
126 |
0
| throw new IllegalArgumentException();
|
|
127 |
| } |
|
128 |
69
| typeParams = tparams;
|
|
129 |
69
| this.name = name;
|
|
130 |
69
| parameters = params;
|
|
131 |
69
| constructorInvocation = eci;
|
|
132 |
69
| statements = stmts;
|
|
133 |
69
| exceptions = excepts;
|
|
134 |
| } |
|
135 |
| |
|
136 |
327
| public Option<List<TypeParameter>> getTypeParams() { return typeParams; }
|
|
137 |
0
| public void setTypeArgs(List<TypeParameter> tparams) { typeParams = Option.wrap(tparams); }
|
|
138 |
0
| public void setTypeArgs(Option<List<TypeParameter>> tparams) {
|
|
139 |
0
| if (tparams == null) throw new IllegalArgumentException();
|
|
140 |
0
| typeParams = tparams;
|
|
141 |
| } |
|
142 |
| |
|
143 |
| |
|
144 |
| |
|
145 |
| |
|
146 |
69
| public String getName() {
|
|
147 |
69
| return name;
|
|
148 |
| } |
|
149 |
| |
|
150 |
| |
|
151 |
| |
|
152 |
| |
|
153 |
| |
|
154 |
0
| public void setName(String s) {
|
|
155 |
0
| if (s == null) throw new IllegalArgumentException("s == null");
|
|
156 |
0
| name = s;
|
|
157 |
| } |
|
158 |
| |
|
159 |
| |
|
160 |
| |
|
161 |
| |
|
162 |
547
| public List<FormalParameter> getParameters() {
|
|
163 |
547
| return parameters;
|
|
164 |
| } |
|
165 |
| |
|
166 |
| |
|
167 |
| |
|
168 |
| |
|
169 |
0
| public void setParameters(List<FormalParameter> l) {
|
|
170 |
0
| parameters = l;
|
|
171 |
| } |
|
172 |
| |
|
173 |
| |
|
174 |
| |
|
175 |
| |
|
176 |
| |
|
177 |
234
| public List<? extends ReferenceTypeName> getExceptions() {
|
|
178 |
234
| return exceptions;
|
|
179 |
| } |
|
180 |
| |
|
181 |
| |
|
182 |
| |
|
183 |
| |
|
184 |
| |
|
185 |
0
| public void setExceptions(List<? extends ReferenceTypeName> l) {
|
|
186 |
0
| if (l == null) throw new IllegalArgumentException("l == null");
|
|
187 |
0
| exceptions = l;
|
|
188 |
| } |
|
189 |
| |
|
190 |
| |
|
191 |
| |
|
192 |
| |
|
193 |
98
| public ConstructorCall getConstructorCall() {
|
|
194 |
98
| return constructorInvocation;
|
|
195 |
| } |
|
196 |
| |
|
197 |
| |
|
198 |
| |
|
199 |
| |
|
200 |
0
| public void setConstructorCall(ConstructorCall ci) {
|
|
201 |
0
| constructorInvocation = ci;
|
|
202 |
| } |
|
203 |
| |
|
204 |
| |
|
205 |
| |
|
206 |
| |
|
207 |
100
| public List<Node> getStatements() {
|
|
208 |
100
| return statements;
|
|
209 |
| } |
|
210 |
| |
|
211 |
| |
|
212 |
| |
|
213 |
| |
|
214 |
| |
|
215 |
0
| public void setStatements(List<Node> l) {
|
|
216 |
0
| if (l == null) throw new IllegalArgumentException("l == null");
|
|
217 |
0
| statements = l;
|
|
218 |
| } |
|
219 |
| |
|
220 |
0
| public boolean isVarArgs(){
|
|
221 |
0
| return varargs;
|
|
222 |
| } |
|
223 |
| |
|
224 |
| |
|
225 |
| |
|
226 |
| |
|
227 |
| |
|
228 |
226
| public <T> T acceptVisitor(Visitor<T> visitor) {
|
|
229 |
226
| return visitor.visit(this);
|
|
230 |
| } |
|
231 |
| |
|
232 |
| |
|
233 |
| |
|
234 |
0
| public String toString() {
|
|
235 |
0
| return "("+getClass().getName()+": "+toStringHelper()+")";
|
|
236 |
| } |
|
237 |
| |
|
238 |
0
| public String toStringHelper() {
|
|
239 |
0
| return getModifiers()+" "+getName()+" "+getParameters()+" "+getExceptions()+" "+getConstructorCall()+" "+getStatements();
|
|
240 |
| } |
|
241 |
| } |