Added:
[repair.git] / Repair / RepairCompiler / MCC / IR / StructureTypeDescriptor.java
index 222c6c1134fcb4d9eeeb25fe19791d39f4d51fb0..f0808e825020ba07d1ba938f4e9d67244b94613f 100755 (executable)
@@ -16,6 +16,7 @@ public class StructureTypeDescriptor extends TypeDescriptor {
     Vector fieldlist = new Vector(); /* ordering information */
     Hashtable labels = new Hashtable();
 
+
     public StructureTypeDescriptor(String name) {
         super(name);
     }
@@ -34,7 +35,10 @@ public class StructureTypeDescriptor extends TypeDescriptor {
     }
 
     public Expr getOffsetExpr(FieldDescriptor field) {
-       
+       /* Fix sizeof calculations */
+       if ((field==null)&&(subtype!=null))
+           return subtype.getSizeExpr();
+
        boolean aligned=true;
         Expr size = new IntegerLiteralExpr(0);
         
@@ -117,11 +121,11 @@ public class StructureTypeDescriptor extends TypeDescriptor {
         labels.put(ld.getSymbol(), ld);
     }
 
-    public TypeDescriptor getSubType() {
+    public TypeDescriptor getSuperType() {
         return subtype;
     }
 
-    public void setSubType(TypeDescriptor td) {
+    public void setSuperType(TypeDescriptor td) {
         subtype = td;
     }
 
@@ -129,6 +133,8 @@ public class StructureTypeDescriptor extends TypeDescriptor {
         if (td == this) {
             return true;
         } else {
+           if (subtype==null)
+               return false;
             return subtype.isSubtypeOf(td);
         }
     }