X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=src%2Fedu%2Fuci%2Feecs%2FspecCompiler%2FcodeGenerator%2FCodeGenerator.java;h=323ca98224af29d87bd9f378bbe380a48d35684f;hb=69183e69892799fb310a328c88c55cd2c71632ce;hp=84ba735ada5970d527349bbaa3fb703a3ecc4af4;hpb=c9d0845c129ac0c7d8ced2e04677006c333b2c73;p=cdsspec-compiler.git diff --git a/src/edu/uci/eecs/specCompiler/codeGenerator/CodeGenerator.java b/src/edu/uci/eecs/specCompiler/codeGenerator/CodeGenerator.java index 84ba735..323ca98 100644 --- a/src/edu/uci/eecs/specCompiler/codeGenerator/CodeGenerator.java +++ b/src/edu/uci/eecs/specCompiler/codeGenerator/CodeGenerator.java @@ -122,10 +122,15 @@ public class CodeGenerator { new ArrayList()); } codeAdditions.get(defineConstruct.file).add(addition); - } else { // No declaration needed but should add forward declaration + } else { // No declaration needed but should add forward declaration in + // Class // Last generate the definition newCode = new ArrayList(); - newCode.addAll(CodeVariables.generateInterfaceWrapperDeclaration(_semantics, construct)); + if (_semantics.getOption("CLASS") == null) { + newCode.addAll(CodeVariables + .generateInterfaceWrapperDeclaration(_semantics, + construct)); + } newCode.addAll(CodeVariables.generateInterfaceWrapperDefinition( _semantics, construct)); lineNum = construct.beginLineNum; @@ -178,6 +183,20 @@ public class CodeGenerator { codeAdditions.get(construct.file).add(addition); } + /** + private void ClassEnd2Code(ClassEndConstruct construct) { + int lineNum = construct.beginLineNum; + ArrayList newCode = CodeVariables.generateStaticVarDefine(_semantics, + _semantics.getGlobalConstruct()); + + CodeAddition addition = new CodeAddition(lineNum, newCode); + if (!codeAdditions.containsKey(construct.file)) { + codeAdditions.put(construct.file, new ArrayList()); + } + codeAdditions.get(construct.file).add(addition); + } + */ + private void EntryPoint2Code(EntryPointConstruct construct) { int lineNum = construct.beginLineNum; ArrayList newCode = new ArrayList(); @@ -229,9 +248,15 @@ public class CodeGenerator { EntryPoint2Code((EntryPointConstruct) construct); } } + +// ClassEndConstruct endConstruct = _semantics.getClassEndConstruct(); +// if (endConstruct != null) { +// ClassEnd2Code(endConstruct); +// } + // Sort code additions HashSet headers = CodeVariables.getAllHeaders(_semantics); - ArrayList headerCode = new ArrayList(headers.size()); + ArrayList headerCode = new ArrayList(); for (String header : headers) { headerCode.add("#include " + header); } @@ -252,23 +277,41 @@ public class CodeGenerator { // Write it back to file ParserUtils.write2File(file, finalContent); } - } 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/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(); }