junc.symtab
Class SymbolTable

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--junc.symtab.SymbolTable
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class SymbolTable
extends java.util.Hashtable

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
SymbolTable()
           
SymbolTable(int tableSize, float bucketFactor)
           
 
Method Summary
 junc.ast.FieldDeclarationNode addField(junc.symtab.Symbol name, junc.ast.FieldDeclarationNode node)
          Adds a field name to the symbol table.
 junc.ast.FormalParameterNode addFormal(junc.symtab.Symbol name, junc.ast.FormalParameterNode node)
          Adds a formal param to the symbol table.
 junc.ast.LabeledStatementNode addLabel(junc.symtab.Symbol name, junc.ast.LabeledStatementNode node)
          Adds a statement label to the symbol table.
 junc.ast.LocalVarDeclarationNode addLocal(junc.symtab.Symbol name, junc.ast.LocalVarDeclarationNode node)
          Adds a local var to the symbol table.
 java.util.Vector addMethod(junc.symtab.Symbol name, junc.ast.MethodDeclarationNode node)
          Adds a method name to the symbol table.
 junc.ast.CompilationUnitNode addPackage(junc.symtab.Symbol name, junc.ast.CompilationUnitNode node)
          Adds a package declaration to the symbol table.
 java.util.Vector addPrimop(junc.symtab.Symbol name, junc.types.MethodType mtype)
          Adds a primop name to the symbol table.
 junc.ast.TypeDeclarationNode addType(junc.symtab.Symbol name, junc.ast.TypeDeclarationNode node)
          Adds a class or an interface name to the symbol table.
 junc.ast.FieldDeclarationNode lookupField(junc.symtab.Symbol name)
          Looks up a field declaration in the symbol table.
 junc.ast.FormalParameterNode lookupFormal(junc.symtab.Symbol name)
          Looks up a formal parameter in the symbol table.
 junc.ast.LabeledStatementNode lookupLabel(junc.symtab.Symbol name)
          Looks up a statement label in the symbol table.
 junc.ast.LocalVarDeclarationNode lookupLocal(junc.symtab.Symbol name)
          Looks up a local var in the symbol table.
 java.util.Vector lookupMethod(junc.symtab.Symbol name)
          Looks up a method declaration in the symbol table.
 junc.ast.CompilationUnitNode lookupPackage(junc.symtab.Symbol name)
          Looks up a package declaration in the symbol table.
 java.util.Vector lookupPrimop(junc.symtab.Symbol name)
          Looks up a primop in the symbol table.
 junc.ast.TypeDeclarationNode lookupType(junc.symtab.Symbol name)
          Looks up a class or interface declaration in the symbol table.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SymbolTable

public SymbolTable()

SymbolTable

public SymbolTable(int tableSize,
                   float bucketFactor)
Method Detail

addPackage

public junc.ast.CompilationUnitNode addPackage(junc.symtab.Symbol name,
                                               junc.ast.CompilationUnitNode node)
Adds a package declaration to the symbol table. The name should be fully qualified.


lookupPackage

public junc.ast.CompilationUnitNode lookupPackage(junc.symtab.Symbol name)
Looks up a package declaration in the symbol table. If the name is not present or does not correspond to a package null is returned.


addType

public junc.ast.TypeDeclarationNode addType(junc.symtab.Symbol name,
                                            junc.ast.TypeDeclarationNode node)
Adds a class or an interface name to the symbol table. Names should be fully qualified.


lookupType

public junc.ast.TypeDeclarationNode lookupType(junc.symtab.Symbol name)
Looks up a class or interface declaration in the symbol table. If the name is not present or does not correspond to a class or an interface then null is returned.


addField

public junc.ast.FieldDeclarationNode addField(junc.symtab.Symbol name,
                                              junc.ast.FieldDeclarationNode node)
Adds a field name to the symbol table. Names should be fully qualified. A forward declaration may be resolved.


lookupField

public junc.ast.FieldDeclarationNode lookupField(junc.symtab.Symbol name)
Looks up a field declaration in the symbol table. If the name is not present or does not correspond to a field, null is returned.


addMethod

public java.util.Vector addMethod(junc.symtab.Symbol name,
                                  junc.ast.MethodDeclarationNode node)
Adds a method name to the symbol table. Names should be fully qualified. A key is built by appending "()" to the name. A vector is kept for each name (method overloading).


lookupMethod

public java.util.Vector lookupMethod(junc.symtab.Symbol name)
Looks up a method declaration in the symbol table. A key is built by appending "()" to the name. If the name is not present or does not correspond to a method, null is returned.


addFormal

public junc.ast.FormalParameterNode addFormal(junc.symtab.Symbol name,
                                              junc.ast.FormalParameterNode node)
Adds a formal param to the symbol table. A name must be qualified with the method (that also includes package and class) and a unique index identifying outermost scope.


lookupFormal

public junc.ast.FormalParameterNode lookupFormal(junc.symtab.Symbol name)
Looks up a formal parameter in the symbol table. If the name is not present or does not correspond to a field, null is returned.


addLocal

public junc.ast.LocalVarDeclarationNode addLocal(junc.symtab.Symbol name,
                                                 junc.ast.LocalVarDeclarationNode node)
Adds a local var to the symbol table. A name must be qualified with the method (that also includes package and class) and a unique index identifying the scope.


lookupLocal

public junc.ast.LocalVarDeclarationNode lookupLocal(junc.symtab.Symbol name)
Looks up a local var in the symbol table. If the name is not present or does not correspond to a field, null is returned.


addPrimop

public java.util.Vector addPrimop(junc.symtab.Symbol name,
                                  junc.types.MethodType mtype)
Adds a primop name to the symbol table. A vector is kept for each name (overloading).


lookupPrimop

public java.util.Vector lookupPrimop(junc.symtab.Symbol name)
Looks up a primop in the symbol table. If the name is not present or does not correspond to a primop, null is returned.


addLabel

public junc.ast.LabeledStatementNode addLabel(junc.symtab.Symbol name,
                                              junc.ast.LabeledStatementNode node)
Adds a statement label to the symbol table. Appends a ":" to avoid name clashes.


lookupLabel

public junc.ast.LabeledStatementNode lookupLabel(junc.symtab.Symbol name)
Looks up a statement label in the symbol table. Appends ":" to the name before searching.