Charj: Fix of initializers in regular class (not a chare)
authorJonathan Lifflander <jliffl2@illinois.edu>
Thu, 1 Jul 2010 03:08:36 +0000 (22:08 -0500)
committerJonathan Lifflander <jliffl2@illinois.edu>
Thu, 1 Jul 2010 03:08:36 +0000 (22:08 -0500)
src/langs/charj/src/charj/translator/Charj.stg
src/langs/charj/src/charj/translator/CharjEmitter.g

index c51530bc0f06ffa6049f4ad82dd747576a754b34..341c07b37f1d825e019f02a0dd99a6fa4e545eda 100644 (file)
@@ -156,22 +156,22 @@ class <ident> {
 <endif>
 >>
 
-templateDeclaration_h(pds, sym, ident, ext, csds, tident, hasDefaultCtor) ::=
+templateDeclaration_h(pds, sym, ident, ext, csds, tident, hasDefaultCtor, inits) ::=
 <<
 template \<class <tident; separator=", class ">\>
-<classDeclaration_h_cont(pds=pds, sym=sym, ident=ident, ext=ext, csds=csds, hasDefaultCtor=hasDefaultCtor)>
+<classDeclaration_h_cont(pds=pds, sym=sym, ident=ident, ext=ext, csds=csds, hasDefaultCtor=hasDefaultCtor, inits=inits)>
 >>
 
-classDeclaration_cc(sym, ident, ext, csds, hasDefaultCtor) ::=
+classDeclaration_cc(sym, ident, ext, csds, hasDefaultCtor, inits) ::=
 <<
-<classDeclaration_cc_cont(pds = sym.packageNames, sym = sym, ident = ident, ext = ext, csds = csds, hasDefaultCtor = hasDefaultCtor)>
+<classDeclaration_cc_cont(pds = sym.packageNames, sym = sym, ident = ident, ext = ext, csds = csds, hasDefaultCtor = hasDefaultCtor, inits = inits)>
 >>
 
-classDeclaration_cc_cont(pds, sym, ident, ext, csds, hasDefaultCtor) ::=
+classDeclaration_cc_cont(pds, sym, ident, ext, csds, hasDefaultCtor, inits) ::=
 <<
 <if(first(pds))>namespace <first(pds)>
 {
-    <classDeclaration_cc_cont(pds = rest(pds), sym = sym, ident = ident, ext = ext, csds = csds, hasDefaultCtor = hasDefaultCtor)>
+    <classDeclaration_cc_cont(pds = rest(pds), sym = sym, ident = ident, ext = ext, csds = csds, hasDefaultCtor = hasDefaultCtor, inits = inits)>
 } // namespace <first(pds)>
 <else>
 #ifdef _CHARJ_TRACE_ALL_METHODS || _CHARJ_TRACE_TRACED_METHODS
@@ -188,7 +188,7 @@ classDeclaration_cc_cont(pds, sym, ident, ext, csds, hasDefaultCtor) ::=
 
 void <sym.name>::constructorHelper()
 {
-
+    <inits; separator="\n">
 }
 
 bool <sym.name>::_trace_registered = false;
index 3677451f53f30b09583219ce2a223bd10ee52c03..b21cf0181671b00bdd63482b179aa96ddbb6c1f4 100644 (file)
@@ -139,6 +139,10 @@ typeDeclaration
     :   ^(TYPE CLASS IDENT (^('extends' su=type))? (^('implements' type+))?
         {
             currentClass = (ClassSymbol)$IDENT.def;
+
+            for (VariableInitializer init : currentClass.initializers) {
+                initializers.add(init.emit());
+            }
         }
         (csds+=classScopeDeclaration)*)
         -> {emitCC()}? classDeclaration_cc(
@@ -146,7 +150,8 @@ typeDeclaration
                 ident={$IDENT.text}, 
                 ext={$su.st}, 
                 csds={$csds},
-                hasDefaultCtor={currentClass.hasDefaultConstructor})
+                hasDefaultCtor={currentClass.hasDefaultConstructor},
+                inits={initializers})
         -> {emitH()}?  classDeclaration_h(
                 sym={currentClass},
                 ident={$IDENT.text},