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 AConstructorDecl extends PConstructorDecl |
9 | { |
10 | private TIdentifier _identifier_; |
11 | private TLPar _l1_; |
12 | private PParamDeclList _paramDeclList_; |
13 | private TRPar _r1_; |
14 | private TLBrace _lBrace_; |
15 | private TSuper _super_; |
16 | private TLPar _l2_; |
17 | private PFieldList _fieldList_; |
18 | private TRPar _r2_; |
19 | private TSemicolon _semicolon_; |
20 | private final LinkedList _thisFieldAssig_ = new TypedLinkedList(new ThisFieldAssig_Cast()); |
21 | private TRBrace _rBrace_; |
22 | |
23 | public AConstructorDecl() |
24 | { |
25 | } |
26 | |
27 | public AConstructorDecl( |
28 | TIdentifier _identifier_, |
29 | TLPar _l1_, |
30 | PParamDeclList _paramDeclList_, |
31 | TRPar _r1_, |
32 | TLBrace _lBrace_, |
33 | TSuper _super_, |
34 | TLPar _l2_, |
35 | PFieldList _fieldList_, |
36 | TRPar _r2_, |
37 | TSemicolon _semicolon_, |
38 | List _thisFieldAssig_, |
39 | TRBrace _rBrace_) |
40 | { |
41 | setIdentifier(_identifier_); |
42 | |
43 | setL1(_l1_); |
44 | |
45 | setParamDeclList(_paramDeclList_); |
46 | |
47 | setR1(_r1_); |
48 | |
49 | setLBrace(_lBrace_); |
50 | |
51 | setSuper(_super_); |
52 | |
53 | setL2(_l2_); |
54 | |
55 | setFieldList(_fieldList_); |
56 | |
57 | setR2(_r2_); |
58 | |
59 | setSemicolon(_semicolon_); |
60 | |
61 | { |
62 | this._thisFieldAssig_.clear(); |
63 | this._thisFieldAssig_.addAll(_thisFieldAssig_); |
64 | } |
65 | |
66 | setRBrace(_rBrace_); |
67 | |
68 | } |
69 | |
70 | public AConstructorDecl( |
71 | TIdentifier _identifier_, |
72 | TLPar _l1_, |
73 | PParamDeclList _paramDeclList_, |
74 | TRPar _r1_, |
75 | TLBrace _lBrace_, |
76 | TSuper _super_, |
77 | TLPar _l2_, |
78 | PFieldList _fieldList_, |
79 | TRPar _r2_, |
80 | TSemicolon _semicolon_, |
81 | XPThisFieldAssig _thisFieldAssig_, |
82 | TRBrace _rBrace_) |
83 | { |
84 | setIdentifier(_identifier_); |
85 | |
86 | setL1(_l1_); |
87 | |
88 | setParamDeclList(_paramDeclList_); |
89 | |
90 | setR1(_r1_); |
91 | |
92 | setLBrace(_lBrace_); |
93 | |
94 | setSuper(_super_); |
95 | |
96 | setL2(_l2_); |
97 | |
98 | setFieldList(_fieldList_); |
99 | |
100 | setR2(_r2_); |
101 | |
102 | setSemicolon(_semicolon_); |
103 | |
104 | if(_thisFieldAssig_ != null) |
105 | { |
106 | while(_thisFieldAssig_ instanceof X1PThisFieldAssig) |
107 | { |
108 | this._thisFieldAssig_.addFirst(((X1PThisFieldAssig) _thisFieldAssig_).getPThisFieldAssig()); |
109 | _thisFieldAssig_ = ((X1PThisFieldAssig) _thisFieldAssig_).getXPThisFieldAssig(); |
110 | } |
111 | this._thisFieldAssig_.addFirst(((X2PThisFieldAssig) _thisFieldAssig_).getPThisFieldAssig()); |
112 | } |
113 | |
114 | setRBrace(_rBrace_); |
115 | |
116 | } |
117 | public Object clone() |
118 | { |
119 | return new AConstructorDecl( |
120 | (TIdentifier) cloneNode(_identifier_), |
121 | (TLPar) cloneNode(_l1_), |
122 | (PParamDeclList) cloneNode(_paramDeclList_), |
123 | (TRPar) cloneNode(_r1_), |
124 | (TLBrace) cloneNode(_lBrace_), |
125 | (TSuper) cloneNode(_super_), |
126 | (TLPar) cloneNode(_l2_), |
127 | (PFieldList) cloneNode(_fieldList_), |
128 | (TRPar) cloneNode(_r2_), |
129 | (TSemicolon) cloneNode(_semicolon_), |
130 | cloneList(_thisFieldAssig_), |
131 | (TRBrace) cloneNode(_rBrace_)); |
132 | } |
133 | |
134 | public void apply(Switch sw) |
135 | { |
136 | ((Analysis) sw).caseAConstructorDecl(this); |
137 | } |
138 | |
139 | public TIdentifier getIdentifier() |
140 | { |
141 | return _identifier_; |
142 | } |
143 | |
144 | public void setIdentifier(TIdentifier node) |
145 | { |
146 | if(_identifier_ != null) |
147 | { |
148 | _identifier_.parent(null); |
149 | } |
150 | |
151 | if(node != null) |
152 | { |
153 | if(node.parent() != null) |
154 | { |
155 | node.parent().removeChild(node); |
156 | } |
157 | |
158 | node.parent(this); |
159 | } |
160 | |
161 | _identifier_ = node; |
162 | } |
163 | |
164 | public TLPar getL1() |
165 | { |
166 | return _l1_; |
167 | } |
168 | |
169 | public void setL1(TLPar node) |
170 | { |
171 | if(_l1_ != null) |
172 | { |
173 | _l1_.parent(null); |
174 | } |
175 | |
176 | if(node != null) |
177 | { |
178 | if(node.parent() != null) |
179 | { |
180 | node.parent().removeChild(node); |
181 | } |
182 | |
183 | node.parent(this); |
184 | } |
185 | |
186 | _l1_ = node; |
187 | } |
188 | |
189 | public PParamDeclList getParamDeclList() |
190 | { |
191 | return _paramDeclList_; |
192 | } |
193 | |
194 | public void setParamDeclList(PParamDeclList node) |
195 | { |
196 | if(_paramDeclList_ != null) |
197 | { |
198 | _paramDeclList_.parent(null); |
199 | } |
200 | |
201 | if(node != null) |
202 | { |
203 | if(node.parent() != null) |
204 | { |
205 | node.parent().removeChild(node); |
206 | } |
207 | |
208 | node.parent(this); |
209 | } |
210 | |
211 | _paramDeclList_ = node; |
212 | } |
213 | |
214 | public TRPar getR1() |
215 | { |
216 | return _r1_; |
217 | } |
218 | |
219 | public void setR1(TRPar node) |
220 | { |
221 | if(_r1_ != null) |
222 | { |
223 | _r1_.parent(null); |
224 | } |
225 | |
226 | if(node != null) |
227 | { |
228 | if(node.parent() != null) |
229 | { |
230 | node.parent().removeChild(node); |
231 | } |
232 | |
233 | node.parent(this); |
234 | } |
235 | |
236 | _r1_ = node; |
237 | } |
238 | |
239 | public TLBrace getLBrace() |
240 | { |
241 | return _lBrace_; |
242 | } |
243 | |
244 | public void setLBrace(TLBrace node) |
245 | { |
246 | if(_lBrace_ != null) |
247 | { |
248 | _lBrace_.parent(null); |
249 | } |
250 | |
251 | if(node != null) |
252 | { |
253 | if(node.parent() != null) |
254 | { |
255 | node.parent().removeChild(node); |
256 | } |
257 | |
258 | node.parent(this); |
259 | } |
260 | |
261 | _lBrace_ = node; |
262 | } |
263 | |
264 | public TSuper getSuper() |
265 | { |
266 | return _super_; |
267 | } |
268 | |
269 | public void setSuper(TSuper node) |
270 | { |
271 | if(_super_ != null) |
272 | { |
273 | _super_.parent(null); |
274 | } |
275 | |
276 | if(node != null) |
277 | { |
278 | if(node.parent() != null) |
279 | { |
280 | node.parent().removeChild(node); |
281 | } |
282 | |
283 | node.parent(this); |
284 | } |
285 | |
286 | _super_ = node; |
287 | } |
288 | |
289 | public TLPar getL2() |
290 | { |
291 | return _l2_; |
292 | } |
293 | |
294 | public void setL2(TLPar node) |
295 | { |
296 | if(_l2_ != null) |
297 | { |
298 | _l2_.parent(null); |
299 | } |
300 | |
301 | if(node != null) |
302 | { |
303 | if(node.parent() != null) |
304 | { |
305 | node.parent().removeChild(node); |
306 | } |
307 | |
308 | node.parent(this); |
309 | } |
310 | |
311 | _l2_ = node; |
312 | } |
313 | |
314 | public PFieldList getFieldList() |
315 | { |
316 | return _fieldList_; |
317 | } |
318 | |
319 | public void setFieldList(PFieldList node) |
320 | { |
321 | if(_fieldList_ != null) |
322 | { |
323 | _fieldList_.parent(null); |
324 | } |
325 | |
326 | if(node != null) |
327 | { |
328 | if(node.parent() != null) |
329 | { |
330 | node.parent().removeChild(node); |
331 | } |
332 | |
333 | node.parent(this); |
334 | } |
335 | |
336 | _fieldList_ = node; |
337 | } |
338 | |
339 | public TRPar getR2() |
340 | { |
341 | return _r2_; |
342 | } |
343 | |
344 | public void setR2(TRPar node) |
345 | { |
346 | if(_r2_ != null) |
347 | { |
348 | _r2_.parent(null); |
349 | } |
350 | |
351 | if(node != null) |
352 | { |
353 | if(node.parent() != null) |
354 | { |
355 | node.parent().removeChild(node); |
356 | } |
357 | |
358 | node.parent(this); |
359 | } |
360 | |
361 | _r2_ = node; |
362 | } |
363 | |
364 | public TSemicolon getSemicolon() |
365 | { |
366 | return _semicolon_; |
367 | } |
368 | |
369 | public void setSemicolon(TSemicolon node) |
370 | { |
371 | if(_semicolon_ != null) |
372 | { |
373 | _semicolon_.parent(null); |
374 | } |
375 | |
376 | if(node != null) |
377 | { |
378 | if(node.parent() != null) |
379 | { |
380 | node.parent().removeChild(node); |
381 | } |
382 | |
383 | node.parent(this); |
384 | } |
385 | |
386 | _semicolon_ = node; |
387 | } |
388 | |
389 | public LinkedList getThisFieldAssig() |
390 | { |
391 | return _thisFieldAssig_; |
392 | } |
393 | |
394 | public void setThisFieldAssig(List list) |
395 | { |
396 | _thisFieldAssig_.clear(); |
397 | _thisFieldAssig_.addAll(list); |
398 | } |
399 | |
400 | public TRBrace getRBrace() |
401 | { |
402 | return _rBrace_; |
403 | } |
404 | |
405 | public void setRBrace(TRBrace node) |
406 | { |
407 | if(_rBrace_ != null) |
408 | { |
409 | _rBrace_.parent(null); |
410 | } |
411 | |
412 | if(node != null) |
413 | { |
414 | if(node.parent() != null) |
415 | { |
416 | node.parent().removeChild(node); |
417 | } |
418 | |
419 | node.parent(this); |
420 | } |
421 | |
422 | _rBrace_ = node; |
423 | } |
424 | |
425 | public String toString() |
426 | { |
427 | return "" |
428 | + toString(_identifier_) |
429 | + toString(_l1_) |
430 | + toString(_paramDeclList_) |
431 | + toString(_r1_) |
432 | + toString(_lBrace_) |
433 | + toString(_super_) |
434 | + toString(_l2_) |
435 | + toString(_fieldList_) |
436 | + toString(_r2_) |
437 | + toString(_semicolon_) |
438 | + toString(_thisFieldAssig_) |
439 | + toString(_rBrace_); |
440 | } |
441 | |
442 | void removeChild(Node child) |
443 | { |
444 | if(_identifier_ == child) |
445 | { |
446 | _identifier_ = null; |
447 | return; |
448 | } |
449 | |
450 | if(_l1_ == child) |
451 | { |
452 | _l1_ = null; |
453 | return; |
454 | } |
455 | |
456 | if(_paramDeclList_ == child) |
457 | { |
458 | _paramDeclList_ = null; |
459 | return; |
460 | } |
461 | |
462 | if(_r1_ == child) |
463 | { |
464 | _r1_ = null; |
465 | return; |
466 | } |
467 | |
468 | if(_lBrace_ == child) |
469 | { |
470 | _lBrace_ = null; |
471 | return; |
472 | } |
473 | |
474 | if(_super_ == child) |
475 | { |
476 | _super_ = null; |
477 | return; |
478 | } |
479 | |
480 | if(_l2_ == child) |
481 | { |
482 | _l2_ = null; |
483 | return; |
484 | } |
485 | |
486 | if(_fieldList_ == child) |
487 | { |
488 | _fieldList_ = null; |
489 | return; |
490 | } |
491 | |
492 | if(_r2_ == child) |
493 | { |
494 | _r2_ = null; |
495 | return; |
496 | } |
497 | |
498 | if(_semicolon_ == child) |
499 | { |
500 | _semicolon_ = null; |
501 | return; |
502 | } |
503 | |
504 | if(_thisFieldAssig_.remove(child)) |
505 | { |
506 | return; |
507 | } |
508 | |
509 | if(_rBrace_ == child) |
510 | { |
511 | _rBrace_ = null; |
512 | return; |
513 | } |
514 | |
515 | } |
516 | |
517 | void replaceChild(Node oldChild, Node newChild) |
518 | { |
519 | if(_identifier_ == oldChild) |
520 | { |
521 | setIdentifier((TIdentifier) newChild); |
522 | return; |
523 | } |
524 | |
525 | if(_l1_ == oldChild) |
526 | { |
527 | setL1((TLPar) newChild); |
528 | return; |
529 | } |
530 | |
531 | if(_paramDeclList_ == oldChild) |
532 | { |
533 | setParamDeclList((PParamDeclList) newChild); |
534 | return; |
535 | } |
536 | |
537 | if(_r1_ == oldChild) |
538 | { |
539 | setR1((TRPar) newChild); |
540 | return; |
541 | } |
542 | |
543 | if(_lBrace_ == oldChild) |
544 | { |
545 | setLBrace((TLBrace) newChild); |
546 | return; |
547 | } |
548 | |
549 | if(_super_ == oldChild) |
550 | { |
551 | setSuper((TSuper) newChild); |
552 | return; |
553 | } |
554 | |
555 | if(_l2_ == oldChild) |
556 | { |
557 | setL2((TLPar) newChild); |
558 | return; |
559 | } |
560 | |
561 | if(_fieldList_ == oldChild) |
562 | { |
563 | setFieldList((PFieldList) newChild); |
564 | return; |
565 | } |
566 | |
567 | if(_r2_ == oldChild) |
568 | { |
569 | setR2((TRPar) newChild); |
570 | return; |
571 | } |
572 | |
573 | if(_semicolon_ == oldChild) |
574 | { |
575 | setSemicolon((TSemicolon) newChild); |
576 | return; |
577 | } |
578 | |
579 | for(ListIterator i = _thisFieldAssig_.listIterator(); i.hasNext();) |
580 | { |
581 | if(i.next() == oldChild) |
582 | { |
583 | if(newChild != null) |
584 | { |
585 | i.set(newChild); |
586 | oldChild.parent(null); |
587 | return; |
588 | } |
589 | |
590 | i.remove(); |
591 | oldChild.parent(null); |
592 | return; |
593 | } |
594 | } |
595 | |
596 | if(_rBrace_ == oldChild) |
597 | { |
598 | setRBrace((TRBrace) newChild); |
599 | return; |
600 | } |
601 | |
602 | } |
603 | |
604 | private class ThisFieldAssig_Cast implements Cast |
605 | { |
606 | public Object cast(Object o) |
607 | { |
608 | PThisFieldAssig node = (PThisFieldAssig) o; |
609 | |
610 | if((node.parent() != null) && |
611 | (node.parent() != AConstructorDecl.this)) |
612 | { |
613 | node.parent().removeChild(node); |
614 | } |
615 | |
616 | if((node.parent() == null) || |
617 | (node.parent() != AConstructorDecl.this)) |
618 | { |
619 | node.parent(AConstructorDecl.this); |
620 | } |
621 | |
622 | return node; |
623 | } |
624 | } |
625 | } |