fix for ssJava: realized that annotation should not be a part of hash code.
[IRC.git] / Robust / src / IR / TypeDescriptor.java
index cb67bb9308be3f332b37d19b7536910cc97f4d35..855345789a76f69727efd793c2f889d191fbc3ce 100644 (file)
@@ -1,5 +1,9 @@
 package IR;
 
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Vector;
+
 /**
  * Descriptor
  *
@@ -26,6 +30,8 @@ public class TypeDescriptor extends Descriptor {
   private int type;
   ClassDescriptor class_desc;
   boolean isClassNameRef = false;
+  
+  private Vector<AnnotationDescriptor> annotationSet;
 
   public boolean equals(Object o) {
     if (o instanceof TypeDescriptor) {
@@ -127,6 +133,8 @@ public class TypeDescriptor extends Descriptor {
       return "short";
     else if (isShort())
       return "short";
+    else if (isEnum())
+      return "int";
     else if (isInt())
       return "int";
     else if (isBoolean())     //Booleans are ints in C
@@ -156,6 +164,8 @@ public class TypeDescriptor extends Descriptor {
       return "short";
     else if (isShort())
       return "short";
+    else if (isEnum())
+      return "int";
     else if (isInt())
       return "int";
     else if (isBoolean())     //Booleans are ints in C
@@ -175,7 +185,7 @@ public class TypeDescriptor extends Descriptor {
     //Can't safely use [ in C
     if (isArray())
       return "_AR_"+this.dereference().getSafeDescriptor();
-    else if (isClass())
+    else if (isClass()||isEnum())
       return class_desc.getSafeDescriptor();
     else if (isByte())
       return "B";
@@ -195,7 +205,7 @@ public class TypeDescriptor extends Descriptor {
       return "F";
     else if (isTag())
       return "T";
-    else throw new Error();
+    else throw new Error(toString());
   }
 
   public boolean isNumber() {
@@ -238,7 +248,7 @@ public class TypeDescriptor extends Descriptor {
   }
 
   public boolean isPtr() {
-    return ((isClass()&&!isEnum())||isNull()||isTag()||isArray());
+    return (isClass()||isNull()||isTag()||isArray());
   }
 
   public boolean isIntegerType() {
@@ -250,7 +260,7 @@ public class TypeDescriptor extends Descriptor {
   }
 
   public boolean isPrimitive() {
-    return ((type>=BYTE)&&(type<=DOUBLE));
+    return (((type>=BYTE)&&(type<=DOUBLE)) || isEnum());
   }
 
   public boolean isEnum() {
@@ -263,7 +273,7 @@ public class TypeDescriptor extends Descriptor {
   }
   
   public boolean isClass() {
-    return type==CLASS;
+    return (type==CLASS && !isEnum());
   }
 
   public boolean isTag() {
@@ -280,6 +290,7 @@ public class TypeDescriptor extends Descriptor {
     this.class_desc=null;
     this.arraycount=0;
     this.isClassNameRef =false;
+    this.annotationSet=new Vector<AnnotationDescriptor>();
   }
 
   public TypeDescriptor(String st) {
@@ -288,6 +299,7 @@ public class TypeDescriptor extends Descriptor {
     this.class_desc=null;
     this.arraycount=0;
     this.isClassNameRef =false;
+    this.annotationSet=new Vector<AnnotationDescriptor>();
   }
 
   public ClassDescriptor getClassDesc() {
@@ -300,6 +312,7 @@ public class TypeDescriptor extends Descriptor {
     this.class_desc=cd;
     this.arraycount=0;
     this.isClassNameRef =false;
+    this.annotationSet=new Vector<AnnotationDescriptor>();
   }
 
   public TypeDescriptor(int t) {
@@ -307,6 +320,7 @@ public class TypeDescriptor extends Descriptor {
     this.type=t;
     this.arraycount=0;
     this.isClassNameRef =false;
+    this.annotationSet=new Vector<AnnotationDescriptor>();
   }
 
   public String toString() {
@@ -353,4 +367,13 @@ public class TypeDescriptor extends Descriptor {
       return "offset";
     else throw new Error();
   }
+  
+  public void addAnnotationMarker(AnnotationDescriptor an){
+    annotationSet.add(an);
+  }
+  
+  public Vector<AnnotationDescriptor> getAnnotationMarkers(){
+    return annotationSet;
+  }
+  
 }