2 import IR.Tree.Modifiers;
3 import IR.Tree.ExpressionNode;
8 * represents a symbol in the language (var name, function name, etc).
11 public class FieldDescriptor extends Descriptor {
13 public static FieldDescriptor arrayLength=new FieldDescriptor(new Modifiers(Modifiers.PUBLIC|Modifiers.FINAL), new TypeDescriptor(TypeDescriptor.INT), "length", null, false);
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 private boolean isEnumClass;
24 private ClassDescriptor cn;
26 public FieldDescriptor(Modifiers m, TypeDescriptor t, String identifier, ExpressionNode e, boolean isglobal) {
31 this.safename = "___" + name + "___";
32 this.uniqueid=count++;
33 this.isglobal=isglobal;
36 this.isEnumClass = false;
39 public ClassDescriptor getClassDescriptor() {
43 public void setClassDescriptor(ClassDescriptor cn) {
47 public String getSafeSymbol() {
49 return cn.getSafeSymbol()+safename;
54 public boolean isEnum() {
58 public int enumValue() {
59 return this.enumvalue;
62 public void setAsEnum() {
66 public void setEnumValue(int value) {
67 this.enumvalue = value;
70 public ExpressionNode getExpressionNode() {
74 public boolean isFinal() {
75 return modifier.isFinal();
78 public boolean isStatic() {
79 return modifier.isStatic();
82 public boolean isVolatile() {
83 return modifier.isVolatile();
86 public boolean isGlobal() {
90 public TypeDescriptor getType() {
94 public void changeSafeSymbol(int id) {
98 public String toString() {
100 return modifier.toString()+td.toString()+" "+getSymbol()+";";
102 return modifier.toString()+td.toString()+" "+getSymbol()+"="+en.printNode(0)+";";
105 public String toStringBrief() {
106 return td.toPrettyString()+" "+getSymbol();
109 public String toPrettyStringBrief() {
110 return td.toPrettyString()+" "+getSymbol();
113 public void setIsEnumClass() {
114 this.isEnumClass = true;
117 public boolean isEnumClass() {
118 return this.isEnumClass;