Change to the spec...missed a consistency property. Adding timing option.
[repair.git] / Repair / RepairCompiler / MCC / IR / RepairGenerator.java
index 0f21555cc39f8cf04682f9f7c6ee3b2d2c75a19e..5d64040d50073b70b3df9c25d92beefb511a3ed7 100755 (executable)
@@ -387,7 +387,22 @@ public class RepairGenerator {
        crhead.outputline("~"+name+"();");
         craux.outputline("#include \""+headername+"\"");
         craux.outputline("#include \"size.h\"");
-
+       if (Compiler.ALLOCATECPLUSPLUS) {
+           for(Iterator it=state.stTypes.descriptors();it.hasNext();) {
+               TypeDescriptor td=(TypeDescriptor)it.next();
+               if (td instanceof StructureTypeDescriptor) {
+                   if (((StructureTypeDescriptor)td).size()>0) {
+                       FieldDescriptor fd=((StructureTypeDescriptor)td).get(0);
+                       if (fd.getSymbol().startsWith("_vptr_")) {
+                           String vtable="_ZTV";
+                           vtable+=td.getSymbol().length();
+                           vtable+=td.getSymbol();
+                           craux.outputline("extern void * "+vtable+";");
+                       }
+                   }
+               }
+           }
+       }
         craux.outputline(name+"::"+name+"() {");
         craux.outputline("// creating hashtables ");
         
@@ -482,6 +497,11 @@ public class RepairGenerator {
        crhead.outputline("void doanalysis();");
        craux.outputline("void "+name +"_state::doanalysis()");
        craux.startblock();
+       if (Compiler.TIME) {
+           craux.outputline("struct timeval _begin_time,_end_time;");
+           craux.outputline("gettimeofday(&_begin_time,NULL);");
+       }
+
        if (Compiler.GENERATEINSTRUMENT) {
            craux.outputline("updatecount=0;");
            craux.outputline("rebuildcount=0;");
@@ -506,6 +526,11 @@ public class RepairGenerator {
     private void generate_teardown() {
        CodeWriter cr = new StandardCodeWriter(outputaux);        
        cr.endblock();
+       if (Compiler.TIME) {
+           cr.outputline("gettimeofday(&_end_time,NULL);");
+           cr.outputline("printf(\"time=%ld uS\\n\",(_end_time.tv_sec-_begin_time.tv_sec)*1000000+_end_time.tv_usec-_begin_time.tv_usec)");
+       }
+
        if (Compiler.GENERATEINSTRUMENT) {
            cr.outputline("printf(\"updatecount=%d\\n\",updatecount);");
            cr.outputline("printf(\"rebuildcount=%d\\n\",rebuildcount);");
@@ -1207,11 +1232,11 @@ public class RepairGenerator {
            VarDescriptor rightvar=VarDescriptor.makeNew("rightvar");
            if (d instanceof RelationDescriptor) {
                if (ep.inverted()) {
-                   rightvar=((ImageSetExpr)((SizeofExpr)((OpExpr)expr).left).setexpr).getVar();
+                   ((ImageSetExpr)((SizeofExpr)expr.left).setexpr).generate_leftside(cr,rightvar);
                    cr.outputline("int "+leftvar.getSafeSymbol()+";");
                    cr.outputline(d.getSafeSymbol()+"_hashinv->get((int)"+rightvar.getSafeSymbol()+","+leftvar.getSafeSymbol()+");");
                } else {
-                   leftvar=((ImageSetExpr)((SizeofExpr)((OpExpr)expr).left).setexpr).getVar();
+                   ((ImageSetExpr)((SizeofExpr)expr.left).setexpr).generate_leftside(cr,leftvar);
                    cr.outputline("int "+rightvar.getSafeSymbol()+"=0;");
                    cr.outputline(d.getSafeSymbol()+"_hash->get((int)"+leftvar.getSafeSymbol()+","+rightvar.getSafeSymbol()+");");
                }
@@ -1250,13 +1275,21 @@ public class RepairGenerator {
            }
            cr.endblock();
        }
+
+// In some cases the analysis has determined that generating removes
+// is unnecessary
+       if (generateadd&&munadd==null) 
+           generateadd=false;
+
        if (generateadd) {
 
            cr.outputline("for(;"+change.getSafeSymbol()+">0;"+change.getSafeSymbol()+"--)");
            cr.startblock();
            VarDescriptor newobject=VarDescriptor.makeNew("newobject");
            if (d instanceof RelationDescriptor) {
-               VarDescriptor otherside=((ImageSetExpr)((SizeofExpr)((OpExpr)ep.expr).left).setexpr).vd;
+               VarDescriptor otherside=VarDescriptor.makeNew("otherside");
+               ((ImageSetExpr)((SizeofExpr)expr.left).setexpr).generate_leftside(cr,otherside);
+               
                RelationDescriptor rd=(RelationDescriptor)d;
                if (termination.sources.relsetSource(rd,!ep.inverted())) {
                    /* Set Source */