X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FIR%2FTypeDescriptor.java;h=431d964dc0d1d76572f17fb2b2951506890ce7ef;hb=5c990dc2f16fb12de3201155cf241f329a712a09;hp=c306e4b4e4687fd1f86369b0ad4e0aed078de289;hpb=468e3b4f0570c70b43375b016eef803f66a37fe8;p=IRC.git diff --git a/Robust/src/IR/TypeDescriptor.java b/Robust/src/IR/TypeDescriptor.java index c306e4b4..431d964d 100644 --- a/Robust/src/IR/TypeDescriptor.java +++ b/Robust/src/IR/TypeDescriptor.java @@ -1,5 +1,9 @@ package IR; +import java.util.HashSet; +import java.util.Set; +import java.util.Vector; + /** * Descriptor * @@ -25,19 +29,22 @@ public class TypeDescriptor extends Descriptor { int arraycount; private int type; ClassDescriptor class_desc; - boolean isStatic = false; + boolean isClassNameRef = false; + + private Vector annotationSet; + private TypeExtension typeExtension; public boolean equals(Object o) { if (o instanceof TypeDescriptor) { TypeDescriptor t=(TypeDescriptor)o; if (t.type!=type) - return false; + return false; if ((type==CLASS)&&(!t.getSymbol().equals(getSymbol()))) - return false; - if (isStatic != t.isStatic) return false; if (t.arraycount!=arraycount) - return false; + return false; + if (t.isClassNameRef != this.isClassNameRef) + return false; return true; } return false; @@ -52,13 +59,13 @@ public class TypeDescriptor extends Descriptor { return false; return true; } - - public boolean isStatic() { - return this.isStatic; + + public boolean isClassNameRef() { + return this.isClassNameRef; } - - public void setStatic() { - this.isStatic = true; + + public void setClassNameRef() { + this.isClassNameRef = true; } public int hashCode() { @@ -72,14 +79,14 @@ public class TypeDescriptor extends Descriptor { if (arraycount!=0||!isClass()) return false; return (name.equals("bytewrapper")|| - name.equals("booleanwrapper")|| - name.equals("shortwrapper")|| - name.equals("intwrapper")|| - name.equals("longwrapper")|| - name.equals("charwrapper")|| - name.equals("floatwrapper")|| - name.equals("doublewrapper")|| - name.equals("Objectwrapper")); + name.equals("booleanwrapper")|| + name.equals("shortwrapper")|| + name.equals("intwrapper")|| + name.equals("longwrapper")|| + name.equals("charwrapper")|| + name.equals("floatwrapper")|| + name.equals("doublewrapper")|| + name.equals("Objectwrapper")); } public TypeDescriptor makeArray(State state) { @@ -119,14 +126,16 @@ public class TypeDescriptor extends Descriptor { public String getSafeSymbol() { if (isArray()) return IR.Flat.BuildCode.arraytype; - else if (isClass()) + else if (isClass()) { return class_desc.getSafeSymbol(); - else if (isByte()) + } else if (isByte()) return "char"; else if (isChar()) 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 @@ -141,20 +150,25 @@ public class TypeDescriptor extends Descriptor { return "float"; else if (isOffset()) return "short"; - else throw new Error("Error Type: "+type); + else if (isNull()) + return "null"; + else + throw new Error("Error Type: "+type); } public String getRepairSymbol() { if (isArray()) return IR.Flat.BuildCode.arraytype; - else if (isClass()) + else if (isClass()) { return class_desc.getSymbol(); - else if (isByte()) + } else if (isByte()) return "byte"; else if (isChar()) 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 @@ -174,7 +188,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"; @@ -194,7 +208,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() { @@ -241,7 +255,7 @@ public class TypeDescriptor extends Descriptor { } public boolean isIntegerType() { - return (isInt()||isLong()||isShort()||isChar()||isByte()); + return (isInt()||isLong()||isShort()||isChar()||isByte()||isEnum()); } public void setClassDescriptor(ClassDescriptor cd) { @@ -249,11 +263,20 @@ public class TypeDescriptor extends Descriptor { } public boolean isPrimitive() { - return ((type>=BYTE)&&(type<=DOUBLE)); + return (((type>=BYTE)&&(type<=DOUBLE)) || isEnum()); + } + + public boolean isEnum() { + if(this.type != CLASS) { + return false; + } else if(this.class_desc != null) { + return this.class_desc.isEnum(); + } + return false; } public boolean isClass() { - return type==CLASS; + return (type==CLASS && !isEnum()); } public boolean isTag() { @@ -261,7 +284,7 @@ public class TypeDescriptor extends Descriptor { } public boolean isImmutable() { - return isPrimitive() || isString(); + return isPrimitive(); } public TypeDescriptor(NameDescriptor name) { @@ -269,7 +292,8 @@ public class TypeDescriptor extends Descriptor { this.type=CLASS; this.class_desc=null; this.arraycount=0; - this.isStatic =false; + this.isClassNameRef =false; + this.annotationSet=new Vector(); } public TypeDescriptor(String st) { @@ -277,7 +301,8 @@ public class TypeDescriptor extends Descriptor { this.type=CLASS; this.class_desc=null; this.arraycount=0; - this.isStatic =false; + this.isClassNameRef =false; + this.annotationSet=new Vector(); } public ClassDescriptor getClassDesc() { @@ -289,14 +314,16 @@ public class TypeDescriptor extends Descriptor { this.type=CLASS; this.class_desc=cd; this.arraycount=0; - this.isStatic =false; + this.isClassNameRef =false; + this.annotationSet=new Vector(); } public TypeDescriptor(int t) { super(decodeInt(t)); this.type=t; this.arraycount=0; - this.isStatic =false; + this.isClassNameRef =false; + this.annotationSet=new Vector(); } public String toString() { @@ -313,7 +340,7 @@ public class TypeDescriptor extends Descriptor { } for(int i=0; i getAnnotationMarkers() { + return annotationSet; + } + + public void setExtension(TypeExtension te) { + typeExtension=te; + } + + public TypeExtension getExtension() { + return typeExtension; + } + }