X-Git-Url: http://plrg.eecs.uci.edu/git/?p=repair.git;a=blobdiff_plain;f=Repair%2FRepairCompiler%2FMCC%2FCompiler.java;h=04ad0bad552606b1f42f608d689d717009a34272;hp=ebda670ebd356603137db75373233fba87bd4b85;hb=fcb08dbb9564da3732dd8b0cbf0088d0f9826541;hpb=cc8dc64af87942be304d8d599dd3779002a2c645 diff --git a/Repair/RepairCompiler/MCC/Compiler.java b/Repair/RepairCompiler/MCC/Compiler.java index ebda670..04ad0ba 100755 --- a/Repair/RepairCompiler/MCC/Compiler.java +++ b/Repair/RepairCompiler/MCC/Compiler.java @@ -17,8 +17,18 @@ import MCC.IR.*; */ public class Compiler { + /* Set this flag to false to turn repairs off */ public static boolean REPAIR=true; + public static boolean AGGRESSIVESEARCH=false; + public static boolean PRUNEQUANTIFIERS=false; + public static boolean GENERATEDEBUGHOOKS=false; + public static boolean GENERATEDEBUGPRINT=false; + public static boolean GENERATEINSTRUMENT=false; + public static boolean ALLOCATECPLUSPLUS=false; + public static boolean TIME=false; + public static Vector debuggraphs=new Vector(); + public static void main(String[] args) { State state = null; boolean success = true; @@ -38,110 +48,79 @@ public class Compiler { * specified at command line */ - System.out.println("\nMCC v0.0.1 - MIT LCS (Author: Daniel Roy, Brian Demsky)"); + System.out.println("MCC v0.0.1 - MIT LCS (Author: Daniel Roy, Brian Demsky)\n"); if (cli.infile == null) { System.err.println("\nError: no input file specified"); System.exit(-1); } - if (cli.target == CLI.ASSEMBLY || cli.target == CLI.DEFAULT) { - if (state.debug) { - System.out.println("Compiling " + cli.infile + "."); - } - - success = scan(state) || error(state, "Scanning failed, not attempting to parse."); - success = parse(state) || error(state, "Parsing failed, not attempting semantic analysis."); - success = semantics(state) || error(state, "Semantic analysis failed, not attempting variable initialization."); - - - - if (REPAIR) { - /* Check partition constraints */ - (new ImplicitSchema(state)).update(); - Termination t=new Termination(state); - } - state.printall(); - (new DependencyBuilder(state)).calculate(); - - try { - Vector nodes = new Vector(state.constraintnodes.values()); - nodes.addAll(state.rulenodes.values()); - - FileOutputStream dotfile; - dotfile = new FileOutputStream(cli.infile + ".dependencies.edgelabels.dot"); - GraphNode.useEdgeLabels = true; - GraphNode.DOTVisitor.visit(dotfile, nodes); - dotfile.close(); - - dotfile = new FileOutputStream(cli.infile + ".dependencies.dot"); - GraphNode.useEdgeLabels = false; - GraphNode.DOTVisitor.visit(dotfile, nodes); - dotfile.close(); - } catch (Exception e) { - e.printStackTrace(); - System.exit(-1); - } - - try { - FileOutputStream gcode = new FileOutputStream(cli.infile + ".cc"); - FileOutputStream gcode2 = new FileOutputStream(cli.infile + "_aux.cc"); - FileOutputStream gcode3 = new FileOutputStream(cli.infile + "_aux.h"); - - // do model optimizations - //(new Optimizer(state)).optimize(); - - //NaiveGenerator ng = new NaiveGenerator(state); - //ng.generate(gcode); - RepairGenerator wg = new RepairGenerator(state); - wg.generate(gcode,gcode2,gcode3, cli.infile + "_aux.h"); - gcode.close(); - } catch (Exception e) { - e.printStackTrace(); - System.exit(-1); - } - - if (state.debug) { - System.out.println("Compilation of " + state.infile + " successful."); - System.out.println("#SUCCESS#"); - } - } else if (cli.target == CLI.INTER) { - if (state.debug) { - System.out.println("Semantic analysis for " + cli.infile + "."); - } - - success = scan(state) || error(state, "Scanning failed, not attempting to parse."); - success = parse(state) || error(state, "Parsing failed, not attempting semantic analysis."); - success = semantics(state) || error(state, "Semantic analysis failed."); - - if (state.debug) { - System.out.println("Semantic analysis of " + state.infile + " successful."); - System.out.println("#SUCCESS#"); - } - } else if (cli.target == CLI.PARSE) { - if (state.debug) { - System.out.println("Parsing " + cli.infile + "."); - } - - success = scan(state) || error(state, "Scanning failed, not attempting to parse."); - success = parse(state) || error(state, "Parsing failed."); - - if (state.debug) { - System.out.println("Parsing of " + state.infile + " successful."); - System.out.println("#SUCCESS#"); - } - } else if (cli.target == CLI.SCAN) { - if (state.debug) { - System.out.println("Scanning " + cli.infile + "."); - } - - success = scan(state) || error(state, "Scanning failed."); - - if (state.debug) { - System.out.println("Scanning of " + state.infile + " successful."); - System.out.println("#SUCCESS#"); - } - } + if (state.debug) { + System.out.println("Compiling " + cli.infile + "."); + } + + success = scan(state) || error(state, "Scanning failed, not attempting to parse."); + success = parse(state) || error(state, "Parsing failed, not attempting semantic analysis."); + success = semantics(state) || error(state, "Semantic analysis failed, not attempting variable initialization."); + + + state.setanalysis=new SetAnalysis(state); + Termination termination=null; + /* Check partition constraints */ + (new ImplicitSchema(state)).update(); + termination=new Termination(state); + + state.printall(); + (new DependencyBuilder(state)).calculate(); + + try { + Vector nodes = new Vector(state.constraintnodes.values()); + nodes.addAll(state.rulenodes.values()); + + FileOutputStream dotfile; + dotfile = new FileOutputStream(cli.infile + ".dependencies.edgelabels.dot"); + GraphNode.useEdgeLabels = true; + GraphNode.DOTVisitor.visit(dotfile, nodes); + dotfile.close(); + + dotfile = new FileOutputStream(cli.infile + ".dependencies.dot"); + GraphNode.useEdgeLabels = false; + GraphNode.DOTVisitor.visit(dotfile, nodes); + dotfile.close(); + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + + try { + FileOutputStream gcode = new FileOutputStream(cli.infile + ".cc"); + + + // do model optimizations + //(new Optimizer(state)).optimize(); + + FileOutputStream gcode2 = new FileOutputStream(cli.infile + "_aux.cc"); + FileOutputStream gcode3 = new FileOutputStream(cli.infile + "_aux.h"); + RepairGenerator wg = new RepairGenerator(state,termination); + wg.generate(gcode,gcode2,gcode3, cli.infile + "_aux.h"); + gcode2.close(); + gcode3.close(); + /* } else { + WorklistGenerator ng = new WorklistGenerator(state); + SetInclusion.worklist=true; + RelationInclusion.worklist=true; + ng.generate(gcode); + }*/ + gcode.close(); + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + + if (state.debug) { + System.out.println("Compilation of " + state.infile + " successful."); + System.out.println("#SUCCESS#"); + } } private static void printArgInfo(CLI cli) { @@ -149,31 +128,6 @@ public class Compiler { System.out.println("Printing debugging information..."); System.out.println("Input filename: " + cli.infile); System.out.println("Output filename: " + cli.outfile); - System.out.print("Target: "); - - switch(cli.target) { - case CLI.ASSEMBLY: - System.out.println("ASSEMBLY"); - break; - case CLI.DEFAULT: - System.out.println("DEFAULT"); - break; - case CLI.INTER: - System.out.println("INTER"); - break; - case CLI.LOWIR: - System.out.println("LOWIR"); - break; - case CLI.PARSE: - System.out.println("PARSE"); - break; - case CLI.SCAN: - System.out.println("SCAN"); - break; - default: - System.out.println("not recognized"); - break; - } for (int i = 0; i < cli.opts.length; i++) { if (cli.opts[i]) { @@ -240,14 +194,15 @@ public class Compiler { LineCount.reset(); FileInputStream infile = new FileInputStream(state.infile + ".struct"); TDLParser parser = new TDLParser(new Lexer(infile)); + parser.filename = state.infile + ".struct"; CUP$TDLParser$actions.debug = state.verbose > 1 ; state.ptStructures = (ParseNode) parser.parse().value; } catch (FileNotFoundException fnfe) { System.err.println("Unable to open file: " + state.infile + ".struct"); System.exit(-1); } catch (Exception e) { - // System.out.println(e); - // e.printStackTrace(); + System.out.println(e); + e.printStackTrace(); return false; } @@ -257,14 +212,15 @@ public class Compiler { LineCount.reset(); FileInputStream infile = new FileInputStream(state.infile + ".model"); MDLParser parser = new MDLParser(new Lexer(infile)); + parser.filename = state.infile + ".model"; CUP$MDLParser$actions.debug = state.verbose > 1 ; state.ptModel = (ParseNode) parser.parse().value; } catch (FileNotFoundException fnfe) { System.err.println("Unable to open file: " + state.infile + ".model"); System.exit(-1); } catch (Exception e) { - // System.out.println(e); - // e.printStackTrace(); + System.out.println(e); + e.printStackTrace(); return false; } @@ -274,14 +230,15 @@ public class Compiler { LineCount.reset(); FileInputStream infile = new FileInputStream(state.infile + ".space"); SDLParser parser = new SDLParser(new Lexer(infile)); + parser.filename = state.infile + ".space"; CUP$SDLParser$actions.debug = state.verbose > 1 ; state.ptSpace = (ParseNode) parser.parse().value; } catch (FileNotFoundException fnfe) { System.err.println("Unable to open file: " + state.infile + ".space"); System.exit(-1); } catch (Exception e) { - // System.out.println(e); - // e.printStackTrace(); + System.out.println(e); + e.printStackTrace(); return false; } @@ -291,14 +248,15 @@ public class Compiler { LineCount.reset(); FileInputStream infile = new FileInputStream(state.infile + ".constraints"); CDLParser parser = new CDLParser(new Lexer(infile)); + parser.filename = state.infile + ".constraints"; CUP$CDLParser$actions.debug = state.verbose > 1 ; state.ptConstraints = (ParseNode) parser.parse().value; } catch (FileNotFoundException fnfe) { System.err.println("Unable to open file: " + state.infile + ".constraints"); System.exit(-1); } catch (Exception e) { - // System.out.println(e); - // e.printStackTrace(); + System.out.println(e); + e.printStackTrace(); return false; }