Fixed small conflicts in Translator.
authorJonathan Lifflander <jliffl2@illinois.edu>
Mon, 14 Jun 2010 16:12:29 +0000 (11:12 -0500)
committerJonathan Lifflander <jliffl2@illinois.edu>
Mon, 14 Jun 2010 16:12:29 +0000 (11:12 -0500)
Merge branch 'charm' of charmgit:charm into charm

Conflicts:
src/langs/charj/src/charj/translator/Translator.java

1  2 
src/langs/charj/src/charj/translator/Charj.g
src/langs/charj/src/charj/translator/CharjEmitter.g
src/langs/charj/src/charj/translator/CharjSemantics.g
src/langs/charj/src/charj/translator/Translator.java

index 076e6fcf0253539a1330d4cef0bce49fe7bc3b9b,ce98bb8261917a7171c2d7258628e5cb1b08f037..feeb88a02f1cadc2d5d6da937dfbbaa682519c73
@@@ -208,13 -201,8 +208,8 @@@ classScopeDeclaratio
      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
-             if($m.start != null)
-                 entry = listContainsToken($m.start.getChildren(), CHARJ_MODIFIER_LIST);
-         }
          -> {emitCC()}? funcMethodDecl_cc(
                  sym={currentClass},
                  modl={$m.st}, 
                  ty={$ty.st},
                  id={$IDENT.text}, 
                  fpl={$f.st}, 
 -                adl={$a.st},
                  block={$b.st})
-         -> {(emitCI() && entry)}? funcMethodDecl_ci(
+         -> {emitCI()}? // do nothing, since it's not an entry method
+         ->
+     |   ^(ENTRY_FUNCTION_DECL m=modifierList? g=genericTypeParameterList? 
+             ty=type IDENT f=formalParameterList a=arrayDeclaratorList? 
+             b=block?)
+         -> {emitCC()}? funcMethodDecl_cc(
+                 sym={currentClass},
+                 modl={$m.st}, 
+                 gtpl={$g.st}, 
+                 ty={$ty.st},
+                 id={$IDENT.text}, 
+                 fpl={$f.st}, 
+                 adl={$a.st},
+                 block={$b.st})
+         -> {emitH()}? funcMethodDecl_h(
+                 modl={$m.st}, 
+                 gtpl={$g.st}, 
+                 ty={$ty.st},
+                 id={$IDENT.text}, 
+                 fpl={$f.st}, 
+                 adl={$a.st},
+                 block={$b.st})
+         -> {emitCI()}? funcMethodDecl_ci(
                  modl={$m.st}, 
                  gtpl={$g.st}, 
                  ty={$ty.st},
index c9ff0cbcf12115af89258e96232bb34d5a713fde,f69ca237286bbabefc1e6ef3973f236895b71830..e90a7815e49bf65e48aa6232711e6028fa973fc6
@@@ -198,10 -193,21 +198,21 @@@ scope ScopeStack
              currentClass.define($IDENT.text, sym);
              $FUNCTION_METHOD_DECL.symbol = sym;
          }
+     |   ^(ENTRY_FUNCTION_DECL m=modifierList? g=genericTypeParameterList?
+             ty=type IDENT formalParameterList a=arrayDeclaratorList? b=block)
+         {
+             ClassSymbol returnType = currentClass.resolveType($ty.text);
+             MethodSymbol sym = new MethodSymbol(symtab, $IDENT.text, currentClass, returnType);
+             currentMethod = sym;
+             sym.definition = $classScopeDeclaration.start;
+             sym.definitionTokenStream = input.getTokenStream();
+             currentClass.define($IDENT.text, sym);
+             $ENTRY_FUNCTION_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());
              b=block)
          {
              if (astmod.isMigrationCtor($CONSTRUCTOR_DECL)) currentClass.migrationCtor = $CONSTRUCTOR_DECL;
 +            if (currentClass != null) {
 +                currentClass.constructor = $classScopeDeclaration.start;
 +            }
          }
+     |   ^(ENTRY_CONSTRUCTOR_DECL m=modifierList? g=genericTypeParameterList? IDENT f=formalParameterList 
+             b=block)
+         {
+             if (astmod.isMigrationCtor($ENTRY_CONSTRUCTOR_DECL)) currentClass.migrationCtor = $ENTRY_CONSTRUCTOR_DECL;
+         }
      ;
  
 -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;
index 901b8bfee813cdeb5523ca4111eb8b97eab1e550,8aae98f90426db4a70c91ad95e844630ee9cf665..4f662109f321023835cff1cc2bdee71c051be2e2
@@@ -93,21 -94,21 +94,26 @@@ public class Translator 
          m_nodes.setTreeAdaptor(m_adaptor);
  
          // do AST rewriting and semantic checking
-         if (m_printAST) printAST("Before Modifier Pass", "before_mod.html");
-         modifierPass();
-         m_nodes = new CommonTreeNodeStream(m_ast);
-         m_nodes.setTokenStream(tokens);
-         m_nodes.setTreeAdaptor(m_adaptor);
+         if (m_printAST) printAST("Before PreSemantics Pass", "before_presem.html");
+         preSemanticPass();
          if (m_printAST) printAST("Before Semantic Pass", "before_sem.html");
 -        semanticPass();
 +      ClassSymbol sem = semanticPass();
 +      modifyNodes(sem);
-         //semanticPass();
+         //m_symtab = new SymbolTable(this);
+         //m_nodes.reset();
+         //SymbolDefiner definer = new SymbolDefiner(m_nodes, m_symtab);
+         //definer.downup(m_ast);
+         //m_nodes.reset();
+         //SymbolResolver resolver = new SymbolResolver(m_nodes, m_symtab);
+         //resolver.downup(m_ast);
          if (m_printAST) printAST("After Semantic Pass", "after_sem.html");
+         postSemanticPass();
+         if (m_printAST) printAST("After PostSemantics Pass", "after_postsem.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);