make code look better
authorPeizhao Ou <peizhaoo@uci.edu>
Mon, 17 Mar 2014 19:55:29 +0000 (12:55 -0700)
committerPeizhao Ou <peizhaoo@uci.edu>
Mon, 17 Mar 2014 19:55:29 +0000 (12:55 -0700)
src/edu/uci/eecs/specCompiler/codeGenerator/CodeGenerator.java

index 9ebfe2704e094597a671ff3455c16864ed18404d..93dae994a61539f741c9b1aa0bab5c511db11bdd 100644 (file)
@@ -46,6 +46,7 @@ public class CodeGenerator {
        private HashMap<File, SourceFileInfo> srcFilesInfo;
 
        private HashMap<File, ArrayList<CodeAddition>> codeAdditions;
+       private String homeDir;
 
        public CodeGenerator(File[] srcFiles) {
                this.srcFiles = srcFiles;
@@ -184,19 +185,17 @@ public class CodeGenerator {
        }
 
        /**
-       private void ClassEnd2Code(ClassEndConstruct construct) {
-               int lineNum = construct.beginLineNum;
-               ArrayList<String> newCode = CodeVariables.generateStaticVarDefine(_semantics,
-                               _semantics.getGlobalConstruct());
+        * private void ClassEnd2Code(ClassEndConstruct construct) { int lineNum =
+        * construct.beginLineNum; ArrayList<String> newCode =
+        * CodeVariables.generateStaticVarDefine(_semantics,
+        * _semantics.getGlobalConstruct());
+        * 
+        * CodeAddition addition = new CodeAddition(lineNum, newCode); if
+        * (!codeAdditions.containsKey(construct.file)) {
+        * codeAdditions.put(construct.file, new ArrayList<CodeAddition>()); }
+        * codeAdditions.get(construct.file).add(addition); }
+        */
 
-               CodeAddition addition = new CodeAddition(lineNum, newCode);
-               if (!codeAdditions.containsKey(construct.file)) {
-                       codeAdditions.put(construct.file, new ArrayList<CodeAddition>());
-               }
-               codeAdditions.get(construct.file).add(addition);
-       }
-       */
-       
        private void EntryPoint2Code(EntryPointConstruct construct) {
                int lineNum = construct.beginLineNum;
                ArrayList<String> newCode = new ArrayList<String>();
@@ -249,10 +248,10 @@ public class CodeGenerator {
                        }
                }
 
-//             ClassEndConstruct endConstruct = _semantics.getClassEndConstruct();
-//             if (endConstruct != null) {
-//                     ClassEnd2Code(endConstruct);
-//             }
+               // ClassEndConstruct endConstruct = _semantics.getClassEndConstruct();
+               // if (endConstruct != null) {
+               // ClassEnd2Code(endConstruct);
+               // }
 
                // Sort code additions
                HashSet<String> headers = CodeVariables.getAllHeaders(_semantics);
@@ -281,38 +280,47 @@ public class CodeGenerator {
 
        public static void main(String[] argvs) {
                String homeDir = Environment.HOME_DIRECTORY;
-               File[] srcFiles = {
-//                              new File(homeDir
-//                              + "/benchmark/linuxrwlocks/linuxrwlocks.c") };
-//                              new File(homeDir
-//                              +
-//                              "/benchmark/cliffc-hashtable/simplified_cliffc_hashtable.h"),
-//                              };
-//                              new File(homeDir + "/benchmark/ms-queue/my_queue.c"),
-//                              new File(homeDir + "/benchmark/ms-queue/main.c"),
-//                              new File(homeDir + "/benchmark/ms-queue/my_queue.h") };
-
-                                new File(homeDir + "/benchmark/read-copy-update/rcu.cc") };
-
-//                              new File(homeDir +
-//                              "/benchmark/chase-lev-deque-bugfix/deque.c"),
-//                              new File(homeDir +
-//                              "/benchmark/chase-lev-deque-bugfix/main.c"),
-//                              new File(homeDir +
-//                              "/benchmark/chase-lev-deque-bugfix/deque.h") };
-
-//                             new File(homeDir + "/benchmark/mcs-lock/mcs-lock.cc"),
-//                             new File(homeDir + "/benchmark/mcs-lock/mcs-lock.h") };
-               
-//                             new File(homeDir + "/benchmark/spsc-bugfix/spsc-queue.cc"),
-//                             new File(homeDir + "/benchmark/spsc-bugfix/eventcount.h"),
-//                             new File(homeDir + "/benchmark/spsc-bugfix/queue.h") };
-               
-//             new File(homeDir + "/benchmark/mpmc-queue/mpmc-queue.h"),
-//             new File(homeDir + "/benchmark/mpmc-queue/mpmc-queue.cc") };
-               
-
-               CodeGenerator gen = new CodeGenerator(srcFiles);
-               gen.generateCode();
+
+               File[] srcLinuxRWLocks = { new File(homeDir
+                               + "/benchmark/linuxrwlocks/linuxrwlocks.c") };
+
+               File[] srcHashtable = { new File(homeDir
+                               + "/benchmark/cliffc-hashtable/simplified_cliffc_hashtable.h") };
+
+               File[] srcMSQueue = {
+                               new File(homeDir + "/benchmark/ms-queue/my_queue.c"),
+                               new File(homeDir + "/benchmark/ms-queue/main.c"),
+                               new File(homeDir + "/benchmark/ms-queue/my_queue.h") };
+
+               File[] srcRCU = { new File(homeDir
+                               + "/benchmark/read-copy-update/rcu.cc") };
+
+               File[] srcDeque = {
+                               new File(homeDir + "/benchmark/chase-lev-deque-bugfix/deque.c"),
+                               new File(homeDir + "/benchmark/chase-lev-deque-bugfix/main.c"),
+                               new File(homeDir + "/benchmark/chase-lev-deque-bugfix/deque.h") };
+
+               File[] srcMCSLock = {
+                               new File(homeDir + "/benchmark/mcs-lock/mcs-lock.cc"),
+                               new File(homeDir + "/benchmark/mcs-lock/mcs-lock.h") };
+
+               File[] srcSPSCQueue = {
+                               new File(homeDir + "/benchmark/spsc-bugfix/spsc-queue.cc"),
+                               new File(homeDir + "/benchmark/spsc-bugfix/eventcount.h"),
+                               new File(homeDir + "/benchmark/spsc-bugfix/queue.h") };
+
+               File[] srcMPMCQueue = {
+                               new File(homeDir + "/benchmark/mpmc-queue/mpmc-queue.h"),
+                               new File(homeDir + "/benchmark/mpmc-queue/mpmc-queue.cc") };
+
+//             File[][] sources = { srcLinuxRWLocks, srcHashtable, srcMSQueue, srcRCU,
+//                             srcDeque, srcMCSLock, srcSPSCQueue, srcMPMCQueue };
+
+                File[][] sources = { srcLinuxRWLocks };
+               // Compile all the benchmarks
+               for (int i = 0; i < sources.length; i++) {
+                       CodeGenerator gen = new CodeGenerator(sources[i]);
+                       gen.generateCode();
+               }
        }
 }