get rid of the stream parsing that occurs in the Layer III decoder. BitStream.readFra...
[IRC.git] / Robust / src / IR / FieldDescriptor.java
1 package IR;
2 import IR.Tree.Modifiers;
3 import IR.Tree.ExpressionNode;
4
5 /**
6  * Descriptor
7  *
8  * represents a symbol in the language (var name, function name, etc).
9  */
10
11 public class FieldDescriptor extends Descriptor {
12
13   public static FieldDescriptor arrayLength=new FieldDescriptor(new Modifiers(Modifiers.PUBLIC|Modifiers.FINAL), new TypeDescriptor(TypeDescriptor.INT), "length", null, false);
14
15   protected Modifiers modifier;
16   protected TypeDescriptor td;
17   protected String identifier;
18   protected ExpressionNode en;
19   private boolean isglobal;
20   private boolean isenum;
21   private int enumvalue;
22
23   private ClassDescriptor cn;
24
25   public FieldDescriptor(Modifiers m, TypeDescriptor t, String identifier, ExpressionNode e, boolean isglobal) {
26     super(identifier);
27     this.modifier=m;
28     this.td=t;
29     this.en=e;
30     this.safename = "___" + name + "___";
31     this.uniqueid=count++;
32     this.isglobal=isglobal;
33     this.isenum = false;
34     this.enumvalue = -1;
35   }
36
37   public ClassDescriptor getClassDescriptor() {
38     return this.cn;
39   }
40
41   public void setClassDescriptor(ClassDescriptor cn) {
42     this.cn = cn;
43   }
44
45   public String getSafeSymbol() {
46     if (isStatic()) {
47       return cn.getSafeSymbol()+safename;
48     } else
49       return safename;
50   }
51
52   public boolean isEnum() {
53     return this.isenum;
54   }
55
56   public int enumValue() {
57     return this.enumvalue;
58   }
59
60   public void setAsEnum() {
61     this.isenum = true;
62   }
63
64   public void setEnumValue(int value) {
65     this.enumvalue = value;
66   }
67
68   public ExpressionNode getExpressionNode() {
69     return en;
70   }
71
72   public boolean isFinal() {
73     return modifier.isFinal();
74   }
75
76   public boolean isStatic() {
77     return modifier.isStatic();
78   }
79
80   public boolean isVolatile() {
81     return modifier.isVolatile();
82   }
83
84   public boolean isGlobal() {
85     return isglobal;
86   }
87
88   public TypeDescriptor getType() {
89     return td;
90   }
91
92   public void changeSafeSymbol(int id) {
93     safename+=id;
94   }
95
96   public String toString() {
97     if (en==null)
98       return modifier.toString()+td.toString()+" "+getSymbol()+";";
99     else
100       return modifier.toString()+td.toString()+" "+getSymbol()+"="+en.printNode(0)+";";
101   }
102
103   public String toStringBrief() {
104     return td.toPrettyString()+" "+getSymbol();
105   }
106
107   public String toPrettyStringBrief() {
108     return td.toPrettyString()+" "+getSymbol();
109   }
110 }