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;
23 private ClassDescriptor cn;
25 public FieldDescriptor(Modifiers m, TypeDescriptor t, String identifier, ExpressionNode e, boolean isglobal) {
30 this.safename = "___" + name + "___";
31 this.uniqueid=count++;
32 this.isglobal=isglobal;
37 public ClassDescriptor getClassDescriptor() {
41 public void setClassDescriptor(ClassDescriptor cn) {
45 public boolean isEnum() {
49 public int enumValue() {
50 return this.enumvalue;
53 public void setAsEnum() {
57 public void setEnumValue(int value) {
58 this.enumvalue = value;
61 public ExpressionNode getExpressionNode(){
65 public boolean isFinal() {
66 return modifier.isFinal();
69 public boolean isStatic() {
70 return modifier.isStatic();
73 public boolean isVolatile() {
74 return modifier.isVolatile();
77 public boolean isGlobal() {
81 public TypeDescriptor getType() {
85 public String toString() {
87 return modifier.toString()+td.toString()+" "+getSymbol()+";";
89 return modifier.toString()+td.toString()+" "+getSymbol()+"="+en.printNode(0)+";";
92 public String toStringBrief() {
93 return td.toString()+" "+getSymbol();
96 public String toPrettyStringBrief() {
97 return td.toPrettyString()+" "+getSymbol();