implemented PCLOC annotation.
[IRC.git] / Robust / src / IR / FieldDescriptor.java
index edfb8959db0276f9c780451ea6f7f350dba58c81..d2e50ac5342ece7e94ce0fba821742e65842bce0 100644 (file)
@@ -17,6 +17,11 @@ public class FieldDescriptor extends Descriptor {
   protected String identifier;
   protected ExpressionNode en;
   private boolean isglobal;
+  private boolean isenum;
+  private int enumvalue;
+  private boolean isEnumClass;
+
+  private ClassDescriptor cn;
 
   public FieldDescriptor(Modifiers m, TypeDescriptor t, String identifier, ExpressionNode e, boolean isglobal) {
     super(identifier);
@@ -26,7 +31,56 @@ public class FieldDescriptor extends Descriptor {
     this.safename = "___" + name + "___";
     this.uniqueid=count++;
     this.isglobal=isglobal;
-    if (en!=null) throw new Error("Field initializers not implemented");
+    this.isenum = false;
+    this.enumvalue = -1;
+    this.isEnumClass = false;
+  }
+
+  public ClassDescriptor getClassDescriptor() {
+    return this.cn;
+  }
+
+  public void setClassDescriptor(ClassDescriptor cn) {
+    this.cn = cn;
+  }
+
+  public String getSafeSymbol() {
+    if (isStatic()) {
+      return cn.getSafeSymbol()+safename;
+    } else
+      return safename;
+  }
+
+  public boolean isEnum() {
+    return this.isenum;
+  }
+
+  public int enumValue() {
+    return this.enumvalue;
+  }
+
+  public void setAsEnum() {
+    this.isenum = true;
+  }
+
+  public void setEnumValue(int value) {
+    this.enumvalue = value;
+  }
+
+  public ExpressionNode getExpressionNode() {
+    return en;
+  }
+
+  public boolean isFinal() {
+    return modifier.isFinal();
+  }
+
+  public boolean isStatic() {
+    return modifier.isStatic();
+  }
+
+  public boolean isVolatile() {
+    return modifier.isVolatile();
   }
 
   public boolean isGlobal() {
@@ -37,6 +91,10 @@ public class FieldDescriptor extends Descriptor {
     return td;
   }
 
+  public void changeSafeSymbol(int id) {
+    safename+=id;
+  }
+
   public String toString() {
     if (en==null)
       return modifier.toString()+td.toString()+" "+getSymbol()+";";
@@ -45,6 +103,19 @@ public class FieldDescriptor extends Descriptor {
   }
 
   public String toStringBrief() {
-    return td.toString()+" "+getSymbol();
+    return td.toPrettyString()+" "+getSymbol();
+  }
+
+  public String toPrettyStringBrief() {
+    return td.toPrettyString()+" "+getSymbol();
+  }
+  
+  public void setIsEnumClass() {
+    this.isEnumClass = true;
   }
+
+  public boolean isEnumClass() {
+    return this.isEnumClass;
+  }
+
 }