X-Git-Url: http://plrg.eecs.uci.edu/git/?p=repair.git;a=blobdiff_plain;f=Repair%2FRepairCompiler%2FMCC%2FIR%2FStructureTypeDescriptor.java;h=f7e19dcb49663b79c18bb89117044cc7232ada8a;hp=7b6e5148c8c88ca8a4b565a26925fe23942376e7;hb=04f85f882f97b329b34d2a898454af2c6382ab0f;hpb=6c695ded242baac0380695bb278faf6416f25e16 diff --git a/Repair/RepairCompiler/MCC/IR/StructureTypeDescriptor.java b/Repair/RepairCompiler/MCC/IR/StructureTypeDescriptor.java index 7b6e514..f7e19dc 100755 --- a/Repair/RepairCompiler/MCC/IR/StructureTypeDescriptor.java +++ b/Repair/RepairCompiler/MCC/IR/StructureTypeDescriptor.java @@ -15,16 +15,10 @@ public class StructureTypeDescriptor extends TypeDescriptor { Hashtable fields = new Hashtable(); /* fast lookups */ Vector fieldlist = new Vector(); /* ordering information */ Hashtable labels = new Hashtable(); - int idnum; - static int counter=0; - public int getId() { - return idnum; - } public StructureTypeDescriptor(String name) { super(name); - idnum=counter++; } public TypeDescriptor getGenerateType() { @@ -55,7 +49,6 @@ public class StructureTypeDescriptor extends TypeDescriptor { boolean ptr = fd.getPtr(); Expr basesize; if (ptr) { /* ptrs are 32bits */ - basesize = new IntegerLiteralExpr(32); } else { basesize = td.getSizeExpr(); @@ -85,7 +78,7 @@ public class StructureTypeDescriptor extends TypeDescriptor { } if (fd == field) { /* stop, reached target field */ - break; + break; } size = new OpExpr(Opcode.ADD, fieldsize, size); @@ -139,8 +132,30 @@ public class StructureTypeDescriptor extends TypeDescriptor { if (td == this) { return true; } else { + if (subtype==null) + return false; return subtype.isSubtypeOf(td); } } + public void generate_printout(CodeWriter cr, VarDescriptor vd) { + // #TBD#: does not support printing out fields that have variable size, substructures, etc + + cr.outputline("printf(\"" + getSymbol() + " %p: \", " + vd.getSafeSymbol() + ");"); + for (int i = 0; i < fieldlist.size(); i++) { + FieldDescriptor fd = (FieldDescriptor) fieldlist.elementAt(i); + cr.outputline("printf(\"\\n\\t" + fd.getSymbol() + " = \");"); + if (fd.getPtr()) { + cr.outputline("printf(\"(" + fd.getType().getSymbol() + ") %p \", ((int *)" + vd.getSafeSymbol() + ")[" + i + "]);"); + } else if ( fd.getType() instanceof ReservedTypeDescriptor) { + cr.outputline("printf(\"%d \", ((int *)" + vd.getSafeSymbol() + ")[" + i + "]);"); + } else { + cr.outputline("printf(\"unsupported, breaking\");"); + break; + } + } + + cr.outputline("printf(\"\\n\");"); + } + }