Bug correction
[IRC.git] / Robust / src / IR / TypeDescriptor.java
index a6f65422c68416f1f59013943740e26ff034efed..bcafc03b44c7bef67bdf512c53b03c7a4a532f44 100644 (file)
@@ -17,7 +17,8 @@ public class TypeDescriptor extends Descriptor {
     public static final int DOUBLE=8;
     public static final int VOID=9;
     public static final int NULL=10;
-    public static final int CLASS=11;
+    public static final int TAG=11;
+    public static final int CLASS=12;
 
 
     int arraycount;
@@ -29,7 +30,7 @@ public class TypeDescriptor extends Descriptor {
            TypeDescriptor t=(TypeDescriptor)o;
            if (t.type!=type)
                return false;
-           if ((type==CLASS)&&(t.class_desc!=class_desc))
+           if ((type==CLASS)&&(!t.getSymbol().equals(getSymbol())))
                return false;
            if (t.arraycount!=arraycount)
                return false;
@@ -38,6 +39,16 @@ public class TypeDescriptor extends Descriptor {
        return false;
     }
 
+    public boolean isString() {
+       if (type!=CLASS)
+           return false;
+       if (arraycount>0)
+           return false;
+       if (!getSymbol().equals(TypeUtil.StringClass))
+           return false;
+       return true;
+    }
+
     public int hashCode() {
        int hashcode=type^arraycount;
        if (type==CLASS)
@@ -146,6 +157,8 @@ public class TypeDescriptor extends Descriptor {
            return "D";
        else if (isFloat())
            return "F";
+       else if (isTag())
+           return "T";
        else throw new Error(); 
     }
 
@@ -185,7 +198,7 @@ public class TypeDescriptor extends Descriptor {
     }
 
     public boolean isPtr() {
-       return (isClass()||isNull());
+       return (isClass()||isNull()||isTag()||isArray());
     }
 
     public boolean isIntegerType() {
@@ -203,6 +216,10 @@ public class TypeDescriptor extends Descriptor {
     public boolean isClass() {
        return type==CLASS;
     }
+    
+    public boolean isTag() {
+       return type==TAG;
+    }
 
     public TypeDescriptor(NameDescriptor name) {
        super(name.toString());
@@ -211,8 +228,11 @@ public class TypeDescriptor extends Descriptor {
        this.arraycount=0;
     }
 
-    private TypeDescriptor(String st) {
+    public TypeDescriptor(String st) {
        super(st);
+       this.type=CLASS;
+       this.class_desc=null;
+       this.arraycount=0;
     }
 
     public ClassDescriptor getClassDesc() {
@@ -233,9 +253,19 @@ public class TypeDescriptor extends Descriptor {
     }
 
     public String toString() {
-       if (type==CLASS)
+       if (type==CLASS) {
            return name;
-       else 
+       } else 
+           return decodeInt(type);
+    }
+
+    public String toPrettyString() {
+       if (type==CLASS) {
+           String str=name;
+           for(int i=0;i<arraycount;i++)
+               str+="[]";
+           return str;
+       } else 
            return decodeInt(type);
     }
 
@@ -260,6 +290,8 @@ public class TypeDescriptor extends Descriptor {
            return "void";
        else if (type==NULL)
            return "null";
+       else if (type==TAG)
+           return TypeUtil.TagClass;
        else throw new Error();
     }
 }