Change to the spec...missed a consistency property. Adding timing option.
[repair.git] / Repair / RepairCompiler / MCC / Compiler.java
index 05c60339cc176a91cfa1cfc4eaa4ffb7d4983dbe..04ad0bad552606b1f42f608d689d717009a34272 100755 (executable)
@@ -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,119 +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.");
-
-
-           Termination termination=null;
-           if (REPAIR) {
-               /* 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();
-
-
-               if(REPAIR) {
-                   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);
+       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#");
-           }
-       } 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#");
-           }
-        }
+                   }*/
+           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) {
@@ -158,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]) {
@@ -249,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;
        }
 
@@ -266,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;
        }
 
@@ -283,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;
        }
 
@@ -300,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;
        }