1 15 16 package javassist.compiler; 17 18 import java.util.HashMap ; 19 import javassist.compiler.ast.Declarator; 20 21 public final class SymbolTable extends HashMap { 22 private SymbolTable parent; 23 24 public SymbolTable() { this(null); } 25 26 public SymbolTable(SymbolTable p) { 27 super(); 28 parent = p; 29 } 30 31 public SymbolTable getParent() { return parent; } 32 33 public Declarator lookup(String name) { 34 Declarator found = (Declarator)get(name); 35 if (found == null && parent != null) 36 return parent.lookup(name); 37 else 38 return found; 39 } 40 41 public void append(String name, Declarator value) { 42 put(name, value); 43 } 44 } 45 | Popular Tags |