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 AProg extends PProg |
9 | { |
10 | private final LinkedList _classDecl_ = new TypedLinkedList(new ClassDecl_Cast()); |
11 | |
12 | public AProg() |
13 | { |
14 | } |
15 | |
16 | public AProg( |
17 | List _classDecl_) |
18 | { |
19 | { |
20 | this._classDecl_.clear(); |
21 | this._classDecl_.addAll(_classDecl_); |
22 | } |
23 | |
24 | } |
25 | |
26 | public AProg( |
27 | XPClassDecl _classDecl_) |
28 | { |
29 | if(_classDecl_ != null) |
30 | { |
31 | while(_classDecl_ instanceof X1PClassDecl) |
32 | { |
33 | this._classDecl_.addFirst(((X1PClassDecl) _classDecl_).getPClassDecl()); |
34 | _classDecl_ = ((X1PClassDecl) _classDecl_).getXPClassDecl(); |
35 | } |
36 | this._classDecl_.addFirst(((X2PClassDecl) _classDecl_).getPClassDecl()); |
37 | } |
38 | |
39 | } |
40 | public Object clone() |
41 | { |
42 | return new AProg( |
43 | cloneList(_classDecl_)); |
44 | } |
45 | |
46 | public void apply(Switch sw) |
47 | { |
48 | ((Analysis) sw).caseAProg(this); |
49 | } |
50 | |
51 | public LinkedList getClassDecl() |
52 | { |
53 | return _classDecl_; |
54 | } |
55 | |
56 | public void setClassDecl(List list) |
57 | { |
58 | _classDecl_.clear(); |
59 | _classDecl_.addAll(list); |
60 | } |
61 | |
62 | public String toString() |
63 | { |
64 | return "" |
65 | + toString(_classDecl_); |
66 | } |
67 | |
68 | void removeChild(Node child) |
69 | { |
70 | if(_classDecl_.remove(child)) |
71 | { |
72 | return; |
73 | } |
74 | |
75 | } |
76 | |
77 | void replaceChild(Node oldChild, Node newChild) |
78 | { |
79 | for(ListIterator i = _classDecl_.listIterator(); i.hasNext();) |
80 | { |
81 | if(i.next() == oldChild) |
82 | { |
83 | if(newChild != null) |
84 | { |
85 | i.set(newChild); |
86 | oldChild.parent(null); |
87 | return; |
88 | } |
89 | |
90 | i.remove(); |
91 | oldChild.parent(null); |
92 | return; |
93 | } |
94 | } |
95 | |
96 | } |
97 | |
98 | private class ClassDecl_Cast implements Cast |
99 | { |
100 | public Object cast(Object o) |
101 | { |
102 | PClassDecl node = (PClassDecl) o; |
103 | |
104 | if((node.parent() != null) && |
105 | (node.parent() != AProg.this)) |
106 | { |
107 | node.parent().removeChild(node); |
108 | } |
109 | |
110 | if((node.parent() == null) || |
111 | (node.parent() != AProg.this)) |
112 | { |
113 | node.parent(AProg.this); |
114 | } |
115 | |
116 | return node; |
117 | } |
118 | } |
119 | } |