package IR;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Vector;
+
/**
* Descriptor
*
ClassDescriptor class_desc;
boolean isClassNameRef = false;
+ private Vector<AnnotationDescriptor> annotationSet;
+ private TypeExtension typeExtension;
+
public boolean equals(Object o) {
if (o instanceof TypeDescriptor) {
TypeDescriptor t=(TypeDescriptor)o;
if (t.arraycount!=arraycount)
return false;
if (t.isClassNameRef != this.isClassNameRef)
- return false;
+ return false;
return true;
}
return false;
return false;
return true;
}
-
+
public boolean isClassNameRef() {
return this.isClassNameRef;
}
-
+
public void setClassNameRef() {
this.isClassNameRef = true;
}
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, boolean addflag) {
+ public TypeDescriptor makeArray(State state) {
TypeDescriptor td=new TypeDescriptor(getSymbol());
td.arraycount=arraycount+1;
td.type=type;
td.class_desc=class_desc;
- if(addflag) {
- state.addArrayType(td);
- }
+ state.addArrayType(td);
return td;
}
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
return "float";
else if (isOffset())
return "short";
- else throw new Error("Error Type: "+type);
+ else
+ throw new Error("Error Type: "+type);
}
public String getRepairSymbol() {
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
//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";
return "F";
else if (isTag())
return "T";
- else throw new Error();
+ else throw new Error(toString());
}
public boolean isNumber() {
}
public boolean isPtr() {
- return ((isClass()&&!isEnum())||isNull()||isTag()||isArray());
+ return (isClass()||isNull()||isTag()||isArray());
}
public boolean isIntegerType() {
}
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){
+ } 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() {
this.class_desc=null;
this.arraycount=0;
this.isClassNameRef =false;
+ this.annotationSet=new Vector<AnnotationDescriptor>();
}
public TypeDescriptor(String st) {
this.class_desc=null;
this.arraycount=0;
this.isClassNameRef =false;
+ this.annotationSet=new Vector<AnnotationDescriptor>();
}
public ClassDescriptor getClassDesc() {
this.class_desc=cd;
this.arraycount=0;
this.isClassNameRef =false;
+ this.annotationSet=new Vector<AnnotationDescriptor>();
}
public TypeDescriptor(int t) {
this.type=t;
this.arraycount=0;
this.isClassNameRef =false;
+ this.annotationSet=new Vector<AnnotationDescriptor>();
}
public String toString() {
}
for(int i=0; i<arraycount; i++)
str+="[]";
- return str;
+ return str;
}
private static String decodeInt(int type) {
else if (type==VOID)
return "void";
else if (type==NULL)
- return "null";
+ return "NULL";
else if (type==TAG)
return TypeUtil.TagClass;
else if (type==OFFSET)
return "offset";
else throw new Error();
}
+
+ public void addAnnotationMarker(AnnotationDescriptor an) {
+ annotationSet.add(an);
+ }
+
+ public Vector<AnnotationDescriptor> getAnnotationMarkers() {
+ return annotationSet;
+ }
+
+ public void setExtension(TypeExtension te) {
+ typeExtension=te;
+ }
+
+ public TypeExtension getExtension() {
+ return typeExtension;
+ }
+
}