KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > ext > jl > types > VarInstance_c


1 package polyglot.ext.jl.types;
2
3 import polyglot.types.*;
4 import polyglot.util.*;
5
6 /**
7  * A <code>VarInstance</code> contains type information for a variable. It may
8  * be either a local or a field.
9  */

10 public abstract class VarInstance_c extends TypeObject_c implements VarInstance
11 {
12     protected Flags flags;
13     protected Type type;
14     protected String JavaDoc name;
15     protected Object JavaDoc constantValue;
16     protected boolean isConstant;
17
18     /** Used for deserializing types. */
19     protected VarInstance_c() { }
20
21     public VarInstance_c(TypeSystem ts, Position pos,
22                      Flags flags, Type type, String JavaDoc name) {
23         super(ts, pos);
24     this.flags = flags;
25     this.type = type;
26     this.name = name;
27     }
28
29     public boolean isConstant() {
30         return isConstant;
31     }
32
33     public Object JavaDoc constantValue() {
34         return constantValue;
35     }
36
37     public Flags flags() {
38         return flags;
39     }
40
41     public Type type() {
42         return type;
43     }
44
45     public String JavaDoc name() {
46         return name;
47     }
48
49     public int hashCode() {
50         return flags.hashCode() + name.hashCode();
51     }
52
53     public boolean equalsImpl(TypeObject o) {
54         if (o instanceof VarInstance) {
55         VarInstance i = (VarInstance) o;
56         return flags.equals(i.flags())
57             && ts.equals(type, i.type())
58         && name.equals(i.name());
59     }
60
61     return false;
62     }
63
64     public boolean isCanonical() {
65     return true;
66     }
67
68     public void setType(Type type) {
69         this.type = type;
70     }
71
72     public void setFlags(Flags flags) {
73         this.flags = flags;
74     }
75 }
76
Popular Tags