Changeset 101
- Timestamp:
- 07/06/08 00:24:04 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Parser.g
r100 r101 219 219 -- class 220 220 ClassDeclaration$ClassDeclaration ::= Annotations Modifiers class$ IDENTIFIER$Name ClassExtends Implements ClassBody$Body 221 /. 222 $action_type.SymbolTable symbolTable; 223 public void setSymbolTable($action_type.SymbolTable symbolTable) { this.symbolTable = symbolTable; } 224 public $action_type.SymbolTable getSymbolTable() { return symbolTable; } 225 ./ 221 226 222 227 ClassExtends$Type ::= %empty | extends$ Name … … 577 582 if (n instanceof FunctionExpression) return ((FunctionExpression) n).getSymbolTable(); 578 583 if (n instanceof ClassBody) return ((ClassBody) n).getSymbolTable(); 584 if (n instanceof ClassDeclaration) return ((ClassDeclaration) n).getSymbolTable(); 579 585 if (n instanceof InterfaceBody) return ((InterfaceBody) n).getSymbolTable(); 580 586 if (n instanceof ForStatement) return ((ForStatement) n).getSymbolTable(); axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/parser/SymbolTableVisitor.java
r92 r101 13 13 import org.axdt.as3.imp.parser.Ast.Block; 14 14 import org.axdt.as3.imp.parser.Ast.ClassBody; 15 import org.axdt.as3.imp.parser.Ast.ClassDeclaration; 15 16 import org.axdt.as3.imp.parser.Ast.CustomNamespace; 16 17 import org.axdt.as3.imp.parser.Ast.ExpressionStatement; … … 21 22 import org.axdt.as3.imp.parser.Ast.InterfaceBody; 22 23 import org.axdt.as3.imp.parser.Ast.MethodDeclaration; 24 import org.axdt.as3.imp.parser.Ast.OtherMod; 23 25 import org.axdt.as3.imp.parser.Ast.PackageBody; 24 26 import org.axdt.as3.imp.parser.Ast.VariableDeclarator; … … 80 82 } 81 83 84 public boolean visit(ClassDeclaration n) { 85 n.setSymbolTable(pushNewTable()); 86 return true; 87 } 88 82 89 public boolean visit(ClassBody n) { 83 90 n.setSymbolTable(pushNewTable()); … … 115 122 } 116 123 for (Object o:n.getModifiers().getArrayList()) { 117 if (o instanceof CustomNamespace) { 124 if (o instanceof OtherMod && "static".equals(o.toString())) { 125 symbol_table = symbol_table.getParent(); 126 } else if (o instanceof CustomNamespace) { 118 127 name = o.toString() + "::" + name; 119 break;120 128 } 121 129 } … … 169 177 public boolean visit(VariableDeclarator n) { 170 178 IAst parent = n.getParent().getParent(); 179 SymbolTable symbol_table = peekTable(); 171 180 String name = n.getName().toString(); 172 181 if (parent instanceof FieldDeclaration) { 173 182 FieldDeclaration f = (FieldDeclaration) parent; 174 183 for (Object o:f.getModifiers().getArrayList()) { 175 if (o instanceof CustomNamespace) { 184 if (o instanceof OtherMod && "static".equals(o.toString())) { 185 symbol_table = symbol_table.getParent(); 186 } else if (o instanceof CustomNamespace) { 176 187 name = o.toString() + "::" + name; 177 break;178 188 } 179 189 } 180 190 } 181 if (! peekTable().create(name, n)) emitError(n, "Illegal redeclaration of " + name);191 if (!symbol_table.create(name, n)) emitError(n, "Illegal redeclaration of " + name); 182 192 return true; 183 193 }
