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 public FieldDescriptor(Modifiers m, TypeDescriptor t, String identifier, ExpressionNode e, boolean isglobal) {
28 this.safename = "___" + name + "___";
29 this.uniqueid=count++;
30 this.isglobal=isglobal;
35 public boolean isEnum() {
39 public int enumValue() {
40 return this.enumvalue;
43 public void setAsEnum() {
47 public void setEnumValue(int value) {
48 this.enumvalue = value;
51 public ExpressionNode getExpressionNode(){
55 public boolean isFinal() {
56 return modifier.isFinal();
59 public boolean isStatic() {
60 return modifier.isStatic();
63 public boolean isVolatile() {
64 return modifier.isVolatile();
67 public boolean isGlobal() {
71 public TypeDescriptor getType() {
75 public String toString() {
77 return modifier.toString()+td.toString()+" "+getSymbol()+";";
79 return modifier.toString()+td.toString()+" "+getSymbol()+"="+en.printNode(0)+";";
82 public String toStringBrief() {
83 return td.toString()+" "+getSymbol();
86 public String toPrettyStringBrief() {
87 return td.toPrettyString()+" "+getSymbol();