Merged arrays into Charj mainline.
authorJonathan Lifflander <jliffl2@illinois.edu>
Mon, 14 Jun 2010 15:44:45 +0000 (10:44 -0500)
committerJonathan Lifflander <jliffl2@illinois.edu>
Mon, 14 Jun 2010 15:44:45 +0000 (10:44 -0500)
src/langs/charj/src/charj/libs/Array.cpp [new file with mode: 0644]
src/langs/charj/src/charj/libs/Array.h [new file with mode: 0644]
src/langs/charj/src/charj/libs/Makefile [new file with mode: 0644]
src/langs/charj/src/charj/translator/Charj.g
src/langs/charj/src/charj/translator/Charj.stg
src/langs/charj/src/charj/translator/CharjEmitter.g
src/langs/charj/src/charj/translator/CharjSemantics.g
src/langs/charj/src/charj/translator/ClassSymbol.java
src/langs/charj/src/charj/translator/Translator.java
src/langs/charj/tests/unit/ArrayTest.cj [new file with mode: 0644]
src/langs/charj/tests/unit/Template.cj [new file with mode: 0644]

diff --git a/src/langs/charj/src/charj/libs/Array.cpp b/src/langs/charj/src/charj/libs/Array.cpp
new file mode 100644 (file)
index 0000000..3ed7df7
--- /dev/null
@@ -0,0 +1,65 @@
+#include "Array.h"
+#include <iostream>
+
+using namespace std;
+using namespace CharjArray;
+
+class Test {
+public: Array<int> aaa;
+  
+  Test() {
+    aaa.init(Domain<1>(Range(3)));
+  }
+
+};
+
+class ArrayTest2 {
+public: 
+  Array<int> test;
+
+  void test1() {
+    test[0] = 0;
+    int i;
+    for (i = 0; i < 10; i++) {
+      test[i] = 110;
+    }
+  }
+
+  ArrayTest2() {
+    test.init(Domain<1>(Range(10)));
+  }
+};
+
+int main(void) {
+  Range ranges[1];
+  ranges[0] = 10;
+
+  Domain<1> domain(ranges);
+
+  Array<int> arr;
+
+  arr.init(domain);
+
+  //arr[0] = 10;
+  arr[Point<1>(0)] = 10000;
+  arr[Point<1>(1)] = 20;
+  arr[Point<1>(8)] = 200;
+
+  //Array<int> aaa;
+  //aaa(Domain<1>(Range(3));
+
+  for (int i = 0; i < arr.size(); i++) {
+    cout << i << " -> " << arr[i] << endl;
+  }
+
+  cout << endl;
+
+  ArrayTest2 at;
+  at.test1();
+
+  for (int i = 0; i < at.test.size(); i++) {
+    cout << i << " -> " << at.test[i] << endl;
+  }
+
+  return 0;
+}
diff --git a/src/langs/charj/src/charj/libs/Array.h b/src/langs/charj/src/charj/libs/Array.h
new file mode 100644 (file)
index 0000000..ed3cfc9
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef ARRAY_H
+#define ARRAY_H
+
+namespace CharjArray {
+  class Range {
+  public:
+    int size, offset;
+    Range() {}
+    Range(int size_) : size(size_) {}
+  };
+
+  template<int dims>
+  class Domain {
+  public:
+    Range ranges[dims];
+    
+    Domain() {}
+
+    Domain(Range ranges_[]) {
+      for (int i = 0; i < dims; i++) 
+       ranges[i] = ranges_[i];      
+    }
+
+    Domain(Range range) {
+      ranges[0] = range;
+    }
+
+    int size() {
+      int total = 0;
+      for (int i = 0; i < dims; i++)
+       if (total == 0)
+         total = ranges[i].size;
+       else
+         total *= ranges[i].size;
+    }
+  };
+
+  template<int dims>
+  class Point : public Domain<dims> {
+  public:
+    Point(int dim) : Domain<dims>() {
+      this->ranges[0].size = dim;
+    }
+  };
+
+  enum ArrayType { RECT, JAGGED, ROW_MAJOR, COL_MAJOR };
+  template<class type, int dims = 1, int atype = RECT>
+  class Array {
+  private:
+    Domain<dims> domain;
+    type *block;
+    bool initialized;
+
+  public:
+    Array() : initialized(false) {}
+
+    void init(Domain<dims> domain_) {
+      domain = domain_;
+      if (atype == RECT)
+       block = new type[domain.size()];
+      initialized = true;
+    }
+
+    ~Array() {
+      delete block;
+    }
+    
+    type& operator[] (const Point<dims> &point) {
+      return block[point.ranges[0].size];
+      //return block[index];
+    }
+    
+    /*Array<type, dims, atype>& operator[] (const Domain<dims> &domain) {
+      
+      }*/
+
+    int size() {
+      return domain.size();
+    }
+
+  };
+}
+
+#endif
diff --git a/src/langs/charj/src/charj/libs/Makefile b/src/langs/charj/src/charj/libs/Makefile
new file mode 100644 (file)
index 0000000..c3affe0
--- /dev/null
@@ -0,0 +1,20 @@
+CPP=g++
+COPTS=-ansi -pedantic -g
+ALL=Array
+
+all: $(ALL)
+
+clobber:
+       rm -rf \#*\# *~ *.o $(ALL)
+
+Array: Array.o
+       $(CPP) $(COPTS) $^ -o $@
+
+Test: Array.o Test.o
+       $(CPP) $(COPTS) $^ -o $@
+
+Array.o: Array.cpp Array.h
+Test.o: Array.o Test.cpp
+
+.cpp.o:
+       $(CPP) $(COPTS) -c $< -o $@
index 8bd1ba11c9705a7f5f03ce5bc085907e8e231752..94e671962dcc279bec1f9f866ce21ac51745ff53 100644 (file)
@@ -165,6 +165,7 @@ tokens {
     CLASS_STATIC_INITIALIZER;
     CLASS_TOP_LEVEL_SCOPE;
     CONSTRUCTOR_DECL;
+    DOMAIN_EXPRESSION;
     ENUM_TOP_LEVEL_SCOPE;
     EXPR;
     EXTENDS_BOUND_LIST;
@@ -185,14 +186,17 @@ tokens {
     METHOD_CALL;
     ENTRY_METHOD_CALL;
     MODIFIER_LIST;
+    NEW_EXPRESSION;
     PAREN_EXPR;
     POST_DEC;
     POST_INC;
     PRE_DEC;
     PRE_INC;
     QUALIFIED_TYPE_IDENT;
+    RANGE_EXPRESSION;
     STATIC_ARRAY_CREATOR;
     SUPER_CONSTRUCTOR_CALL;
+    TEMPLATE_INST;
     THIS_CONSTRUCTOR_CALL;
     TYPE;
     SIMPLE_TYPE;
@@ -257,15 +261,24 @@ readonlyDeclaration
 
 typeDeclaration
     :   classDefinition
+    |   templateDeclaration
     |   interfaceDefinition
     |   enumDefinition
     |   chareDefinition
     ;
 
+templateList
+    : 'class'! IDENT (','! 'class'! IDENT)*
+    ;
+
+templateDeclaration
+    : 'template' '<' templateList '>' classDefinition
+        -> ^('template' templateList classDefinition)
+    ;
+
 classDefinition
     :   PUBLIC? CLASS IDENT (EXTENDS type)? ('implements' typeList)? '{'
-            classScopeDeclaration*
-        '}' ';'?
+      classScopeDeclaration* '}' ';'?
         -> ^(TYPE CLASS IDENT ^(EXTENDS type)? ^('implements' typeList)? classScopeDeclaration*)
     ;
 
@@ -313,9 +326,11 @@ typeList
 classScopeDeclaration
     :   modifierList?
         (   genericTypeParameterList?
-            (   type IDENT formalParameterList arrayDeclaratorList? (block | ';')
+            (   type IDENT formalParameterList (block | ';')
                 ->  ^(FUNCTION_METHOD_DECL modifierList? genericTypeParameterList? type IDENT
-                    formalParameterList arrayDeclaratorList? block?)
+                    formalParameterList block?)
+            /*|   'void' IDENT formalParameterList (block | ';')
+                ->  ^(VOID_METHOD_DECL modifierList? genericTypeParameterList? IDENT formalParameterList block?)*/
             |   ident=IDENT formalParameterList block
                 ->  ^(CONSTRUCTOR_DECL[$ident, "CONSTRUCTOR_DECL"] modifierList? genericTypeParameterList? IDENT
                         formalParameterList block)
@@ -330,9 +345,11 @@ classScopeDeclaration
 interfaceScopeDeclaration
     :   modifierList?
         (   genericTypeParameterList?
-            (   type IDENT formalParameterList arrayDeclaratorList? ';'
+            (   type IDENT formalParameterList ';'
                 ->  ^(FUNCTION_METHOD_DECL modifierList? genericTypeParameterList?
-                        type IDENT formalParameterList arrayDeclaratorList?)
+                        type IDENT formalParameterList)
+            /*|   'void' IDENT formalParameterList ';'
+                ->  ^(VOID_METHOD_DECL modifierList? genericTypeParameterList? IDENT formalParameterList)*/
             )
         |   simpleType interfaceFieldDeclaratorList ';'
             ->  ^(PRIMITIVE_VAR_DECLARATION modifierList? simpleType interfaceFieldDeclaratorList)
@@ -363,7 +380,7 @@ interfaceFieldDeclarator
 
 
 variableDeclaratorId
-    :   IDENT^ arrayDeclaratorList?
+    :   ^(IDENT domainExpression?)
     ;
 
 variableInitializer
@@ -371,7 +388,7 @@ variableInitializer
     |   expression
     ;
 
-arrayDeclarator
+/*arrayDeclarator
     :   '[' ']'
         ->  ARRAY_DECLARATOR
     ;
@@ -379,13 +396,29 @@ arrayDeclarator
 arrayDeclaratorList
     :   arrayDeclarator+
         ->  ^(ARRAY_DECLARATOR_LIST arrayDeclarator+)   
-    ;
+    ;*/
 
 arrayInitializer
     :   lc='{' (variableInitializer (',' variableInitializer)* ','?)? '}'
         ->  ^(ARRAY_INITIALIZER[$lc, "ARRAY_INITIALIZER"] variableInitializer*)
     ;
 
+templateArg
+    : genericTypeArgument
+    | literal
+    ;
+
+templateArgList
+    :   templateArg (','! templateArg)*
+    ;
+
+templateInstantiation
+    :    '<' templateArgList '>'
+        -> ^(TEMPLATE_INST templateArgList)
+    |    '<' templateInstantiation '>'
+        -> ^(TEMPLATE_INST templateInstantiation)
+    ;
+
 genericTypeParameterList
     :   lt='<' genericTypeParameter (',' genericTypeParameter)* genericTypeListClosing
         ->  ^(GENERIC_TYPE_PARAM_LIST[$lt, "GENERIC_TYPE_PARAM_LIST"] genericTypeParameter+)
@@ -443,23 +476,23 @@ type
     ;
 
 constructorType
-    :   qualifiedTypeIdent AT arrayDeclaratorList?
-        ->  ^(PROXY_TYPE qualifiedTypeIdent arrayDeclaratorList?)
-    |   qualifiedTypeIdent arrayDeclaratorList?
-        ->  ^(OBJECT_TYPE qualifiedTypeIdent arrayDeclaratorList?)
+    :   qualifiedTypeIdent AT domainExpression?
+        ->  ^(PROXY_TYPE qualifiedTypeIdent domainExpression?)
+    |   qualifiedTypeIdent domainExpression?
+        ->  ^(OBJECT_TYPE qualifiedTypeIdent domainExpression?)
     ;
 
 
 simpleType
-    :   primitiveType arrayDeclaratorList?
-        ->  ^(SIMPLE_TYPE primitiveType arrayDeclaratorList?)  
+    :   primitiveType domainExpression?
+        ->  ^(SIMPLE_TYPE primitiveType domainExpression?)  
     ;
 
 objectType
-    :   qualifiedTypeIdent AT arrayDeclaratorList?
-        ->  ^(PROXY_TYPE qualifiedTypeIdent arrayDeclaratorList?)
-    |   qualifiedTypeIdent arrayDeclaratorList?
-        ->  ^(POINTER_TYPE qualifiedTypeIdent arrayDeclaratorList?)
+    :   qualifiedTypeIdent AT domainExpression?
+        ->  ^(PROXY_TYPE qualifiedTypeIdent domainExpression?)
+    |   qualifiedTypeIdent domainExpression?
+        ->  ^(POINTER_TYPE qualifiedTypeIdent domainExpression?)
     ;
 
 qualifiedTypeIdent
@@ -468,7 +501,7 @@ qualifiedTypeIdent
     ;
 
 typeIdent
-    :   IDENT^ genericTypeArgumentList?
+    :   IDENT^ templateInstantiation?
     ;
 
 primitiveType
@@ -482,10 +515,10 @@ primitiveType
     |   DOUBLE
     ;
 
-genericTypeArgumentList
+/*genericTypeArgumentList
     :   lt='<' genericTypeArgument (',' genericTypeArgument)* genericTypeListClosing
         ->  ^(GENERIC_TYPE_ARG_LIST[$lt, "GENERIC_TYPE_ARG_LIST"] genericTypeArgument+)
-    ;
+    ;*/
 
 genericTypeArgument
     :   type
@@ -623,6 +656,29 @@ parenthesizedExpression
         ->  ^(PAREN_EXPR[$lp, "PAREN_EXPR"] expression)
     ;
     
+rangeItem
+    :   DECIMAL_LITERAL
+    |   IDENT
+    ;
+
+rangeExpression
+    :   rangeItem
+        -> ^(RANGE_EXPRESSION rangeItem)
+    |   rangeItem ':' rangeItem
+        -> ^(RANGE_EXPRESSION rangeItem rangeItem)
+    |   rangeItem ':' rangeItem ':' rangeItem
+        -> ^(RANGE_EXPRESSION rangeItem rangeItem rangeItem)
+    ;
+
+rangeList
+    :   rangeExpression (','! rangeExpression)*
+    ;
+
+domainExpression
+    :   '[' rangeList ']'
+        -> ^(DOMAIN_EXPRESSION rangeList)
+    ;
+
 expressionList
     :   expression (','! expression)*
     ;
@@ -754,17 +810,16 @@ postfixedExpression
     :   (   primaryExpression
             ->  primaryExpression
         )
-        // ... and than the optional things that may follow a primary
-        // expression 0 or more times.
+        // ... and than the optional things that may follow a primary expression 0 or more times.
         (   outerDot=DOT                 
             // Note: generic type arguments are only valid for method calls,
             // i.e. if there is an argument list
-            (   (   genericTypeArgumentList?  
+            (   (   templateInstantiation?  
                     IDENT
                     ->  ^($outerDot $postfixedExpression IDENT)
                 ) 
                 (   arguments
-                    ->  ^(METHOD_CALL $postfixedExpression genericTypeArgumentList? arguments)
+                    ->  ^(METHOD_CALL $postfixedExpression templateInstantiation? arguments)
                 )?
             |   THIS
                 ->  ^($outerDot $postfixedExpression THIS)
@@ -777,8 +832,8 @@ postfixedExpression
                     ->  ^(METHOD_CALL $postfixedExpression arguments)
                 )?
             )
-        |   (AT genericTypeArgumentList? IDENT arguments)
-            ->  ^(ENTRY_METHOD_CALL ^(AT $postfixedExpression IDENT) genericTypeArgumentList? arguments)
+        |   (AT templateInstantiation? IDENT arguments)
+            ->  ^(ENTRY_METHOD_CALL ^(AT $postfixedExpression IDENT) templateInstantiation? arguments)
         |   '[' expression ']'
             ->  ^(ARRAY_ELEMENT_ACCESS $postfixedExpression expression)
         )*
@@ -793,17 +848,17 @@ primaryExpression
     |   literal
     |   newExpression
     |   qualifiedIdentExpression
-    |   genericTypeArgumentList 
+    |   templateInstantiation
         (   s=SUPER
             (   arguments
-                ->  ^(SUPER_CONSTRUCTOR_CALL[$s, "SUPER_CONSTRUCTOR_CALL"] genericTypeArgumentList arguments)
+                ->  ^(SUPER_CONSTRUCTOR_CALL[$s, "SUPER_CONSTRUCTOR_CALL"] templateInstantiation arguments)
             |   IDENT arguments
-                ->  ^(METHOD_CALL ^(DOT SUPER IDENT) genericTypeArgumentList arguments)
+                ->  ^(METHOD_CALL ^(DOT SUPER IDENT) templateInstantiation arguments)
             )
         |   IDENT arguments
-            ->  ^(METHOD_CALL IDENT genericTypeArgumentList arguments)
+            ->  ^(METHOD_CALL IDENT templateInstantiation arguments)
         |   t=THIS arguments
-            ->  ^(THIS_CONSTRUCTOR_CALL[$t, "THIS_CONSTRUCTOR_CALL"] genericTypeArgumentList arguments)
+            ->  ^(THIS_CONSTRUCTOR_CALL[$t, "THIS_CONSTRUCTOR_CALL"] templateInstantiation arguments)
         )
     |   (   THIS
             ->  THIS
@@ -840,15 +895,15 @@ qualifiedIdentExpression
         (   arguments
             ->  ^(METHOD_CALL qualifiedIdentifier arguments)
         |   outerDot=DOT
-            (   genericTypeArgumentList 
+            (   templateInstantiation
                 (   s=SUPER arguments
                     ->  ^(SUPER_CONSTRUCTOR_CALL[$s, "SUPER_CONSTRUCTOR_CALL"]
-                            qualifiedIdentifier genericTypeArgumentList arguments)
+                            qualifiedIdentifier templateInstantiation arguments)
                 |   SUPER innerDot=DOT IDENT arguments
                     ->  ^(METHOD_CALL ^($innerDot ^($outerDot qualifiedIdentifier SUPER) IDENT)
-                            genericTypeArgumentList arguments)
+                            templateInstantiation arguments)
                 |   IDENT arguments
-                    ->  ^(METHOD_CALL ^($outerDot qualifiedIdentifier IDENT) genericTypeArgumentList arguments)
+                    ->  ^(METHOD_CALL ^($outerDot qualifiedIdentifier IDENT) templateInstantiation arguments)
                 )
             |   THIS
                 ->  ^($outerDot qualifiedIdentifier THIS)
@@ -860,20 +915,18 @@ qualifiedIdentExpression
 
 newExpression
     :   n=NEW
-        (   primitiveType newArrayConstruction          // new static array of primitive type elements
-            ->  ^(STATIC_ARRAY_CREATOR[$n, "STATIC_ARRAY_CREATOR"] primitiveType newArrayConstruction)
-        |   genericTypeArgumentList? qualifiedTypeIdent
-                newArrayConstruction                // new static array of object type reference elements
-            ->  ^(STATIC_ARRAY_CREATOR[$n, "STATIC_ARRAY_CREATOR"] genericTypeArgumentList? qualifiedTypeIdent newArrayConstruction)
+        (
+            domainExpression arguments?
+            ->  ^(NEW_EXPRESSION arguments? domainExpression)
         |   constructorType arguments
             -> ^(NEW constructorType arguments)
         )
     ;
     
-newArrayConstruction
+/*newArrayConstruction
     :   arrayDeclaratorList arrayInitializer
     |   '['! expression ']'! ('['! expression ']'!)* arrayDeclaratorList?
-    ;
+    ;*/
 
 arguments
     :   lp='(' expressionList? ')'
index 324f8775cf1dd3db75e55b95194fbe7c68f96977..25178534a77f0df1db66058d9d90dc70227d2432 100644 (file)
@@ -121,10 +121,14 @@ chare_epilogue_h(sym) ::=
 <type_epilogue_h(sym)>
 >>
 
-classDeclaration_h(sym, ident, ext, csds) ::=
+classDeclaration_h(sym, ident, ext, csds, tident) ::=
 <<
 <type_preamble_h(sym)>
+<if(tident)>
+<templateDeclaration_h_cont(pds = sym.packageNames, sym = sym, ident = ident, ext = ext, csds = csds, tident = tident)>
+<else>
 <classDeclaration_h_cont(pds = sym.packageNames, sym = sym, ident = ident, ext = ext, csds = csds)>
+<endif>
 <type_epilogue_h(sym)>
 >>
 
@@ -146,6 +150,11 @@ class <ident> {
 <endif>
 >>
 
+templateDeclaration_h(pds, sym, ident, ext, csds, tident) ::=
+<<
+template \<class <tident; separator=", class ">\>
+<classDeclaration_h_cont(pds=pds, sym=sym, ident=ident, ext=ext, csds=csds)>
+>>
 
 classDeclaration_cc(sym, ident, ext, csds) ::=
 <<
@@ -311,9 +320,9 @@ var_decl_ci(id, initializer) ::=
 <id><if(initializer)> = <initializer><endif>
 >>
 
-var_decl_id(id, array_decl_list) ::=
+var_decl_id(id, domainExp) ::=
 <<
-<id><if(array_decl_list)> <array_decl_list><endif>
+<id><if(domainExp)>(<domainExp>)<endif>
 >>
 
 
@@ -338,12 +347,13 @@ mod_list_ci(accmods, localmods, charjmods, othermods) ::=
 <if(charjmods)><charjmods; separator=" "> <endif>
 >>
 
-local_var_decl(modList, type, declList) ::=
+local_var_decl(modList, type, declList, domainExps) ::=
 <<
 <if(modList)><modList> <endif><type> <declList>;
 >>
 
-local_mod_list(mods) ::= <<
+local_mod_list(mods) ::= 
+<<
 <mods; separator=" ">
 >>
 
@@ -504,3 +514,10 @@ exitall() ::=
 CkExit();
 >>
 
+range_constructor(range, others, len) ::=
+<<
+<if(range)>
+Domain\<<len>\>(<range>)<if(others)>, <others; separator=", "><endif>
+<else>
+<endif>
+>>
index 8de9fc6d6c8aff8bbd6ae133683e750139e75d82..e680c7d00a36ae5c2f8cd93e2393e64c128344d4 100644 (file)
@@ -148,6 +148,13 @@ typeDeclaration
                 ext={$su.st}, 
                 csds={$csds})
         ->
+    |   ^('template' (i0+=IDENT*) ^('class' i1=IDENT (^('extends' su=type))? (^('implements' type+))? (csds+=classScopeDeclaration)*))
+        -> {emitH()}? templateDeclaration_h(
+            tident={$i0},
+            ident={$i1.text},
+            ext={$su.st},
+            csds={$csds})
+        -> 
     |   ^(INTERFACE IDENT (^('extends' type+))? interfaceScopeDeclaration*)
         -> template(t={$text}) "/*INTERFACE-not implemented*/ <t>"
     |   ^(ENUM IDENT (^('implements' type+))? classScopeDeclaration*)
@@ -201,7 +208,7 @@ classScopeDeclaration
     boolean migrationCtor = false;
 }
     :   ^(FUNCTION_METHOD_DECL m=modifierList? g=genericTypeParameterList? 
-            ty=type IDENT f=formalParameterList a=arrayDeclaratorList? 
+            ty=type IDENT f=formalParameterList
             b=block?)
         {
             // determine whether it's an entry method
@@ -215,7 +222,6 @@ classScopeDeclaration
                 ty={$ty.st},
                 id={$IDENT.text}, 
                 fpl={$f.st}, 
-                adl={$a.st},
                 block={$b.st})
         -> {emitH()}? funcMethodDecl_h(
                 modl={$m.st}, 
@@ -223,7 +229,6 @@ classScopeDeclaration
                 ty={$ty.st},
                 id={$IDENT.text}, 
                 fpl={$f.st}, 
-                adl={$a.st},
                 block={$b.st})
         -> {(emitCI() && entry)}? funcMethodDecl_ci(
                 modl={$m.st}, 
@@ -231,17 +236,16 @@ classScopeDeclaration
                 ty={$ty.st},
                 id={$IDENT.text}, 
                 fpl={$f.st}, 
-                adl={$a.st},
                 block={$b.st})
         ->
-    |   ^(PRIMITIVE_VAR_DECLARATION modifierList? simpleType variableDeclaratorList)
-        -> {emitH()}? class_var_decl(
+    |   ^(PRIMITIVE_VAR_DECLARATION modifierList? simpleType variableDeclaratorList[null, false])
+        -> {emitCC() || emitH()}? class_var_decl(
             modl={$modifierList.st},
             type={$simpleType.st},
             declList={$variableDeclaratorList.st})
         ->
-    |   ^(OBJECT_VAR_DECLARATION modifierList? objectType variableDeclaratorList)
-        -> {emitH()}? class_var_decl(
+    |   ^(OBJECT_VAR_DECLARATION modifierList? objectType variableDeclaratorList[$objectType.st, false])
+        -> {emitCC() || emitH()}? class_var_decl(
             modl={$modifierList.st},
             type={$objectType.st},
             declList={$variableDeclaratorList.st})
@@ -276,46 +280,78 @@ classScopeDeclaration
     ;
     
 interfaceScopeDeclaration
-    :   ^(FUNCTION_METHOD_DECL modifierList? genericTypeParameterList? type IDENT formalParameterList arrayDeclaratorList?)
+    :   ^(FUNCTION_METHOD_DECL modifierList? genericTypeParameterList? type IDENT formalParameterList)
         -> template(t={$text}) "/*interfaceScopeDeclarations-not implemented */ <t>"
-    |   ^(PRIMITIVE_VAR_DECLARATION modifierList? simpleType variableDeclaratorList)
+    |   ^(PRIMITIVE_VAR_DECLARATION modifierList? simpleType variableDeclaratorList[$simpleType.st, false])
         -> template(t={$text}) "/*interfaceScopeDeclarations-not implemented */ <t>"
-    |   ^(OBJECT_VAR_DECLARATION modifierList? objectType variableDeclaratorList)
+    |   ^(OBJECT_VAR_DECLARATION modifierList? objectType variableDeclaratorList[$objectType.st, false])
         -> template(t={$text}) "/*interfaceScopeDeclarations-not implemented */ <t>"
     ;
 
-variableDeclaratorList
-    :   ^(VAR_DECLARATOR_LIST (var_decls+=variableDeclarator)+)
+variableDeclaratorList[StringTemplate obtype, boolean output]
+    :   ^(VAR_DECLARATOR_LIST (var_decls+=variableDeclarator[obtype, output])+ )
         -> var_decl_list(var_decls={$var_decls})
     ;
 
-variableDeclarator
-    :   ^(VAR_DECLARATOR id=variableDeclaratorId initializer=variableInitializer?)
-        -> {emitCC()}? var_decl_cc(id={$id.st}, initializer={$initializer.st})
-        -> {emitH()}?  var_decl_h(id={$id.st}, initializer={$initializer.st})
-        -> {emitCI()}? var_decl_ci(id={$id.st}, initializer={$initializer.st})
+variableDeclarator[StringTemplate obtype, boolean output]
+    :   ^(VAR_DECLARATOR id=variableDeclaratorId[output] initializer=variableInitializer[obtype, output]?)
+        -> {$output && emitCC()}? var_decl_cc(id={$id.st}, initializer={$initializer.st})
+        -> {$output && emitH()}?  var_decl_h(id={$id.st}, initializer={$initializer.st})
+        -> {$output && emitCI()}? var_decl_ci(id={$id.st}, initializer={$initializer.st})
+        -> {!$output && emitCC()}? var_decl_cc(id={$id.st})
+        -> {!$output && emitH()}?  var_decl_h(id={$id.st})
+        -> {!$output && emitCI()}? var_decl_ci(id={$id.st})
         ->
     ; 
     
-variableDeclaratorId
-    :   ^(IDENT adl=arrayDeclaratorList?)
-        -> var_decl_id(id={$IDENT.text}, arrayDeclList={$adl.st})
+variableDeclaratorId[boolean output]
+    :   ^(IDENT de=domainExpression[null]?)
+        -> {$output}? var_decl_id(id={$IDENT.text}, domainExp={$de.st})
+        -> {!$output}? var_decl_id(id={$IDENT.text})
+        ->
     ;
 
-variableInitializer
+variableInitializer[StringTemplate obtype, boolean output]
     :   arrayInitializer
         -> {$arrayInitializer.st}
+    |   newExpression[obtype, output]
+        -> {$newExpression.st}
     |   expression
         -> {$expression.st}
     ;
 
-arrayDeclaratorList
+rangeItem
+    :   dl=DECIMAL_LITERAL
+        -> template(t={$dl.text}) "<t>"
+    |   IDENT
+        -> template(t={$IDENT.text}) "<t>"
+    ;
+
+rangeExpression
+    :   ^(RANGE_EXPRESSION (ri+=rangeItem)*)
+        -> template(t={$ri}) "Range(<t; separator=\",\">)"
+    ;
+
+rangeList returns [int len]
+    :   (r+=rangeExpression)*
+        { $len = $r.size(); }
+        -> template(t={$r}) "<t; separator=\", \">"
+        
+    ;
+
+domainExpression[List<StringTemplate> otherParams]
+    :   ^(DOMAIN_EXPRESSION rl=rangeList)
+        -> range_constructor(range={$rl.st}, others={$otherParams}, len={$rl.len})
+
+    ;
+
+/*arrayDeclaratorList
     :   ^(ARRAY_DECLARATOR_LIST ARRAY_DECLARATOR*)  
         -> template(t={$text}) "<t>"
-    ;
+    ;*/
     
 arrayInitializer
-    :   ^(ARRAY_INITIALIZER variableInitializer*)
+    :   ^(ARRAY_INITIALIZER variableInitializer[null, false]*)
         -> template(t={$text}) "/* arrayInitializer-not implemented */ <t>"
     ;
 
@@ -435,8 +471,8 @@ type
     ;
 
 simpleType
-    :   ^(SIMPLE_TYPE primitiveType arrayDeclaratorList?)
-        -> simple_type(typeID={$primitiveType.st}, arrDeclList={$arrayDeclaratorList.st})
+    :   ^(SIMPLE_TYPE primitiveType domainExpression[null]?)
+        -> simple_type(typeID={$primitiveType.st}, arrDeclList={$domainExpression.st})
     ;
 
 objectType
@@ -445,17 +481,17 @@ objectType
     ;
 
 nonProxyType
-    :   ^(OBJECT_TYPE qualifiedTypeIdent arrayDeclaratorList?)
-        -> obj_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$arrayDeclaratorList.st})
-    |   ^(POINTER_TYPE qualifiedTypeIdent arrayDeclaratorList?)
-        -> pointer_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$arrayDeclaratorList.st})
-    |   ^(REFERENCE_TYPE qualifiedTypeIdent arrayDeclaratorList?)
-        -> reference_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$arrayDeclaratorList.st})
+    :   ^(OBJECT_TYPE qualifiedTypeIdent domainExpression[null]?)
+        -> obj_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$domainExpression.st})
+    |   ^(POINTER_TYPE qualifiedTypeIdent domainExpression[null]?)
+        -> pointer_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$domainExpression.st})
+    |   ^(REFERENCE_TYPE qualifiedTypeIdent domainExpression[null]?)
+        -> reference_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$domainExpression.st})
     ;
 
 proxyType
-    :   ^(PROXY_TYPE qualifiedTypeIdent arrayDeclaratorList?)
-        -> proxy_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$arrayDeclaratorList.st})
+    :   ^(PROXY_TYPE qualifiedTypeIdent domainExpression[null]?)
+        -> proxy_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$domainExpression.st})
     ;
 
 qualifiedTypeIdent returns [ClassSymbol type]
@@ -465,8 +501,8 @@ qualifiedTypeIdent returns [ClassSymbol type]
     ;
 
 typeIdent
-    :   ^(IDENT genericTypeArgumentList?)
-        -> typeIdent(typeID={$IDENT.text}, generics={$genericTypeArgumentList.st})
+    :   ^(IDENT templateInstantiation?)
+        -> typeIdent(typeID={$IDENT.text}, generics={$templateInstantiation.st})
     ;
 
 primitiveType
@@ -485,11 +521,30 @@ $st = %{$start.getText()};
     |   DOUBLE
     ;
 
+templateArg
+    :   genericTypeArgument
+        -> {$genericTypeArgument.st}
+    |   literal
+        -> {$literal.st}
+    ;
+
+templateArgList
+    :   params+=templateArg+
+        -> template(params={$params}) "<params; separator=\", \">"
+    ;
+
+templateInstantiation
+    :   ^(TEMPLATE_INST templateArgList)
+        -> template(args={$templateArgList.st}) "\<<args>\>"
+    |   ^(TEMPLATE_INST ts=templateInstantiation)
+        -> template(inst={$ts.st}) "\<<inst>\>"
+    ;
+
 genericTypeArgumentList
     :   ^(GENERIC_TYPE_ARG_LIST (gta+=genericTypeArgument)+)
         -> template(gtal={$gta}) "\<<gtal; separator=\", \">\>"
     ;
-    
+
 genericTypeArgument
     :   type
         -> {$type.st}
@@ -503,12 +558,12 @@ formalParameterList
     ;
     
 formalParameterStandardDecl
-    :   ^(FORMAL_PARAM_STD_DECL lms=localModifierList? t=type vdid=variableDeclaratorId)
+    :   ^(FORMAL_PARAM_STD_DECL lms=localModifierList? t=type vdid=variableDeclaratorId[true])
         -> formal_param_decl(modList={$lms.st}, type={$t.st}, declID={$vdid.st})
     ;
     
 formalParameterVarargDecl
-    :   ^(FORMAL_PARAM_VARARG_DECL localModifierList? type variableDeclaratorId)
+    :   ^(FORMAL_PARAM_VARARG_DECL localModifierList? type variableDeclaratorId[true])
         -> template(t={$text}) "/*formal parameter varargs not implemented*/ <t>"
     ;
     
@@ -537,16 +592,16 @@ blockStatement
 
 
 localVariableDeclaration
-    :   ^(PRIMITIVE_VAR_DECLARATION localModifierList? simpleType variableDeclaratorList)
+    :   ^(PRIMITIVE_VAR_DECLARATION localModifierList? simpleType vdl=variableDeclaratorList[null, true])
         -> local_var_decl(
             modList={$localModifierList.st},
             type={$simpleType.st},
-            declList={$variableDeclaratorList.st})
-    |   ^(OBJECT_VAR_DECLARATION localModifierList? objectType variableDeclaratorList)
+            declList={$vdl.st})
+    |   ^(OBJECT_VAR_DECLARATION localModifierList? objectType vdl=variableDeclaratorList[$objectType.st, true])
         -> local_var_decl(
             modList={$localModifierList.st},
             type={$objectType.st},
-            declList={$variableDeclaratorList.st})
+            declList={$vdl.st})
     ;
 
 
@@ -624,6 +679,8 @@ parenthesizedExpression
 expression
     :   ^(EXPR expr)
         -> {$expr.st}
+    |   domainExpression[null]
+        -> {$domainExpression.st}
     ;
 
 expr
@@ -742,7 +799,7 @@ primaryExpression
         -> template(pe={$pe.st}, ex={$ex.st}) "<pe>[<ex>]"
     |   literal
         -> {$literal.st}
-    |   newExpression
+    |   newExpression[null, false]
         -> {$newExpression.st}
     |   THIS
         -> {%{$start.getText()}}
@@ -775,7 +832,18 @@ arrayTypeDeclarator
         -> template(t={$text}) "<t>"
     ;
 
-newExpression
+newExpression[StringTemplate obtype, boolean output] returns [StringTemplate initArray]
+    :   ^(NEW_EXPRESSION arguments? domainExpression[$arguments.args])
+        -> {$output}? template(domain={$domainExpression.st},type={$obtype}) "new <type>(<domain>)"
+        -> {!$output}? template() ""
+        ->
+    |   ^(NEW proxyType arguments)
+        -> template(t={$proxyType.st}, a={$arguments.st}) "<t>::ckNew(<a>)"
+    |   ^(NEW nonProxyType arguments)
+        -> template(q={$nonProxyType.st}, a={$arguments.st}) "new <q>(<a>)"
+    ;
+
+/*newExpression
     :   ^(  STATIC_ARRAY_CREATOR
             (   primitiveType newArrayConstruction
             |   genericTypeArgumentList? qualifiedTypeIdent newArrayConstruction
@@ -787,8 +855,8 @@ newExpression
     |   ^(NEW nonProxyType arguments)
         -> template(q={$nonProxyType.st}, a={$arguments.st}) "new <q>(<a>)"
     ;
-
-newArrayConstruction
+*/
+/*newArrayConstruction
     :   arrayDeclaratorList arrayInitializer
         -> array_construction_with_init(
                 array_decls={$arrayDeclaratorList.st},
@@ -796,10 +864,13 @@ newArrayConstruction
     |   (ex+=expression)+ adl=arrayDeclaratorList?
         -> array_construction(exprs={$ex}, array_decls={$adl.st})
     ;
-
-arguments
-    :   ^(ARGUMENT_LIST (ex+=expression)*)
-        -> arguments(exprs={$ex})
+*/
+arguments returns [List<StringTemplate> args]
+@init {
+    $args = new ArrayList<StringTemplate>();
+}
+    :   ^(ARGUMENT_LIST (e=expression { $args.add($e.st); } )*)        
+        ->  arguments(exprs={$args})
     ;
 
 literal
index e7d3fcf92581f901dec23725412ac5b11b390d50..c9ff0cbcf12115af89258e96232bb34d5a713fde 100644 (file)
@@ -158,6 +158,11 @@ scope ScopeStack; // top-level type scope
                 //    System.out.println(entry.getKey());
                 //}
             }
+    |   ^('template' i1=IDENT* typeDeclaration)
+        {
+            // JL: Need to fill the templateArgs in ClassSymbol, and push this down
+            // to the class subtree
+        }
     |   ^('interface' IDENT (^('extends' type+))?  interfaceScopeDeclaration*)
     |   ^('enum' IDENT (^('implements' type+))? enumConstant+ classScopeDeclaration*)
     ;
@@ -194,9 +199,9 @@ scope ScopeStack;
             $FUNCTION_METHOD_DECL.symbol = sym;
         }
     |   ^(PRIMITIVE_VAR_DECLARATION modifierList? simpleType
-            ^(VAR_DECLARATOR_LIST field[$simpleType.type]+))
+            ^(VAR_DECLARATOR_LIST field[$simpleType.type, false]+))
     |   ^(OBJECT_VAR_DECLARATION modifierList? objectType
-            ^(VAR_DECLARATOR_LIST field[$objectType.type]+))
+            ^(VAR_DECLARATOR_LIST field[$objectType.type, false]+))
         {
             ClassSymbol type = $objectType.type;
             if (type != null && type.isChare) currentClass.addExtern(type.getName());
@@ -205,17 +210,20 @@ scope ScopeStack;
             b=block)
         {
             if (astmod.isMigrationCtor($CONSTRUCTOR_DECL)) currentClass.migrationCtor = $CONSTRUCTOR_DECL;
+            if (currentClass != null) {
+                currentClass.constructor = $classScopeDeclaration.start;
+            }
         }
     ;
 
-field [ClassSymbol type]
-    :   ^(VAR_DECLARATOR ^(IDENT arrayDeclaratorList?) variableInitializer?)
+field [ClassSymbol type, boolean localdef]
+    :   ^(VAR_DECLARATOR variableDeclaratorId[localdef] variableInitializer?)
     {
-            VariableSymbol sym = new VariableSymbol(symtab, $IDENT.text, $type);
+            VariableSymbol sym = new VariableSymbol(symtab, $variableDeclaratorId.ident, $type);
             sym.definition = $field.start;
             sym.definitionTokenStream = input.getTokenStream();
             $VAR_DECLARATOR.symbol = sym;
-            currentClass.define($IDENT.text, sym);
+            currentClass.define($variableDeclaratorId.ident, sym);
     }
     ;
     
@@ -225,21 +233,46 @@ interfaceScopeDeclaration
         // Interface constant declarations have been switched to variable
         // declarations by Charj.g; the parser has already checked that
         // there's an obligatory initializer.
-    |   ^(PRIMITIVE_VAR_DECLARATION modifierList? simpleType variableDeclaratorList)
-    |   ^(OBJECT_VAR_DECLARATION modifierList? objectType variableDeclaratorList)
+    |   ^(PRIMITIVE_VAR_DECLARATION modifierList? simpleType variableDeclaratorList[false])
+    |   ^(OBJECT_VAR_DECLARATION modifierList? objectType variableDeclaratorList[false])
     ;
 
-variableDeclaratorList
-    :   ^(VAR_DECLARATOR_LIST variableDeclarator+)
+variableDeclaratorList[boolean localdef]
+    :   ^(VAR_DECLARATOR_LIST variableDeclarator[localdef]+)
     ;
 
-variableDeclarator
-    :   ^(VAR_DECLARATOR ^(IDENT arrayDeclaratorList?) variableInitializer?)
-
+variableDeclarator[boolean localdef]
+    :   ^(VAR_DECLARATOR variableDeclaratorId[localdef] variableInitializer?)
     ;
     
-variableDeclaratorId
-    :   ^(IDENT arrayDeclaratorList?)
+variableDeclaratorId[boolean localdef] returns [String ident]
+    :   ^(IDENT domainExpression?
+        { 
+            if (currentClass != null && !localdef) {
+                currentClass.initializers.add($variableDeclaratorId.start);
+            }
+
+            $ident = $IDENT.text;
+        } )
+    ;
+
+rangeItem
+    :   DECIMAL_LITERAL
+    |   IDENT
+    ;
+
+rangeExpression
+    :   ^(RANGE_EXPRESSION rangeItem)
+    |   ^(RANGE_EXPRESSION rangeItem rangeItem)
+    |   ^(RANGE_EXPRESSION rangeItem rangeItem rangeItem)
+    ;
+
+rangeList
+    :   rangeExpression*
+    ;
+
+domainExpression
+    :   ^(DOMAIN_EXPRESSION rangeList)
     ;
 
 variableInitializer
@@ -354,7 +387,7 @@ String name = "";
     ;
 
 typeIdent returns [String name]
-    :   ^(IDENT genericTypeArgumentList?)
+    :   ^(IDENT templateInstantiation?)
         { $name = $IDENT.text; }
     ;
 
@@ -372,6 +405,15 @@ primitiveType
 genericTypeArgumentList
     :   ^(GENERIC_TYPE_ARG_LIST genericTypeArgument+)
     ;
+
+templateArgList
+    :   genericTypeArgument+
+    ;
+
+templateInstantiation
+    :   ^(TEMPLATE_INST templateArgList)
+    |   ^(TEMPLATE_INST templateInstantiation)
+    ;
     
 genericTypeArgument
     :   type
@@ -383,11 +425,11 @@ formalParameterList
     ;
     
 formalParameterStandardDecl
-    :   ^(FORMAL_PARAM_STD_DECL localModifierList? type variableDeclaratorId)
+    :   ^(FORMAL_PARAM_STD_DECL localModifierList? type variableDeclaratorId[false])
     ;
     
 formalParameterVarargDecl
-    :   ^(FORMAL_PARAM_VARARG_DECL localModifierList? type variableDeclaratorId)
+    :   ^(FORMAL_PARAM_VARARG_DECL localModifierList? type variableDeclaratorId[false])
     ;
     
 // FIXME: is this rule right? Verify that this is ok, I expected something like:
@@ -407,8 +449,8 @@ blockStatement
     ;
     
 localVariableDeclaration
-    :   ^(PRIMITIVE_VAR_DECLARATION localModifierList? simpleType variableDeclaratorList)
-    |   ^(OBJECT_VAR_DECLARATION localModifierList? objectType variableDeclaratorList)
+    :   ^(PRIMITIVE_VAR_DECLARATION localModifierList? simpleType variableDeclaratorList[true])
+    |   ^(OBJECT_VAR_DECLARATION localModifierList? objectType variableDeclaratorList[true])
         {
             ClassSymbol type = $objectType.type;
             /*System.out.println("looked up type " + type + " for declaration " + $objectType.text);*/
@@ -467,7 +509,7 @@ forInit
 parenthesizedExpression
     :   ^(PAREN_EXPR expression)
     ;
-    
+
 expression
     :   ^(EXPR expr)
     ;
@@ -559,11 +601,12 @@ arrayTypeDeclarator
     ;
 
 newExpression
-    :   ^(  STATIC_ARRAY_CREATOR
-            (   primitiveType newArrayConstruction
-            |   genericTypeArgumentList? qualifiedTypeIdent newArrayConstruction
-            )
-        )
+    :   ^(NEW_EXPRESSION arguments? domainExpression)
+        {
+            if (currentClass != null) {
+                currentClass.initializers.add($newExpression.start);
+            }
+        }
     |   ^(NEW type arguments)
     ;
 
index 42f072a2974c8116ee1379ad73a2855c80a7d187..e4c727df5e46617f96700f839eac96cf705921e1 100644 (file)
@@ -7,6 +7,10 @@ public class ClassSymbol extends SymbolWithScope implements Scope {
 
     public ClassSymbol superClass;
     public List<String> interfaceImpls;
+    public List<String> templateArgs;
+    public List<CharjAST> initializers;
+
+    public CharjAST constructor;
 
     Map<String, PackageScope> imports =
         new LinkedHashMap<String, PackageScope>();
@@ -34,6 +38,8 @@ public class ClassSymbol extends SymbolWithScope implements Scope {
         for (String pkg : SymbolTable.AUTO_IMPORTS) {
             importPackage(pkg);
         }
+       this.initializers = new ArrayList<CharjAST>();
+       constructor = null;
     }
 
     public ClassSymbol(
@@ -44,6 +50,8 @@ public class ClassSymbol extends SymbolWithScope implements Scope {
         this(symtab, name);
         this.superClass = superClass;
         this.scope = scope;
+       this.initializers = new ArrayList<CharjAST>();
+       constructor = null;
 
         // manually add automatic class methods and symbols here
         this.includes.add("charm++.h");
index 8c4398072a6aa81f6ac6f04bbc9ad1b708dfc3f4..901b8bfee813cdeb5523ca4111eb8b97eab1e550 100644 (file)
@@ -99,9 +99,15 @@ public class Translator {
         m_nodes.setTokenStream(tokens);
         m_nodes.setTreeAdaptor(m_adaptor);
         if (m_printAST) printAST("Before Semantic Pass", "before_sem.html");
-        semanticPass();
+       ClassSymbol sem = semanticPass();
+       modifyNodes(sem);
+        //semanticPass();
         if (m_printAST) printAST("After Semantic Pass", "after_sem.html");
 
+       m_nodes = new CommonTreeNodeStream(m_ast);
+        m_nodes.setTokenStream(tokens);
+        m_nodes.setTreeAdaptor(m_adaptor);
+
         // emit code for .ci, .h, and .cc based on rewritten AST
         String ciOutput = translationPass(OutputMode.ci);
         writeTempFile(filename, ciOutput, OutputMode.ci);
@@ -140,6 +146,60 @@ public class Translator {
         return sem.charjSource(m_symtab);
     }
 
+
+    private CharjAST addConstructor(ClassSymbol sem) {
+       CharjAST ast1 = new CharjAST(CharjParser.CONSTRUCTOR_DECL, 
+                                    "CONSTRUCTOR_DECL");
+       CharjAST ast2 = new CharjAST(CharjParser.IDENT, 
+                                    sem.getScopeName());
+       CharjAST ast3 = new CharjAST(CharjParser.FORMAL_PARAM_LIST, 
+                                    "FORMAL_PARAM_LIST");
+       CharjAST ast4 = new CharjAST(CharjParser.BLOCK, "BLOCK");
+       
+       ast1.addChild(ast2);
+       ast1.addChild(ast3);
+       ast1.addChild(ast4);
+       sem.definition.addChild(ast1);
+       return ast1;
+    }
+
+    private void modifyNodes(ClassSymbol sem) {
+       /* Add constructor */
+
+       if (sem.constructor == null) {
+           sem.constructor = addConstructor(sem);
+       }
+
+       /* Insert array initializers into the constructor */
+
+       for (CharjAST init : sem.initializers) {
+           System.out.println("processing init token = " + init.getType());
+
+           if (init.getType() == CharjParser.IDENT) {
+               CharjAST ast1 = new CharjAST(CharjParser.EXPR, "EXPR");
+               CharjAST ast2 = new CharjAST(CharjParser.METHOD_CALL, "METHOD_CALL");
+               CharjAST ast2_1 = new CharjAST(CharjParser.DOT, ".");
+               CharjAST ast2_2 = new CharjAST(CharjParser.IDENT, init.getText());
+               CharjAST ast2_3 = new CharjAST(CharjParser.IDENT, "init");
+               CharjAST ast4 = new CharjAST(CharjParser.ARGUMENT_LIST, "ARGUMENT_LIST");
+
+               ast1.addChild(ast2);
+               ast2.addChild(ast2_1);
+               ast2_1.addChild(ast2_2);
+               ast2_1.addChild(ast2_3);
+               ast2.addChild(ast4);
+               ast4.addChildren(init.getChildren());
+
+               //System.out.println(sem.constructor.toStringTree());
+
+               sem.constructor.getChild(2).addChild(ast1);
+           } else if (init.getType() == CharjParser.NEW_EXPRESSION) {
+               //(OBJECT_VAR_DECLARATION (TYPE (QUALIFIED_TYPE_IDENT (Array (TEMPLATE_INST (TYPE double(Symbol(double_primitive, ClassSymbol[double]: {}, ))))))) (VAR_DECLARATOR_LIST (VAR_DECLARATOR ccc (NEW_EXPRESSION (ARGUMENT_LIST (EXPR get)) (DOMAIN_EXPRESSION (RANGE_EXPRESSION 1))))))
+           }
+           
+       }
+    }
+
     private String translationPass(OutputMode m) throws
         RecognitionException, IOException, InterruptedException
     {
diff --git a/src/langs/charj/tests/unit/ArrayTest.cj b/src/langs/charj/tests/unit/ArrayTest.cj
new file mode 100644 (file)
index 0000000..623c81c
--- /dev/null
@@ -0,0 +1,14 @@
+
+class ArrayTest {
+      Array<int> test[10];
+
+      void test() {
+           test[0] = 0;
+
+          int i;
+
+          for (i = 0; i < 10; i++) {
+               test[i] = 0;
+           }
+      }
+}
diff --git a/src/langs/charj/tests/unit/Template.cj b/src/langs/charj/tests/unit/Template.cj
new file mode 100644 (file)
index 0000000..bb67191
--- /dev/null
@@ -0,0 +1,17 @@
+
+class test {
+      Array<int, 2> test[2:2, 4];
+      Array<int, 2> test2 = new [2, 4](gen);
+      Array<int> aaa[3];
+
+      test() {
+         aaa(abc, 4, test);
+        
+        def.init(abc, 4, test);
+
+        Array<double> ddd[5];
+        Array<double> ccc = new [1](get);
+
+        //test = new [2]();
+      }
+}