code.table
Class MapTable

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

public class MapTable
extends java.lang.Object

This class defines a mapping from the integers 1,2,3,... to the symbols of a program. A symbol in a term is identified by this integer. The mapping is injective and provides fast access to the symbol.

This table is written during the modules loading phase by ModuleTable and/or SymbolTable and is read during the execution of a program. The visibility of methods is suggested by this modus of use.

Since:
June 24, 2004
Author:
Sergio Antoy

Field Summary
private static int baseline
          Saved value of NextId when setBaseline was called.
private static java.util.Vector intToSymbol
          Mapping representation
private static int nextId
          Counts the ids used so far
 
Constructor Summary
private MapTable()
          Singleton class
 
Method Summary
static java.util.Enumeration getAllSymbols()
           
static int getId(java.lang.String symbolName)
           
static DataSymbol getSymbol(int id)
           
(package private) static void installSymbol(Symbol symbol, int id)
           
(package private) static int nextId()
           
(package private) static void resetBaseline()
          Remove all the symbols except those below the baseline.
(package private) static void setBaseline()
          Save the value of nextId in baseline.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

intToSymbol

private static final java.util.Vector intToSymbol
Mapping representation


nextId

private static int nextId
Counts the ids used so far


baseline

private static int baseline
Saved value of NextId when setBaseline was called.

Constructor Detail

MapTable

private MapTable()
Singleton class

Method Detail

nextId

static int nextId()

setBaseline

static void setBaseline()
Save the value of nextId in baseline. The intent is to set this value after all the builtin modules have been loaded. When an ordinary (non-builtin) module is loaded, and all its imported modules are loaded as well, everything above the baseline in the MapTable is discarded. This has the effect to remove all the symbols except those belonging to builtin modules.


resetBaseline

static void resetBaseline()
Remove all the symbols except those below the baseline. This operation also reset nextId with the value saved in the baseline.


installSymbol

static void installSymbol(Symbol symbol,
                          int id)

getSymbol

public static DataSymbol getSymbol(int id)

getId

public static int getId(java.lang.String symbolName)
                 throws AmbiguousSymbolException
Throws:
AmbiguousSymbolException

getAllSymbols

public static java.util.Enumeration getAllSymbols()