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;
25 private ClassDescriptor cn;
27 public FieldDescriptor(Modifiers m, TypeDescriptor t, String identifier, ExpressionNode e, boolean isglobal) {
32 this.safename = "___" + name + "___";
33 this.uniqueid=count++;
34 this.isglobal=isglobal;
37 this.isEnumClass = false;
40 public ClassDescriptor getClassDescriptor() {
44 public void setClassDescriptor(ClassDescriptor cn) {
48 public String getSafeSymbol() {
50 return cn.getSafeSymbol()+safename;
55 public boolean isEnum() {
59 public int enumValue() {
60 return this.enumvalue;
63 public void setAsEnum() {
67 public void setEnumValue(int value) {
68 this.enumvalue = value;
71 public ExpressionNode getExpressionNode() {
75 public boolean isFinal() {
76 return modifier.isFinal();
79 public boolean isStatic() {
80 return modifier.isStatic();
83 public boolean isVolatile() {
84 return modifier.isVolatile();
87 public boolean isGlobal() {
91 public TypeDescriptor getType() {
95 public void changeSafeSymbol(int id) {
99 public String toString() {
101 return modifier.toString()+td.toString()+" "+getSymbol()+";";
103 return modifier.toString()+td.toString()+" "+getSymbol()+"="+en.printNode(0)+";";
106 public String toStringBrief() {
107 return td.toPrettyString()+" "+getSymbol();
110 public String toPrettyStringBrief() {
111 return td.toPrettyString()+" "+getSymbol();
114 public void setIsEnumClass() {
115 this.isEnumClass = true;
118 public boolean isEnumClass() {
119 return this.isEnumClass;
122 public void setLineNum(int n){
126 public int getLineNum(){