New option -printrepair added. Prints updates to data structures.
[repair.git] / Repair / RepairCompiler / MCC / IR / UpdateNode.java
index ee6bdac134c291c4ecd870f71e8324ee7b8e8de8..0f472875ed2f966d5c61f7abc18f3b2f6e1fb30d 100755 (executable)
@@ -1,6 +1,7 @@
 package MCC.IR;
 import java.util.*;
 import MCC.State;
+import MCC.Compiler;
 
 class UpdateNode {
     Vector updates;
@@ -44,14 +45,29 @@ class UpdateNode {
        }
     }
 
-    public boolean checkupdates() {
+    public boolean checkupdates(State state) {
        if (!checkconflicts()) /* Do we have conflicting concrete updates */
            return false;
+        if (!checknoupdates(state))
+            return false;
        if (computeordering()) /* Ordering exists */
            return true;
        return false;
     }
 
+    private boolean checknoupdates(State state) {
+        Set noupdate=state.noupdate;
+        for(int i=0;i<updates.size();i++) {
+           Updates u=(Updates)updates.get(i);
+            if (u.isAbstract())
+                continue; /* Abstract updates don't change fields */
+            Descriptor d=u.getDescriptor();
+            if (noupdate.contains(d))
+                return false;
+        }
+        return true;
+    }
+
     private boolean computeordering() {
        /* Build dependency graph between updates */
        HashSet graph=new HashSet();
@@ -416,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();
@@ -426,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) {