code.table
Class SymbolTable

java.lang.Object
  extended by code.table.SymbolTable

 class SymbolTable
extends java.lang.Object

An object of this class holds all the symbols of a module. Each symbol is accessed by its name or identifier.

Since symbols definitions can be mutually recursive, some symbols can be referenced before they are defined. Therefore, symbols can be either installed or announced. Symbols are installed at the point of the definition. Symbols are announced at the point of reference. It is OK to annouce a symbol multiple times before and/or after it is installed.

This class could be an inner class of ModuleTable. It is separated to keep the size of programs small. The class and all its members are not public.

The numeric ids of symbols are assigned by the class MapTable which also holds the mapping from ids to symbols.

Since:
June 21, 2004
Author:
Sergio Antoy

Nested Class Summary
private static class SymbolTable.Pair
          A table stores both a symbol and the symbol's numeric id.
 
Field Summary
private  java.lang.String moduleName
          The module whose symbols this table holds.
(package private)  java.util.Hashtable nameToSymbol
           
 
Constructor Summary
SymbolTable(java.lang.String moduleName)
           
 
Method Summary
(package private)  void announceSymbol(java.lang.String symbolName)
           
(package private)  java.util.Enumeration getAllSymbols()
           
(package private)  int getId(java.lang.String symbolName)
           
(package private)  Symbol getSymbol(java.lang.String symbolName)
           
(package private)  java.lang.String getSymbolName(int id)
           
(package private)  java.util.Enumeration getUndefinedSymbols()
           
(package private)  void installSymbol(Symbol symbol)
           
(package private)  int sureGetId(java.lang.String symbolName)
           
private  java.util.Vector symbolVector()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nameToSymbol

java.util.Hashtable nameToSymbol

moduleName

private java.lang.String moduleName
The module whose symbols this table holds.

Constructor Detail

SymbolTable

SymbolTable(java.lang.String moduleName)
Method Detail

installSymbol

void installSymbol(Symbol symbol)

getSymbol

Symbol getSymbol(java.lang.String symbolName)

announceSymbol

void announceSymbol(java.lang.String symbolName)

getId

int getId(java.lang.String symbolName)

sureGetId

int sureGetId(java.lang.String symbolName)

getSymbolName

java.lang.String getSymbolName(int id)

symbolVector

private java.util.Vector symbolVector()

getAllSymbols

java.util.Enumeration getAllSymbols()

getUndefinedSymbols

java.util.Enumeration getUndefinedSymbols()