Fixed lots of bugs with increment operations and +=/etc...
[IRC.git] / Robust / src / IR / FieldDescriptor.java
1 package IR;
2 import IR.Tree.Modifiers;
3 import IR.Tree.ExpressionNode;
4
5 /**
6  * Descriptor 
7  *
8  * represents a symbol in the language (var name, function name, etc).
9  */
10
11 public class FieldDescriptor extends Descriptor {
12
13     public static FieldDescriptor arrayLength=new FieldDescriptor(new Modifiers(Modifiers.PUBLIC|Modifiers.FINAL), new TypeDescriptor(TypeDescriptor.INT), "length", null);
14
15     protected Modifiers modifier;
16     protected TypeDescriptor td;
17     protected String identifier;
18     protected ExpressionNode en;
19     
20     public FieldDescriptor(Modifiers m, TypeDescriptor t, String identifier, ExpressionNode e) {
21         super(identifier);
22         this.modifier=m;
23         this.td=t;
24         this.en=e;
25         this.safename = "___" + name + "___";
26         this.uniqueid=count++;
27         if (en!=null) throw new Error("Field initializers not implemented");
28     }
29
30     public TypeDescriptor getType() {
31         return td;
32     }
33
34     public String toString() {
35         if (en==null)
36             return modifier.toString()+td.toString()+" "+getSymbol()+";";
37         else
38             return modifier.toString()+td.toString()+" "+getSymbol()+"="+en.printNode(0)+";";
39     }
40 }