Adding the -cplusplus option. This option writes virual table pointers into allocate...
authorbdemsky <bdemsky>
Fri, 13 Aug 2004 19:22:50 +0000 (19:22 +0000)
committerbdemsky <bdemsky>
Fri, 13 Aug 2004 19:22:50 +0000 (19:22 +0000)
Repair/RepairCompiler/MCC/CLI.java
Repair/RepairCompiler/MCC/Compiler.java
Repair/RepairCompiler/MCC/IR/Sources.java

index 10d5d4b4c92cce25a6f1e38c1a87b867990cd079..28ecc2973c0ff7bf06b2a02693e60ec2521e1c4e 100755 (executable)
@@ -11,7 +11,7 @@ import MCC.IR.DebugItem;
  * files.
  *
  * @author  le01, 6.035 Staff (<tt>6.035-staff@mit.edu</tt>)
  * files.
  *
  * @author  le01, 6.035 Staff (<tt>6.035-staff@mit.edu</tt>)
- * @version <tt>$Id: CLI.java,v 1.10 2004/07/27 05:42:30 bdemsky Exp $</tt>
+ * @version <tt>$Id: CLI.java,v 1.11 2004/08/13 19:22:23 bdemsky Exp $</tt>
  */
 public class CLI {
     /**
  */
 public class CLI {
     /**
@@ -105,6 +105,7 @@ public class CLI {
            System.out.println("-instrument -- generate instrumentation code");
            System.out.println("-aggressivesearch");
            System.out.println("-prunequantifiernodes");
            System.out.println("-instrument -- generate instrumentation code");
            System.out.println("-aggressivesearch");
            System.out.println("-prunequantifiernodes");
+           System.out.println("-cplusplus");
            System.exit(-1);
        }
 
            System.exit(-1);
        }
 
@@ -128,6 +129,8 @@ public class CLI {
                 Compiler.AGGRESSIVESEARCH=true;
            } else if (args[i].equals("-prunequantifiernodes")) {
                 Compiler.PRUNEQUANTIFIERS=true;
                 Compiler.AGGRESSIVESEARCH=true;
            } else if (args[i].equals("-prunequantifiernodes")) {
                 Compiler.PRUNEQUANTIFIERS=true;
+           } else if (args[i].equals("-cplusplus")) {
+                Compiler.ALLOCATECPLUSPLUS=true;
             } else if (args[i].equals("-verbose") || args[i].equals("-v")) {
                 context = 0;
                 verbose++;
             } else if (args[i].equals("-verbose") || args[i].equals("-v")) {
                 context = 0;
                 verbose++;
index fc4f7382a5de0a4ba7363b20ffc3314818e6c9d1..70e9749e07185d574c16f2314ff071cf58981bb4 100755 (executable)
@@ -24,6 +24,7 @@ public class Compiler {
     public static boolean GENERATEDEBUGHOOKS=false;
     public static boolean GENERATEDEBUGPRINT=false;
     public static boolean GENERATEINSTRUMENT=false;
     public static boolean GENERATEDEBUGHOOKS=false;
     public static boolean GENERATEDEBUGPRINT=false;
     public static boolean GENERATEINSTRUMENT=false;
+    public static boolean ALLOCATECPLUSPLUS=false;
     
     public static Vector debuggraphs=new Vector();
 
     
     public static Vector debuggraphs=new Vector();
 
index 5d11a57d090ddccccd2ce10f2a057555fd1ddfbf..0db5228d4dca81699a9b731aa5412e9cdb9d716a 100755 (executable)
@@ -1,6 +1,7 @@
 package MCC.IR;
 
 import MCC.State;
 package MCC.IR;
 
 import MCC.State;
+import MCC.Compiler;
 
 public class Sources {
     State state;
 
 public class Sources {
     State state;
@@ -43,6 +44,13 @@ public class Sources {
        e.generate(cr, size);
        cr.popSymbolTable();
        cr.outputline(td.getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"=("+td.getGenerateType().getSafeSymbol()+") malloc("+size.getSafeSymbol()+");");
        e.generate(cr, size);
        cr.popSymbolTable();
        cr.outputline(td.getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"=("+td.getGenerateType().getSafeSymbol()+") malloc("+size.getSafeSymbol()+");");
+       
+       if (Compiler.ALLOCATECPLUSPLUS) {
+           String vtable="_ZTV";
+           vtable+=sd.getType().getSafeSymbol().length();
+           vtable+=sd.getType().getSafeSymbol();
+           cr.outputline("((int**)"+vd.getSafeSymbol()+")[0] = (int *)"+vtable+"+2;");
+       }
     }
 
     public boolean relsetSource(RelationDescriptor rd, boolean domain) {
     }
 
     public boolean relsetSource(RelationDescriptor rd, boolean domain) {
@@ -75,5 +83,4 @@ public class Sources {
        cr.popSymbolTable();
        cr.outputline(td.getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"=("+td.getGenerateType().getSafeSymbol()+") malloc("+size.getSafeSymbol()+");");
     }
        cr.popSymbolTable();
        cr.outputline(td.getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"=("+td.getGenerateType().getSafeSymbol()+") malloc("+size.getSafeSymbol()+");");
     }
-
 }
 }