1 | /* This file was generated by SableCC (http://www.sablecc.org/). */ |
2 | |
3 | package uk.co.zonetora.fj.ast.node; |
4 | |
5 | import java.util.*; |
6 | import uk.co.zonetora.fj.ast.analysis.*; |
7 | |
8 | public final class AClassDecl extends PClassDecl |
9 | { |
10 | private TTclass _tclass_; |
11 | private TIdentifier _classname_; |
12 | private TExtends _extends_; |
13 | private TIdentifier _extendsname_; |
14 | private TLBrace _lBrace_; |
15 | private final LinkedList _fieldDecl_ = new TypedLinkedList(new FieldDecl_Cast()); |
16 | private PConstructorDecl _constructorDecl_; |
17 | private final LinkedList _methodDecl_ = new TypedLinkedList(new MethodDecl_Cast()); |
18 | private TRBrace _rBrace_; |
19 | |
20 | public AClassDecl() |
21 | { |
22 | } |
23 | |
24 | public AClassDecl( |
25 | TTclass _tclass_, |
26 | TIdentifier _classname_, |
27 | TExtends _extends_, |
28 | TIdentifier _extendsname_, |
29 | TLBrace _lBrace_, |
30 | List _fieldDecl_, |
31 | PConstructorDecl _constructorDecl_, |
32 | List _methodDecl_, |
33 | TRBrace _rBrace_) |
34 | { |
35 | setTclass(_tclass_); |
36 | |
37 | setClassname(_classname_); |
38 | |
39 | setExtends(_extends_); |
40 | |
41 | setExtendsname(_extendsname_); |
42 | |
43 | setLBrace(_lBrace_); |
44 | |
45 | { |
46 | this._fieldDecl_.clear(); |
47 | this._fieldDecl_.addAll(_fieldDecl_); |
48 | } |
49 | |
50 | setConstructorDecl(_constructorDecl_); |
51 | |
52 | { |
53 | this._methodDecl_.clear(); |
54 | this._methodDecl_.addAll(_methodDecl_); |
55 | } |
56 | |
57 | setRBrace(_rBrace_); |
58 | |
59 | } |
60 | |
61 | public AClassDecl( |
62 | TTclass _tclass_, |
63 | TIdentifier _classname_, |
64 | TExtends _extends_, |
65 | TIdentifier _extendsname_, |
66 | TLBrace _lBrace_, |
67 | XPFieldDecl _fieldDecl_, |
68 | PConstructorDecl _constructorDecl_, |
69 | XPMethodDecl _methodDecl_, |
70 | TRBrace _rBrace_) |
71 | { |
72 | setTclass(_tclass_); |
73 | |
74 | setClassname(_classname_); |
75 | |
76 | setExtends(_extends_); |
77 | |
78 | setExtendsname(_extendsname_); |
79 | |
80 | setLBrace(_lBrace_); |
81 | |
82 | if(_fieldDecl_ != null) |
83 | { |
84 | while(_fieldDecl_ instanceof X1PFieldDecl) |
85 | { |
86 | this._fieldDecl_.addFirst(((X1PFieldDecl) _fieldDecl_).getPFieldDecl()); |
87 | _fieldDecl_ = ((X1PFieldDecl) _fieldDecl_).getXPFieldDecl(); |
88 | } |
89 | this._fieldDecl_.addFirst(((X2PFieldDecl) _fieldDecl_).getPFieldDecl()); |
90 | } |
91 | |
92 | setConstructorDecl(_constructorDecl_); |
93 | |
94 | if(_methodDecl_ != null) |
95 | { |
96 | while(_methodDecl_ instanceof X1PMethodDecl) |
97 | { |
98 | this._methodDecl_.addFirst(((X1PMethodDecl) _methodDecl_).getPMethodDecl()); |
99 | _methodDecl_ = ((X1PMethodDecl) _methodDecl_).getXPMethodDecl(); |
100 | } |
101 | this._methodDecl_.addFirst(((X2PMethodDecl) _methodDecl_).getPMethodDecl()); |
102 | } |
103 | |
104 | setRBrace(_rBrace_); |
105 | |
106 | } |
107 | public Object clone() |
108 | { |
109 | return new AClassDecl( |
110 | (TTclass) cloneNode(_tclass_), |
111 | (TIdentifier) cloneNode(_classname_), |
112 | (TExtends) cloneNode(_extends_), |
113 | (TIdentifier) cloneNode(_extendsname_), |
114 | (TLBrace) cloneNode(_lBrace_), |
115 | cloneList(_fieldDecl_), |
116 | (PConstructorDecl) cloneNode(_constructorDecl_), |
117 | cloneList(_methodDecl_), |
118 | (TRBrace) cloneNode(_rBrace_)); |
119 | } |
120 | |
121 | public void apply(Switch sw) |
122 | { |
123 | ((Analysis) sw).caseAClassDecl(this); |
124 | } |
125 | |
126 | public TTclass getTclass() |
127 | { |
128 | return _tclass_; |
129 | } |
130 | |
131 | public void setTclass(TTclass node) |
132 | { |
133 | if(_tclass_ != null) |
134 | { |
135 | _tclass_.parent(null); |
136 | } |
137 | |
138 | if(node != null) |
139 | { |
140 | if(node.parent() != null) |
141 | { |
142 | node.parent().removeChild(node); |
143 | } |
144 | |
145 | node.parent(this); |
146 | } |
147 | |
148 | _tclass_ = node; |
149 | } |
150 | |
151 | public TIdentifier getClassname() |
152 | { |
153 | return _classname_; |
154 | } |
155 | |
156 | public void setClassname(TIdentifier node) |
157 | { |
158 | if(_classname_ != null) |
159 | { |
160 | _classname_.parent(null); |
161 | } |
162 | |
163 | if(node != null) |
164 | { |
165 | if(node.parent() != null) |
166 | { |
167 | node.parent().removeChild(node); |
168 | } |
169 | |
170 | node.parent(this); |
171 | } |
172 | |
173 | _classname_ = node; |
174 | } |
175 | |
176 | public TExtends getExtends() |
177 | { |
178 | return _extends_; |
179 | } |
180 | |
181 | public void setExtends(TExtends node) |
182 | { |
183 | if(_extends_ != null) |
184 | { |
185 | _extends_.parent(null); |
186 | } |
187 | |
188 | if(node != null) |
189 | { |
190 | if(node.parent() != null) |
191 | { |
192 | node.parent().removeChild(node); |
193 | } |
194 | |
195 | node.parent(this); |
196 | } |
197 | |
198 | _extends_ = node; |
199 | } |
200 | |
201 | public TIdentifier getExtendsname() |
202 | { |
203 | return _extendsname_; |
204 | } |
205 | |
206 | public void setExtendsname(TIdentifier node) |
207 | { |
208 | if(_extendsname_ != null) |
209 | { |
210 | _extendsname_.parent(null); |
211 | } |
212 | |
213 | if(node != null) |
214 | { |
215 | if(node.parent() != null) |
216 | { |
217 | node.parent().removeChild(node); |
218 | } |
219 | |
220 | node.parent(this); |
221 | } |
222 | |
223 | _extendsname_ = node; |
224 | } |
225 | |
226 | public TLBrace getLBrace() |
227 | { |
228 | return _lBrace_; |
229 | } |
230 | |
231 | public void setLBrace(TLBrace node) |
232 | { |
233 | if(_lBrace_ != null) |
234 | { |
235 | _lBrace_.parent(null); |
236 | } |
237 | |
238 | if(node != null) |
239 | { |
240 | if(node.parent() != null) |
241 | { |
242 | node.parent().removeChild(node); |
243 | } |
244 | |
245 | node.parent(this); |
246 | } |
247 | |
248 | _lBrace_ = node; |
249 | } |
250 | |
251 | public LinkedList getFieldDecl() |
252 | { |
253 | return _fieldDecl_; |
254 | } |
255 | |
256 | public void setFieldDecl(List list) |
257 | { |
258 | _fieldDecl_.clear(); |
259 | _fieldDecl_.addAll(list); |
260 | } |
261 | |
262 | public PConstructorDecl getConstructorDecl() |
263 | { |
264 | return _constructorDecl_; |
265 | } |
266 | |
267 | public void setConstructorDecl(PConstructorDecl node) |
268 | { |
269 | if(_constructorDecl_ != null) |
270 | { |
271 | _constructorDecl_.parent(null); |
272 | } |
273 | |
274 | if(node != null) |
275 | { |
276 | if(node.parent() != null) |
277 | { |
278 | node.parent().removeChild(node); |
279 | } |
280 | |
281 | node.parent(this); |
282 | } |
283 | |
284 | _constructorDecl_ = node; |
285 | } |
286 | |
287 | public LinkedList getMethodDecl() |
288 | { |
289 | return _methodDecl_; |
290 | } |
291 | |
292 | public void setMethodDecl(List list) |
293 | { |
294 | _methodDecl_.clear(); |
295 | _methodDecl_.addAll(list); |
296 | } |
297 | |
298 | public TRBrace getRBrace() |
299 | { |
300 | return _rBrace_; |
301 | } |
302 | |
303 | public void setRBrace(TRBrace node) |
304 | { |
305 | if(_rBrace_ != null) |
306 | { |
307 | _rBrace_.parent(null); |
308 | } |
309 | |
310 | if(node != null) |
311 | { |
312 | if(node.parent() != null) |
313 | { |
314 | node.parent().removeChild(node); |
315 | } |
316 | |
317 | node.parent(this); |
318 | } |
319 | |
320 | _rBrace_ = node; |
321 | } |
322 | |
323 | public String toString() |
324 | { |
325 | return "" |
326 | + toString(_tclass_) |
327 | + toString(_classname_) |
328 | + toString(_extends_) |
329 | + toString(_extendsname_) |
330 | + toString(_lBrace_) |
331 | + toString(_fieldDecl_) |
332 | + toString(_constructorDecl_) |
333 | + toString(_methodDecl_) |
334 | + toString(_rBrace_); |
335 | } |
336 | |
337 | void removeChild(Node child) |
338 | { |
339 | if(_tclass_ == child) |
340 | { |
341 | _tclass_ = null; |
342 | return; |
343 | } |
344 | |
345 | if(_classname_ == child) |
346 | { |
347 | _classname_ = null; |
348 | return; |
349 | } |
350 | |
351 | if(_extends_ == child) |
352 | { |
353 | _extends_ = null; |
354 | return; |
355 | } |
356 | |
357 | if(_extendsname_ == child) |
358 | { |
359 | _extendsname_ = null; |
360 | return; |
361 | } |
362 | |
363 | if(_lBrace_ == child) |
364 | { |
365 | _lBrace_ = null; |
366 | return; |
367 | } |
368 | |
369 | if(_fieldDecl_.remove(child)) |
370 | { |
371 | return; |
372 | } |
373 | |
374 | if(_constructorDecl_ == child) |
375 | { |
376 | _constructorDecl_ = null; |
377 | return; |
378 | } |
379 | |
380 | if(_methodDecl_.remove(child)) |
381 | { |
382 | return; |
383 | } |
384 | |
385 | if(_rBrace_ == child) |
386 | { |
387 | _rBrace_ = null; |
388 | return; |
389 | } |
390 | |
391 | } |
392 | |
393 | void replaceChild(Node oldChild, Node newChild) |
394 | { |
395 | if(_tclass_ == oldChild) |
396 | { |
397 | setTclass((TTclass) newChild); |
398 | return; |
399 | } |
400 | |
401 | if(_classname_ == oldChild) |
402 | { |
403 | setClassname((TIdentifier) newChild); |
404 | return; |
405 | } |
406 | |
407 | if(_extends_ == oldChild) |
408 | { |
409 | setExtends((TExtends) newChild); |
410 | return; |
411 | } |
412 | |
413 | if(_extendsname_ == oldChild) |
414 | { |
415 | setExtendsname((TIdentifier) newChild); |
416 | return; |
417 | } |
418 | |
419 | if(_lBrace_ == oldChild) |
420 | { |
421 | setLBrace((TLBrace) newChild); |
422 | return; |
423 | } |
424 | |
425 | for(ListIterator i = _fieldDecl_.listIterator(); i.hasNext();) |
426 | { |
427 | if(i.next() == oldChild) |
428 | { |
429 | if(newChild != null) |
430 | { |
431 | i.set(newChild); |
432 | oldChild.parent(null); |
433 | return; |
434 | } |
435 | |
436 | i.remove(); |
437 | oldChild.parent(null); |
438 | return; |
439 | } |
440 | } |
441 | |
442 | if(_constructorDecl_ == oldChild) |
443 | { |
444 | setConstructorDecl((PConstructorDecl) newChild); |
445 | return; |
446 | } |
447 | |
448 | for(ListIterator i = _methodDecl_.listIterator(); i.hasNext();) |
449 | { |
450 | if(i.next() == oldChild) |
451 | { |
452 | if(newChild != null) |
453 | { |
454 | i.set(newChild); |
455 | oldChild.parent(null); |
456 | return; |
457 | } |
458 | |
459 | i.remove(); |
460 | oldChild.parent(null); |
461 | return; |
462 | } |
463 | } |
464 | |
465 | if(_rBrace_ == oldChild) |
466 | { |
467 | setRBrace((TRBrace) newChild); |
468 | return; |
469 | } |
470 | |
471 | } |
472 | |
473 | private class FieldDecl_Cast implements Cast |
474 | { |
475 | public Object cast(Object o) |
476 | { |
477 | PFieldDecl node = (PFieldDecl) o; |
478 | |
479 | if((node.parent() != null) && |
480 | (node.parent() != AClassDecl.this)) |
481 | { |
482 | node.parent().removeChild(node); |
483 | } |
484 | |
485 | if((node.parent() == null) || |
486 | (node.parent() != AClassDecl.this)) |
487 | { |
488 | node.parent(AClassDecl.this); |
489 | } |
490 | |
491 | return node; |
492 | } |
493 | } |
494 | |
495 | private class MethodDecl_Cast implements Cast |
496 | { |
497 | public Object cast(Object o) |
498 | { |
499 | PMethodDecl node = (PMethodDecl) o; |
500 | |
501 | if((node.parent() != null) && |
502 | (node.parent() != AClassDecl.this)) |
503 | { |
504 | node.parent().removeChild(node); |
505 | } |
506 | |
507 | if((node.parent() == null) || |
508 | (node.parent() != AClassDecl.this)) |
509 | { |
510 | node.parent(AClassDecl.this); |
511 | } |
512 | |
513 | return node; |
514 | } |
515 | } |
516 | } |