X-Git-Url: http://plrg.eecs.uci.edu/git/?p=repair.git;a=blobdiff_plain;f=Repair%2FRepairCompiler%2FMCC%2FCompiler.java;h=9ecf6a653a6e40209b1e04f5cc0ed30b898fbe6a;hp=ad98137f3611e38fa7e0f4e8e4db01d4bac5f307;hb=860ccbdf9cd6f96c6bba58641372b6776987a080;hpb=0ddd66cf596f161886dc67214f3fb2e19f6f7168 diff --git a/Repair/RepairCompiler/MCC/Compiler.java b/Repair/RepairCompiler/MCC/Compiler.java index ad98137..9ecf6a6 100755 --- a/Repair/RepairCompiler/MCC/Compiler.java +++ b/Repair/RepairCompiler/MCC/Compiler.java @@ -17,8 +17,11 @@ import MCC.IR.*; */ public class Compiler { - public static boolean REPAIR=false; - + /* 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 void main(String[] args) { State state = null; boolean success = true; @@ -38,107 +41,78 @@ 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."); - - /* Check partition constraints */ - (new ImplicitSchema(state)).update(); - - if (REPAIR) { - 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"); - - // do model optimizations - //(new Optimizer(state)).optimize(); - - NaiveGenerator ng = new NaiveGenerator(state); - ng.generate(gcode); - //WorklistGenerator wg = new WorklistGenerator(state); - //wg.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#"); - } - } 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."); + + + 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) { @@ -146,31 +120,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]) { @@ -237,6 +186,7 @@ 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) { @@ -254,6 +204,7 @@ 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) { @@ -271,14 +222,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; } @@ -288,6 +240,7 @@ 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) {