New option -printrepair added. Prints updates to data structures.
authorbdemsky <bdemsky>
Fri, 14 Oct 2005 18:34:28 +0000 (18:34 +0000)
committerbdemsky <bdemsky>
Fri, 14 Oct 2005 18:34:28 +0000 (18:34 +0000)
Repair/RepairCompiler/MCC/CLI.java
Repair/RepairCompiler/MCC/Compiler.java
Repair/RepairCompiler/MCC/IR/UpdateNode.java

index d69310a63d41acecbc7c5832eb7e9758975ca3d7..9b2e961bd816d0e61589f9692e8a4ca8d5756a82 100755 (executable)
@@ -11,7 +11,7 @@ import MCC.IR.DebugItem;
  * files.
  *
  * @author  le01, 6.035 Staff (<tt>6.035-staff@mit.edu</tt>)
- * @version <tt>$Id: CLI.java,v 1.17 2005/10/12 17:43:10 bdemsky Exp $</tt>
+ * @version <tt>$Id: CLI.java,v 1.18 2005/10/14 18:31:41 bdemsky Exp $</tt>
  */
 public class CLI {
     /**
@@ -111,6 +111,7 @@ public class CLI {
            System.out.println("-mergenodes -- omit nodes for simpler role dependence graphs");
            System.out.println("-debuggraph -- add edge labels and support to debug graph");
            System.out.println("-rejectlengthchanges -- reject all updates which change the length of an array");
+           System.out.println("-printrepairs -- print log of repair actions");
 
            System.exit(-1);
        }
@@ -127,6 +128,8 @@ public class CLI {
                 Compiler.DEBUGGRAPH=true;
            } else if (args[i].equals("-mergenodes")) {
                 Compiler.MERGENODES=true;
+           } else if (args[i].equals("-printrepairs")) {
+                Compiler.PRINTREPAIRS=true;
            } else if (args[i].equals("-depth")) {
                Compiler.debuggraphs.add(new DebugItem(Integer.parseInt(args[i+1]),Integer.parseInt(args[i+2])));
                i+=2;
index 5fa3fca1a81ccf07b6d65b7838959ef55e645319..6151f2d3ecf586449ed8fa21fe938d85dfcfa9bd 100755 (executable)
@@ -30,6 +30,7 @@ public class Compiler {
     public static boolean TIME=false;
     public static boolean DEBUGGRAPH=false;
     public static boolean REJECTLENGTH=false;
+    public static boolean PRINTREPAIRS=false;
 
     public static Vector debuggraphs=new Vector();
 
index 89ffed905db057b1a0dd553c2269487e0a978e9b..0f472875ed2f966d5c61f7abc18f3b2f6e1fb30d 100755 (executable)
@@ -1,6 +1,7 @@
 package MCC.IR;
 import java.util.*;
 import MCC.State;
+import MCC.Compiler;
 
 class UpdateNode {
     Vector updates;
@@ -431,9 +432,13 @@ class UpdateNode {
            else if (op==Opcode.LE)
                ;
            else throw new Error();
+
            if (u.isGlobal()) {
                VarDescriptor vd=((VarExpr)u.getLeftExpr()).getVar();
                cr.outputline(vd.getSafeSymbol()+"="+right.getSafeSymbol()+";");
+                if (Compiler.PRINTREPAIRS) {
+                    cr.outputline("printf(\""+u.getLeftExpr().toString()+"=%d\\n\","+right.getSafeSymbol()+");");
+                }
            } else if (u.isField()) {
                /* NEED TO FIX */
                Expr subexpr=((DotExpr)u.getLeftExpr()).getExpr();
@@ -441,9 +446,22 @@ class UpdateNode {
                VarDescriptor subvd=VarDescriptor.makeNew("subexpr");
                VarDescriptor indexvd=VarDescriptor.makeNew("index");
                subexpr.generate(cr,subvd);
+
                if (intindex!=null)
                    intindex.generate(cr,indexvd);
                FieldDescriptor fd=(FieldDescriptor)u.getDescriptor();
+                if (Compiler.PRINTREPAIRS) {
+                    if (intindex==null) {
+                        cr.outputline("printf(\"0x%x."+fd.toString()+
+                                      "=%d\\n\","+subvd.getSafeSymbol()+","+right.getSafeSymbol()+");");
+                    } else {
+                        cr.outputline("printf(\"0x%x."+fd.toString()+
+                                      "[%d]=%d\\n\","+subvd.getSafeSymbol()+
+                                      ","+indexvd.getSafeSymbol()+","+right.getSafeSymbol()+");");
+                    }
+                }
+
+
                StructureTypeDescriptor std=(StructureTypeDescriptor)subexpr.getType();
                Expr offsetbits = std.getOffsetExpr(fd);
                if (fd instanceof ArrayDescriptor) {