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 String getSafeSymbol() {
47 return cn.getSafeSymbol()+safename;
52 public boolean isEnum() {
56 public int enumValue() {
57 return this.enumvalue;
60 public void setAsEnum() {
64 public void setEnumValue(int value) {
65 this.enumvalue = value;
68 public ExpressionNode getExpressionNode(){
72 public boolean isFinal() {
73 return modifier.isFinal();
76 public boolean isStatic() {
77 return modifier.isStatic();
80 public boolean isVolatile() {
81 return modifier.isVolatile();
84 public boolean isGlobal() {
88 public TypeDescriptor getType() {
92 public void changeSafeSymbol(int id) {
96 public String toString() {
98 return modifier.toString()+td.toString()+" "+getSymbol()+";";
100 return modifier.toString()+td.toString()+" "+getSymbol()+"="+en.printNode(0)+";";
103 public String toStringBrief() {
104 return td.toPrettyString()+" "+getSymbol();
107 public String toPrettyStringBrief() {
108 return td.toPrettyString()+" "+getSymbol();