projects
/
IRC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix for ssJava: realized that annotation should not be a part of hash code.
[IRC.git]
/
Robust
/
src
/
IR
/
TypeDescriptor.java
diff --git
a/Robust/src/IR/TypeDescriptor.java
b/Robust/src/IR/TypeDescriptor.java
index 7725f61070dd1d5d36fea460a88f225ef52525f7..855345789a76f69727efd793c2f889d191fbc3ce 100644
(file)
--- a/
Robust/src/IR/TypeDescriptor.java
+++ b/
Robust/src/IR/TypeDescriptor.java
@@
-1,5
+1,9
@@
package IR;
package IR;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Vector;
+
/**
* Descriptor
*
/**
* Descriptor
*
@@
-25,6
+29,9
@@
public class TypeDescriptor extends Descriptor {
int arraycount;
private int type;
ClassDescriptor class_desc;
int arraycount;
private int type;
ClassDescriptor class_desc;
+ boolean isClassNameRef = false;
+
+ private Vector<AnnotationDescriptor> annotationSet;
public boolean equals(Object o) {
if (o instanceof TypeDescriptor) {
public boolean equals(Object o) {
if (o instanceof TypeDescriptor) {
@@
-35,6
+42,8
@@
public class TypeDescriptor extends Descriptor {
return false;
if (t.arraycount!=arraycount)
return false;
return false;
if (t.arraycount!=arraycount)
return false;
+ if (t.isClassNameRef != this.isClassNameRef)
+ return false;
return true;
}
return false;
return true;
}
return false;
@@
-49,6
+58,14
@@
public class TypeDescriptor extends Descriptor {
return false;
return true;
}
return false;
return true;
}
+
+ public boolean isClassNameRef() {
+ return this.isClassNameRef;
+ }
+
+ public void setClassNameRef() {
+ this.isClassNameRef = true;
+ }
public int hashCode() {
int hashcode=type^arraycount;
public int hashCode() {
int hashcode=type^arraycount;
@@
-68,7
+85,7
@@
public class TypeDescriptor extends Descriptor {
name.equals("charwrapper")||
name.equals("floatwrapper")||
name.equals("doublewrapper")||
name.equals("charwrapper")||
name.equals("floatwrapper")||
name.equals("doublewrapper")||
- name.equals("
o
bjectwrapper"));
+ name.equals("
O
bjectwrapper"));
}
public TypeDescriptor makeArray(State state) {
}
public TypeDescriptor makeArray(State state) {
@@
-108,14
+125,16
@@
public class TypeDescriptor extends Descriptor {
public String getSafeSymbol() {
if (isArray())
return IR.Flat.BuildCode.arraytype;
public String getSafeSymbol() {
if (isArray())
return IR.Flat.BuildCode.arraytype;
- else if (isClass())
+ else if (isClass())
{
return class_desc.getSafeSymbol();
return class_desc.getSafeSymbol();
- else if (isByte())
+
}
else if (isByte())
return "char";
else if (isChar())
return "short";
else if (isShort())
return "short";
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
else if (isInt())
return "int";
else if (isBoolean()) //Booleans are ints in C
@@
-130,20
+149,23
@@
public class TypeDescriptor extends Descriptor {
return "float";
else if (isOffset())
return "short";
return "float";
else if (isOffset())
return "short";
- else throw new Error("Error Type: "+type);
+ else
+ throw new Error("Error Type: "+type);
}
public String getRepairSymbol() {
if (isArray())
return IR.Flat.BuildCode.arraytype;
}
public String getRepairSymbol() {
if (isArray())
return IR.Flat.BuildCode.arraytype;
- else if (isClass())
+ else if (isClass())
{
return class_desc.getSymbol();
return class_desc.getSymbol();
- else if (isByte())
+
}
else if (isByte())
return "byte";
else if (isChar())
return "short";
else if (isShort())
return "short";
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
else if (isInt())
return "int";
else if (isBoolean()) //Booleans are ints in C
@@
-163,7
+185,7
@@
public class TypeDescriptor extends Descriptor {
//Can't safely use [ in C
if (isArray())
return "_AR_"+this.dereference().getSafeDescriptor();
//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 class_desc.getSafeDescriptor();
else if (isByte())
return "B";
@@
-183,7
+205,7
@@
public class TypeDescriptor extends Descriptor {
return "F";
else if (isTag())
return "T";
return "F";
else if (isTag())
return "T";
- else throw new Error();
+ else throw new Error(
toString()
);
}
public boolean isNumber() {
}
public boolean isNumber() {
@@
-230,7
+252,7
@@
public class TypeDescriptor extends Descriptor {
}
public boolean isIntegerType() {
}
public boolean isIntegerType() {
- return (isInt()||isLong()||isShort()||isChar()||isByte());
+ return (isInt()||isLong()||isShort()||isChar()||isByte()
||isEnum()
);
}
public void setClassDescriptor(ClassDescriptor cd) {
}
public void setClassDescriptor(ClassDescriptor cd) {
@@
-238,11
+260,20
@@
public class TypeDescriptor extends Descriptor {
}
public boolean isPrimitive() {
}
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() {
public boolean isClass() {
- return
type==CLASS
;
+ return
(type==CLASS && !isEnum())
;
}
public boolean isTag() {
}
public boolean isTag() {
@@
-258,6
+289,8
@@
public class TypeDescriptor extends Descriptor {
this.type=CLASS;
this.class_desc=null;
this.arraycount=0;
this.type=CLASS;
this.class_desc=null;
this.arraycount=0;
+ this.isClassNameRef =false;
+ this.annotationSet=new Vector<AnnotationDescriptor>();
}
public TypeDescriptor(String st) {
}
public TypeDescriptor(String st) {
@@
-265,6
+298,8
@@
public class TypeDescriptor extends Descriptor {
this.type=CLASS;
this.class_desc=null;
this.arraycount=0;
this.type=CLASS;
this.class_desc=null;
this.arraycount=0;
+ this.isClassNameRef =false;
+ this.annotationSet=new Vector<AnnotationDescriptor>();
}
public ClassDescriptor getClassDesc() {
}
public ClassDescriptor getClassDesc() {
@@
-276,12
+311,16
@@
public class TypeDescriptor extends Descriptor {
this.type=CLASS;
this.class_desc=cd;
this.arraycount=0;
this.type=CLASS;
this.class_desc=cd;
this.arraycount=0;
+ this.isClassNameRef =false;
+ this.annotationSet=new Vector<AnnotationDescriptor>();
}
public TypeDescriptor(int t) {
super(decodeInt(t));
this.type=t;
this.arraycount=0;
}
public TypeDescriptor(int t) {
super(decodeInt(t));
this.type=t;
this.arraycount=0;
+ this.isClassNameRef =false;
+ this.annotationSet=new Vector<AnnotationDescriptor>();
}
public String toString() {
}
public String toString() {
@@
-321,11
+360,20
@@
public class TypeDescriptor extends Descriptor {
else if (type==VOID)
return "void";
else if (type==NULL)
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();
}
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;
+ }
+
}
}