record which methods contain sdag syntax in symbol table
authorAaron Becker <akbecker@gmail.com>
Mon, 23 Aug 2010 20:32:01 +0000 (15:32 -0500)
committerAaron Becker <akbecker@gmail.com>
Mon, 23 Aug 2010 20:37:34 +0000 (15:37 -0500)
src/langs/charj/src/charj/translator/MethodSymbol.java
src/langs/charj/src/charj/translator/SymbolDefiner.g

index c195b12dad46e22c16a025c18beac0229b12c2b1..f238c072473367d0e263ac421bb4d886fc19fc87 100644 (file)
@@ -23,6 +23,7 @@ public class MethodSymbol
     public boolean isStatic = false;
     public boolean isCtor = false;
     public boolean isTraced = false;
+    public boolean hasSDAG = false;
 
     public MethodSymbol(SymbolTable symtab) {
         super(symtab);
index 66ed97b843905e56801eecc909ec7b14ab8703a0..9ac800950d543be2b92287e758d9d342c5c2c31e 100644 (file)
@@ -13,8 +13,9 @@ package charj.translator;
 
 @members {
     SymbolTable symtab;
-    Scope currentScope;
-    ClassSymbol currentClass;
+    Scope currentScope = null;
+    ClassSymbol currentClass = null;
+    MethodSymbol currentMethod = null;
     AstModifier astmod = new AstModifier();
 
     public SymbolDefiner(TreeNodeStream input, SymbolTable symtab) {
@@ -105,6 +106,7 @@ boolean entry = false;
             currentScope.define($IDENT.text, sym);
             $IDENT.def = sym;
             currentScope = sym;
+            currentMethod = sym;
             $IDENT.scope = currentScope;
             //System.out.println(currentScope);
         }
@@ -133,6 +135,7 @@ boolean entry = false;
             currentScope.define($IDENT.text, sym);
             $IDENT.def = sym;
             currentScope = sym;
+            currentMethod = sym;
             $IDENT.scope = currentScope;
             //System.out.println(currentScope);
         }
@@ -142,11 +145,11 @@ exitMethod
     :   ^((FUNCTION_METHOD_DECL | ENTRY_FUNCTION_DECL | CONSTRUCTOR_DECL | ENTRY_CONSTRUCTOR_DECL) .*) {
             //System.out.println("method " + currentScope);
             currentScope = currentScope.getEnclosingScope();
+            currentMethod = null;
         }
     ;
 
 
-
 enterClass
     :   ^(TYPE classType IDENT
             (^('extends' parent=type))?
@@ -290,4 +293,8 @@ atoms
             assert currentScope != null;
             t.scope = currentScope;
        }
+    |  (WHEN|OVERLAP) {
+            assert currentMethod != null;
+            currentMethod.hasSDAG = true;
+       }
     ;