Charj: fixes for compiling plain C++ classes, rather than chare types
authorAaron Becker <akbecker@gmail.com>
Thu, 20 May 2010 22:10:50 +0000 (17:10 -0500)
committerAaron Becker <akbecker@gmail.com>
Thu, 20 May 2010 22:10:50 +0000 (17:10 -0500)
src/langs/charj/src/charj/translator/Charj.stg
src/langs/charj/src/charj/translator/CharjEmitter.g
src/langs/charj/src/charj/translator/Translator.java

index 2710848a3bf45d9d3f9a087c54dbc1185fb8966b..bb21a6e78618c00f4f4945508d78937411fa0415 100644 (file)
@@ -84,12 +84,15 @@ interfaceExtends(ts) ::=
 classDeclaration_h(ident, ext, csds) ::=
 <<
 <if(debug)>/* \<typeDeclaration> */<endif>
+<if(ext)>
+class <ident>: public <ext> {
+<else>
+class <ident> {
+<endif>
 
-#include "<ident>.decl.h"
-/* superclass: <ext> */
-class <ident>: public CBase_<ident> {
     <csds; separator="\n">
 };
+
 <if(debug)>/* \</typeDeclaration> */<endif>
 
 >>
@@ -97,7 +100,20 @@ class <ident>: public CBase_<ident> {
 classDeclaration_cc(ident, ext, csds) ::=
 <<
 <if(debug)>/* \<typeDeclaration> */<endif>
+<if(ext)>
+class <ident>: public <ext> {
+<else>
+class <ident> {
+<endif>
+
+    <csds; separator="\n">
+};
+<if(debug)>/* \</typeDeclaration> */<endif>
+
+>>
 
+chareDeclaration_cc(ident, ext, csds) ::=
+<<
 
 #include "<ident>.decl.h"
 /* superclass: <ext> */
@@ -105,12 +121,18 @@ class <ident>: public CBase_<ident> {
     <csds; separator="\n">
 };
 #include "<ident>.def.h"
-<if(debug)>/* \</typeDeclaration> */<endif>
-
 >>
 
+chareDeclaration_h(ident, ext, csds) ::=
+<<
+#include "<ident>.decl.h"
+/* superclass: <ext> */
+class <ident>: public CBase_<ident> {
+    <csds; separator="\n">
+};
+>>
 
-charedeclaration_ci(chareType, arrayDim, ident, ext, csds) ::=
+chareDeclaration_ci(chareType, arrayDim, ident, ext, csds) ::=
 <<
 <if(debug)>/* \<typeDeclaration> */<endif>
 module <ident> {
index da06b69a72dfc9daa15504abe70a767cbcd5039c..c313e26c5a4a540567584b0d75057d9347a93bed 100644 (file)
@@ -151,23 +151,23 @@ typeDeclaration
     |   ^('enum' IDENT (^('implements' type+))? classScopeDeclaration*)
         -> template(t={$text}) "/*ENUM-not implemented*/ <t>"
     |   ^(chareType IDENT (^('extends' type))? (^('implements' type+))? classScopeDeclaration*)
-        -> {emitCC()}? classDeclaration_cc(
+        -> {emitCC()}? chareDeclaration_cc(
                 ident={$IDENT.text}, 
                 ext={$su.st}, 
                 csds={$csds})
-        -> {emitCI()}? charedeclaration_ci(
+        -> {emitCI()}? chareDeclaration_ci(
                 chareType={$chareType.st},
                 arrayDim={null},
                 ident={$IDENT.text}, 
                 ext={$su.st}, 
                 csds={$csds})
-        -> {emitH()}? classDeclaration_h(
+        -> {emitH()}? chareDeclaration_h(
                 ident={$IDENT.text}, 
                 ext={$su.st}, 
                 csds={$csds})
         ->
     |   ^('chare_array' ARRAY_DIMENSION IDENT (^('extends' type))? (^('implements' type+))? classScopeDeclaration*)
-        -> {emitCI()}? charedeclaration_ci(
+        -> {emitCI()}? chareDeclaration_ci(
                 chareType={"array"},
                 arrayDim={$ARRAY_DIMENSION.text.toUpperCase()},
                 ident={$IDENT.text}, 
index 63fa066a1d40c0e70031d857de15cd378678e01f..aab526ae0bdb84968b5c64fe971ed2aec8288489 100644 (file)
@@ -294,10 +294,16 @@ public class Translator {
 
         // Move decl.h and def.h into temp directory.
         // charmxi/charmc doesn't offer control over where to generate these
+        cmd = "touch " + moduleName + ".decl.h " + moduleName + ".def.h";
+        retVal = exec(cmd, currentDir);
+        if (retVal != 0) {
+            error("Could not touch .decl.h and .def.h files ");
+            return;
+        }
         cmd = "mv " + moduleName + ".decl.h " + moduleName + ".def.h " +
             tempDirectory;
         retVal = exec(cmd, currentDir);
-         if (retVal != 0) {
+        if (retVal != 0) {
             error("Could not move .decl.h and .def.h files " +
                     "into temp directory");
             return;