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 10d5d4b..28ecc29 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.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 {
     /**
@@ -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("-cplusplus");
            System.exit(-1);
        }
 
@@ -128,6 +129,8 @@ public class CLI {
                 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++;
index fc4f738..70e9749 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 ALLOCATECPLUSPLUS=false;
     
     public static Vector debuggraphs=new Vector();
 
index 5d11a57..0db5228 100755 (executable)
@@ -1,6 +1,7 @@
 package MCC.IR;
 
 import MCC.State;
+import MCC.Compiler;
 
 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()+");");
+       
+       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) {
@@ -75,5 +83,4 @@ public class Sources {
        cr.popSymbolTable();
        cr.outputline(td.getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"=("+td.getGenerateType().getSafeSymbol()+") malloc("+size.getSafeSymbol()+");");
     }
-
 }