From 2409ec48449928d85300b050d742be64e54706fb Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 13 Aug 2004 19:22:50 +0000 Subject: [PATCH] Adding the -cplusplus option. This option writes virual table pointers into allocated objects. --- Repair/RepairCompiler/MCC/CLI.java | 5 ++++- Repair/RepairCompiler/MCC/Compiler.java | 1 + Repair/RepairCompiler/MCC/IR/Sources.java | 9 ++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Repair/RepairCompiler/MCC/CLI.java b/Repair/RepairCompiler/MCC/CLI.java index 10d5d4b..28ecc29 100755 --- a/Repair/RepairCompiler/MCC/CLI.java +++ b/Repair/RepairCompiler/MCC/CLI.java @@ -11,7 +11,7 @@ import MCC.IR.DebugItem; * files. * * @author le01, 6.035 Staff (6.035-staff@mit.edu) - * @version $Id: CLI.java,v 1.10 2004/07/27 05:42:30 bdemsky Exp $ + * @version $Id: CLI.java,v 1.11 2004/08/13 19:22:23 bdemsky Exp $ */ 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++; diff --git a/Repair/RepairCompiler/MCC/Compiler.java b/Repair/RepairCompiler/MCC/Compiler.java index fc4f738..70e9749 100755 --- a/Repair/RepairCompiler/MCC/Compiler.java +++ b/Repair/RepairCompiler/MCC/Compiler.java @@ -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(); diff --git a/Repair/RepairCompiler/MCC/IR/Sources.java b/Repair/RepairCompiler/MCC/IR/Sources.java index 5d11a57..0db5228 100755 --- a/Repair/RepairCompiler/MCC/IR/Sources.java +++ b/Repair/RepairCompiler/MCC/IR/Sources.java @@ -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()+");"); } - } -- 2.34.1