KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > ext > jl > ast > JL_c


1 package polyglot.ext.jl.ast;
2
3 import java.util.Collections JavaDoc;
4 import java.util.List JavaDoc;
5
6 import polyglot.ast.*;
7 import polyglot.types.*;
8 import polyglot.visit.*;
9 import polyglot.util.*;
10
11 /**
12  * <code>JL_c</code> is the super class of JL node delegates objects.
13  * It defines default implementations of the methods which implement compiler
14  * passes, dispatching to the node to perform the actual work of the pass.
15  * Language extensions may subclass <code>JL_c</code> for individual node
16  * classes or may reimplement all compiler passes in a new class implementing
17  * the <code>JL</code> interface.
18  */

19 public class JL_c extends Ext_c implements JL {
20     public JL_c() {
21     }
22
23     /** The <code>JL</code> object we dispatch to, by default, the node
24      * itself, but possibly another delegate.
25      */

26     public JL jl() {
27         return node();
28     }
29
30     /**
31      * Visit the children of the node.
32      *
33      * @param v The visitor that will traverse/rewrite the AST.
34      * @return A new AST if a change was made, or <code>this</code>.
35      */

36     public Node visitChildren(NodeVisitor v) {
37         return jl().visitChildren(v);
38     }
39
40     /**
41      * Push a new scope upon entering this node, and add any declarations to the
42      * context that should be in scope when visiting children of this node.
43      * This should <i>not</i> update the old context
44      * imperatively. Use <code>addDecls</code> when leaving the node
45      * for that.
46      *
47      * @param c the current <code>Context</code>
48      * @return the <code>Context</code> to be used for visiting this node.
49      */

50     public Context enterScope(Context c) {
51         return jl().enterScope(c);
52     }
53
54     /**
55      * Push a new scope for visiting the child node <code>child</code>.
56      * The default behavior is to delegate the call to the child node, and let
57      * it add appropriate declarations that should be in scope. However,
58      * this method gives parent nodes have the ability to modify this behavior.
59      *
60      * @param child the child node about to be entered.
61      * @param c the current <code>Context</code>
62      * @return the <code>Context</code> to be used for visiting node
63      * <code>child</code>
64      */

65     public Context enterScope(Node child, Context c) {
66         return jl().enterScope(child, c);
67     }
68
69     /**
70      * Add any declarations to the context that should be in scope when
71      * visiting later sibling nodes.
72      *
73      * @param c The context to which to add declarations.
74      */

75     public void addDecls(Context c) {
76         jl().addDecls(c);
77     }
78
79     /**
80      * Collects classes, methods, and fields from the AST rooted at this node
81      * and constructs type objects for these. These type objects may be
82      * ambiguous. Inserts classes into the <code>TypeSystem</code>.
83      *
84      * This method is called by the <code>enter()</code> method of the
85      * visitor. The * method should perform work that should be done
86      * before visiting the children of the node. The method may return
87      * <code>this</code> or a new copy of the node on which
88      * <code>visitChildren()</code> and <code>leave()</code> will be
89      * invoked.
90      *
91      * @param tb The visitor which adds new type objects to the
92      * <code>TypeSystem</code>.
93      */

94     public NodeVisitor buildTypesEnter(TypeBuilder tb) throws SemanticException {
95     return jl().buildTypesEnter(tb);
96     }
97
98     /**
99      * Collects classes, methods, and fields from the AST rooted at this node
100      * and constructs type objects for these. These type objects may be
101      * ambiguous. Inserts classes into the <code>TypeSystem</code>.
102      *
103      * This method is called by the <code>leave()</code> method of the
104      * visitor. The method should perform work that should be done
105      * after visiting the children of the node. The method may return
106      * <code>this</code> or a new copy of the node which will be
107      * installed as a child of the node's parent.
108      *
109      * @param tb The visitor which adds new type objects to the
110      * <code>TypeSystem</code>.
111      */

112     public Node buildTypes(TypeBuilder tb) throws SemanticException {
113     return jl().buildTypes(tb);
114     }
115
116     /**
117      * Remove any remaining ambiguities from the AST.
118      *
119      * This method is called by the <code>enter()</code> method of the
120      * visitor. The * method should perform work that should be done
121      * before visiting the children of the node. The method may return
122      * <code>this</code> or a new copy of the node on which
123      * <code>visitChildren()</code> and <code>leave()</code> will be
124      * invoked.
125      *
126      * @param ar The visitor which disambiguates.
127      */

128     public NodeVisitor disambiguateEnter(AmbiguityRemover ar) throws SemanticException {
129     return jl().disambiguateEnter(ar);
130     }
131
132     /**
133      * Remove any remaining ambiguities from the AST.
134      *
135      * This method is called by the <code>leave()</code> method of the
136      * visitor. The method should perform work that should be done
137      * after visiting the children of the node. The method may return
138      * <code>this</code> or a new copy of the node which will be
139      * installed as a child of the node's parent.
140      *
141      * @param ar The visitor which disambiguates.
142      */

143     public Node disambiguate(AmbiguityRemover ar) throws SemanticException {
144     return jl().disambiguate(ar);
145     }
146
147     /**
148      * Adds disambiguated methods and fields to the types.
149      *
150      * This method is called by the <code>enter()</code> method of the
151      * visitor. The * method should perform work that should be done
152      * before visiting the children of the node. The method may return
153      * <code>this</code> or a new copy of the node on which
154      * <code>visitChildren()</code> and <code>leave()</code> will be
155      * invoked.
156      *
157      * @param am The visitor which builds types.
158      */

159     public NodeVisitor addMembersEnter(AddMemberVisitor am) throws SemanticException {
160     return jl().addMembersEnter(am);
161     }
162
163     /**
164      * Adds disambiguated methods and fields to the types.
165      *
166      * This method is called by the <code>leave()</code> method of the
167      * visitor. The method should perform work that should be done
168      * after visiting the children of the node. The method may return
169      * <code>this</code> or a new copy of the node which will be
170      * installed as a child of the node's parent.
171      *
172      * @param am The visitor which builds types.
173      */

174     public Node addMembers(AddMemberVisitor am) throws SemanticException {
175     return jl().addMembers(am);
176     }
177
178     /**
179      * Type check the AST.
180      *
181      * This method is called by the <code>enter()</code> method of the
182      * visitor. The * method should perform work that should be done
183      * before visiting the children of the node. The method may return
184      * <code>this</code> or a new copy of the node on which
185      * <code>visitChildren()</code> and <code>leave()</code> will be
186      * invoked.
187      *
188      * @param tc The type checking visitor.
189      */

190     public NodeVisitor typeCheckEnter(TypeChecker tc) throws SemanticException {
191     return jl().typeCheckEnter(tc);
192     }
193
194     /**
195      * Type check the AST.
196      *
197      * This method is called by the <code>leave()</code> method of the
198      * visitor. The method should perform work that should be done
199      * after visiting the children of the node. The method may return
200      * <code>this</code> or a new copy of the node which will be
201      * installed as a child of the node's parent.
202      *
203      * @param tc The type checking visitor.
204      */

205     public Node typeCheck(TypeChecker tc) throws SemanticException {
206     return jl().typeCheck(tc);
207     }
208
209     /**
210      * Check that exceptions are properly propagated throughout the AST.
211      *
212      * This method is called by the <code>enter()</code> method of the
213      * visitor. The * method should perform work that should be done
214      * before visiting the children of the node. The method may return
215      * <code>this</code> or a new copy of the node on which
216      * <code>visitChildren()</code> and <code>leave()</code> will be
217      * invoked.
218      *
219      * @param ec The visitor.
220      */

221     public NodeVisitor exceptionCheckEnter(ExceptionChecker ec) throws SemanticException {
222     return jl().exceptionCheckEnter(ec);
223     }
224
225     /**
226      * Check that exceptions are properly propagated throughout the AST.
227      *
228      * This method is called by the <code>leave()</code> method of the
229      * visitor. The method should perform work that should be done
230      * after visiting the children of the node. The method may return
231      * <code>this</code> or a new copy of the node which will be
232      * installed as a child of the node's parent.
233      *
234      * @param ec The visitor.
235      */

236     public Node exceptionCheck(ExceptionChecker ec) throws SemanticException {
237     return jl().exceptionCheck(ec);
238     }
239
240     /**
241      * List of Types of exceptions that might get thrown. The result is
242      * not necessarily correct until after type checking.
243      */

244     public List JavaDoc throwTypes(TypeSystem ts) {
245        return jl().throwTypes(ts);
246     }
247
248     /**
249      * Pretty-print the AST using the given code writer.
250      *
251      * @param w The code writer to which to write.
252      * @param pp The pretty printer. This is <i>not</i> a visitor.
253      */

254     public void prettyPrint(CodeWriter w, PrettyPrinter pp) {
255         jl().prettyPrint(w, pp);
256     }
257
258     /**
259      * Translate the AST using the given code writer.
260      *
261      * @param w The code writer to which to write.
262      * @param tr The translation pass. This is <i>not</i> a visitor.
263      */

264     public void translate(CodeWriter w, Translator tr) {
265         jl().translate(w, tr);
266     }
267 }
268
Popular Tags