Changes to allow unique names
authorbdemsky <bdemsky>
Wed, 9 Nov 2005 16:48:14 +0000 (16:48 +0000)
committerbdemsky <bdemsky>
Wed, 9 Nov 2005 16:48:14 +0000 (16:48 +0000)
Repair/RepairCompiler/MCC/CLI.java
Repair/RepairCompiler/MCC/IR/DotExpr.java
Repair/RepairCompiler/MCC/IR/RepairGenerator.java

index 9f3badc6cc863b8d40739258e0257842bed1b154..b8cce23e2c2b62857c1e25ab22ac50ac2be1c935 100755 (executable)
@@ -2,6 +2,7 @@ package MCC;
 
 import java.util.*;
 import MCC.IR.DebugItem;
+import MCC.IR.RepairGenerator;
 
 /**
  * A generic command-line interface for 6.035 compilers.  This class
@@ -11,7 +12,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.19 2005/10/17 00:29:13 bdemsky Exp $</tt>
+ * @version <tt>$Id: CLI.java,v 1.20 2005/11/09 16:47:42 bdemsky Exp $</tt>
  */
 public class CLI {
     /**
@@ -114,7 +115,7 @@ public class CLI {
            System.out.println("-printrepairs -- print log of repair actions");
            System.out.println("-exactallocation -- application calls malloc for each struct and");
            System.out.println("                    allocates exactly the right amount of space.");
-
+           System.out.println("-name -- set name");
            System.exit(-1);
        }
 
@@ -154,6 +155,10 @@ public class CLI {
                 Compiler.PRUNEQUANTIFIERS=true;
            } else if (args[i].equals("-cplusplus")) {
                 Compiler.ALLOCATECPLUSPLUS=true;
+           } else if (args[i].equals("-name")) {
+               i++;
+                RepairGenerator.name=args[i];
+               RepairGenerator.postfix=args[i];
             } else if (args[i].equals("-verbose") || args[i].equals("-v")) {
                 context = 0;
                 verbose++;
index d3caca911634e304931e6164156d389358789edd..6998d3a3f001d8edb46ff6c5196380631c77ef97 100755 (executable)
@@ -371,7 +371,13 @@ public class DotExpr extends Expr {
                                     UpdateNode un=new UpdateNode(null);
                                     un.addUpdate(u);
                                     un.generate(writer,false,false,null,null,null,null);
-                                    writer.outputline("break;");
+                                   writer.outputline("free"+RepairGenerator.name+"("+RepairGenerator.newmodel.getSafeSymbol()+");");
+                                   writer.outputline("computesizes(thisvar);");
+                                   writer.outputline(RepairGenerator.name+"_staterecomputesizes(thisvar);");
+                                   writer.outputline("goto rebuild;");
+
+                                   //                                    writer.outputline("break;");
+                                   
                                 } else if ((indexbound instanceof OpExpr)&&
                                            (((OpExpr)indexbound).getOpcode()==Opcode.MULT)&&
                                            (((OpExpr)indexbound).getLeftExpr() instanceof DotExpr)&&
@@ -398,7 +404,11 @@ public class DotExpr extends Expr {
                                         UpdateNode un=new UpdateNode(null);
                                         un.addUpdate(u);
                                         un.generate(writer,false,false,null,null,null,null);
-                                        writer.outputline("break;");
+                                       writer.outputline("free"+RepairGenerator.name+"("+RepairGenerator.newmodel.getSafeSymbol()+");");
+                                       writer.outputline("computesizes(thisvar);");
+                                       writer.outputline(RepairGenerator.name+"_staterecomputesizes(thisvar);");
+                                       writer.outputline("goto rebuild;");
+                                       //                                        writer.outputline("break;");
                                         writer.endblock();
                                     }
                                     writer.outputline("else if (("+rightside.getSafeSymbol()+"!=0)&&("+numElements.getSafeSymbol()+"%"+rightside.getSafeSymbol()+"==0))");
@@ -414,7 +424,11 @@ public class DotExpr extends Expr {
                                         UpdateNode un=new UpdateNode(null);
                                         un.addUpdate(u);
                                         un.generate(writer,false,false,null,null,null,null);
-                                        writer.outputline("break;");
+                                       writer.outputline("free"+RepairGenerator.name+"("+RepairGenerator.newmodel.getSafeSymbol()+");");
+                                       writer.outputline("computesizes(thisvar);");
+                                       writer.outputline(RepairGenerator.name+"_staterecomputesizes(thisvar);");
+                                       writer.outputline("goto rebuild;");
+                                       //                                        writer.outputline("break;");
                                         writer.endblock();
                                     }
 
index 1902bf66941e1433f454ce491c8f66124c1d8db3..80400dc0a84e4bf56aa941dd58904ebc07b96faf 100755 (executable)
@@ -10,7 +10,8 @@ public class RepairGenerator {
     PrintWrapper outputrepair = null;
     PrintWrapper outputaux = null;
     PrintWrapper outputhead = null;
-    String name="foo";
+    public static String name="foo";
+    public static String postfix="";
     String headername;
     static VarDescriptor oldmodel=null;
     static VarDescriptor newmodel=null;
@@ -66,7 +67,7 @@ public class RepairGenerator {
            if (togenerate.contains(gn))
            for (int i=0;i<mun.numUpdates();i++) {
                UpdateNode un=mun.getUpdate(i);
-               String name="update"+String.valueOf(count++);
+               String name="update"+RepairGenerator.name+String.valueOf(count++);
                updatenames.put(un,name);
            }
        }
@@ -274,7 +275,7 @@ public class RepairGenerator {
            cr.outputline(vdstate.getSafeSymbol()+"->"+vd.getSafeSymbol()+"=("+vd.getType().getGenerateType().getSafeSymbol()+")"+vd.getSafeSymbol()+";");
        }
        /* Insert repair here */
-       cr.outputline("doanalysis("+vdstate.getSafeSymbol()+");");
+       cr.outputline("doanalysis"+postfix+"("+vdstate.getSafeSymbol()+");");
        globals=state.stGlobals.descriptors();
        while (globals.hasNext()) {
            VarDescriptor vd=(VarDescriptor) globals.next();
@@ -543,8 +544,8 @@ public class RepairGenerator {
            craux.outputline("int abstractcount;");
        }
 
-       crhead.outputline("void doanalysis(struct "+name+"_state *);");
-       craux.outputline("void doanalysis(struct "+name+"_state * thisvar)");
+       crhead.outputline("void doanalysis"+postfix+"(struct "+name+"_state *);");
+       craux.outputline("void doanalysis"+postfix+"(struct "+name+"_state * thisvar)");
        craux.startblock();
        craux.outputline("int highmark;"); /* This declaration is special...need it to be first */
        craux.startBuffer();