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 isStatic() {
56 return modifier.isStatic();
59 public boolean isVolatile() {
60 return modifier.isVolatile();
63 public boolean isGlobal() {
67 public TypeDescriptor getType() {
71 public String toString() {
73 return modifier.toString()+td.toString()+" "+getSymbol()+";";
75 return modifier.toString()+td.toString()+" "+getSymbol()+"="+en.printNode(0)+";";
78 public String toStringBrief() {
79 return td.toString()+" "+getSymbol();
82 public String toPrettyStringBrief() {
83 return td.toPrettyString()+" "+getSymbol();