KickJava   Java API By Example, From Geeks To Geeks.

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


1 package polyglot.ext.jl.ast;
2
3 import polyglot.ast.*;
4
5 import polyglot.util.*;
6 import polyglot.types.*;
7 import polyglot.visit.*;
8
9 /**
10  * A <code>TypeNode</code> is the syntactic representation of a
11  * <code>Type</code> within the abstract syntax tree.
12  */

13 public abstract class TypeNode_c extends Node_c implements TypeNode
14 {
15     protected Type type;
16
17     public TypeNode_c(Position pos) {
18     super(pos);
19     }
20
21     /** Get the type as a qualifier. */
22     public Qualifier qualifier() {
23         return type();
24     }
25
26     /** Get the type this node encapsulates. */
27     public Type type() {
28     return this.type;
29     }
30
31     /** Set the type this node encapsulates. */
32     public TypeNode type(Type type) {
33     TypeNode_c n = (TypeNode_c) copy();
34     n.type = type;
35     return n;
36     }
37
38     public Node buildTypes(TypeBuilder tb) throws SemanticException {
39         if (type == null) {
40             TypeSystem ts = tb.typeSystem();
41             return type(ts.unknownType(position()));
42         }
43         else {
44             return this;
45         }
46     }
47
48     public String JavaDoc toString() {
49     if (type != null) {
50         return type.toString();
51     }
52     else {
53         return "<unknown type>";
54     }
55     }
56
57     public abstract void prettyPrint(CodeWriter w, PrettyPrinter tr);
58 }
59
Popular Tags