fixed rcu
[cdsspec-compiler.git] / src / edu / uci / eecs / specCompiler / codeGenerator / CodeGenerator.java
index e68c27d666f4fd29d3c4ebdf90e0ebd71df254c4..84ba735ada5970d527349bbaa3fb703a3ecc4af4 100644 (file)
@@ -17,6 +17,7 @@ import edu.uci.eecs.specCompiler.specExtraction.ClassEndConstruct;
 import edu.uci.eecs.specCompiler.specExtraction.ConditionalInterface;
 import edu.uci.eecs.specCompiler.specExtraction.Construct;
 import edu.uci.eecs.specCompiler.specExtraction.EntryPointConstruct;
+import edu.uci.eecs.specCompiler.specExtraction.FunctionHeader;
 import edu.uci.eecs.specCompiler.specExtraction.GlobalConstruct;
 import edu.uci.eecs.specCompiler.specExtraction.IDExtractor;
 import edu.uci.eecs.specCompiler.specExtraction.InterfaceConstruct;
@@ -121,10 +122,12 @@ public class CodeGenerator {
                                                new ArrayList<CodeAddition>());
                        }
                        codeAdditions.get(defineConstruct.file).add(addition);
-               } else { // No declaration needed
+               } else { // No declaration needed but should add forward declaration
                        // Last generate the definition
-                       newCode = CodeVariables.generateInterfaceWrapperDefinition(
-                                       _semantics, construct);
+                       newCode = new ArrayList<String>();
+                       newCode.addAll(CodeVariables.generateInterfaceWrapperDeclaration(_semantics, construct));
+                       newCode.addAll(CodeVariables.generateInterfaceWrapperDefinition(
+                                       _semantics, construct));
                        lineNum = construct.beginLineNum;
                        // Add the wrapper declaration
                        addition = new CodeAddition(lineNum, newCode);
@@ -234,7 +237,7 @@ public class CodeGenerator {
                }
                for (File file : codeAdditions.keySet()) {
                        ArrayList<CodeAddition> additions = codeAdditions.get(file);
-                       
+
                        if (additions.size() == 0) // Simply do nothing
                                continue;
                        ArrayList<String> content = _semantics.srcFilesInfo.get(file).content;
@@ -242,7 +245,8 @@ public class CodeGenerator {
                        // Insert generated annotation to the source files
                        ArrayList<String> newContent = insertAnnotation2Src(additions,
                                        content);
-                       ArrayList<String> finalContent = new ArrayList<String>(headerCode.size() + newContent.size());
+                       ArrayList<String> finalContent = new ArrayList<String>(
+                                       headerCode.size() + newContent.size());
                        finalContent.addAll(headerCode);
                        finalContent.addAll(newContent);
                        // Write it back to file
@@ -254,16 +258,16 @@ 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/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") };
                CodeGenerator gen = new CodeGenerator(srcFiles);
                gen.generateCode();