code.table
Class ModuleTable

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

public class ModuleTable
extends java.lang.Object

This is the main class for managing the symbols of a program. This class is a singleton.

This class holds a table that maps module names to a pair consisting of a module and a table of all the symbols of the module. See the package description for other tables in this package.

Since symbol definitions may be mutually recursive, symbols may be referenced before they are defined. When a symbol is referenced, it is announced. Announcing a symbol assigns a unique numeric id to it that is used to identify the symbol throughout the virtual machine and to enable fast access to the symbol information. It is expected that all referenced symbols will be defined. When a symbol is defined, it is installed in its module symbol table

A module or a symbol can be announced repeatedly before and/or after being installed, but it can be installed only once.

Class main responsibilities :

  1. Create and initialize the table of the modules of a program.
  2. Install, retrieve and announce a module.
  3. Install, retrieve and announce a symbol of a module.
  4. Enumerate both modules and symbols.
Class Collaborators :
  1. CurryModule
  2. Symbol
  3. SymbolTable
  4. TablesPrinter

Revised in June 2004 by Sergio Antoy to provide a name space for modules from a version of Jimeng Liu dated Sept. 2002.

Since:
June 22, 2004 Modified by Sunita Marathe Jul 15, 2005 : to support implicit loading of modules whose symbols are referenced by explicitly loaded modules
Author:
Sergio Antoy

Nested Class Summary
private static class ModuleTable.Pair
          Objects of this class represent an entry of the module table.
 
Field Summary
private static CurryModule[] builtins
          The builtin modules in some arbitrary order.
private static java.util.Hashtable moduleTable
          A table holding all the loaded modules A module is accessed by its name, a string.
private static java.lang.String[] standards
          The standard module names in some arbitrary order.
 
Constructor Summary
private ModuleTable()
          Singleton class, all members are static.
 
Method Summary
private static void announceModule(java.lang.String moduleName)
           
private static void announceSymbol(java.lang.String moduleName, java.lang.String symbolName)
           
static void clear()
          Reset the entire table leaving only the builtin modules.
static java.util.Enumeration getAllModules()
           
static java.util.Enumeration getAllSymbols(CurryModule module)
           
static java.util.Enumeration getAllSymbols(java.lang.String moduleName)
           
static int getId(java.lang.String maybeQualifiedName)
          The symbol should already be installed
static int getId(java.lang.String moduleName, java.lang.String symbolName)
           
static CurryModule getModule(java.lang.String moduleName)
           
static Symbol getSymbol(java.lang.String symbolName)
           
static Symbol getSymbol(java.lang.String moduleName, java.lang.String symbolName)
           
(package private) static SymbolTable getTable(java.lang.String moduleName)
           
static java.util.Enumeration getUndefinedModules()
           
static java.lang.String getUndefinedSymbol(int id)
           
static java.util.Enumeration getUndefinedSymbols()
           
static void installModule(CurryModule module)
           
private static void installSymbol(CurryModule module, Symbol symbol)
           
static void installSymbol(java.lang.String moduleName, Symbol symbol)
           
static void loadBuiltinModules()
          Install the builtin/standard modules.
(package private) static java.util.Vector moduleVector()
           
static void removeModule(java.lang.String moduleName)
           
static int sureGetId(java.lang.String moduleName, java.lang.String symbolName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

moduleTable

private static final java.util.Hashtable moduleTable
A table holding all the loaded modules A module is accessed by its name, a string.


builtins

private static CurryModule[] builtins
The builtin modules in some arbitrary order.


standards

private static java.lang.String[] standards
The standard module names in some arbitrary order.

Constructor Detail

ModuleTable

private ModuleTable()
Singleton class, all members are static.

Method Detail

loadBuiltinModules

public static void loadBuiltinModules()
Install the builtin/standard modules.


clear

public static void clear()
Reset the entire table leaving only the builtin modules.


installModule

public static void installModule(CurryModule module)

getModule

public static CurryModule getModule(java.lang.String moduleName)

getTable

static SymbolTable getTable(java.lang.String moduleName)

announceModule

private static void announceModule(java.lang.String moduleName)

removeModule

public static void removeModule(java.lang.String moduleName)

installSymbol

private static void installSymbol(CurryModule module,
                                  Symbol symbol)

installSymbol

public static void installSymbol(java.lang.String moduleName,
                                 Symbol symbol)

getSymbol

public static Symbol getSymbol(java.lang.String moduleName,
                               java.lang.String symbolName)

getSymbol

public static Symbol getSymbol(java.lang.String symbolName)
                        throws AmbiguousSymbolException
Throws:
AmbiguousSymbolException

announceSymbol

private static void announceSymbol(java.lang.String moduleName,
                                   java.lang.String symbolName)

getId

public static int getId(java.lang.String moduleName,
                        java.lang.String symbolName)

sureGetId

public static int sureGetId(java.lang.String moduleName,
                            java.lang.String symbolName)

getId

public static int getId(java.lang.String maybeQualifiedName)
                 throws AmbiguousSymbolException
The symbol should already be installed

Throws:
AmbiguousSymbolException

moduleVector

static java.util.Vector moduleVector()

getAllModules

public static java.util.Enumeration getAllModules()

getAllSymbols

public static java.util.Enumeration getAllSymbols(CurryModule module)

getAllSymbols

public static java.util.Enumeration getAllSymbols(java.lang.String moduleName)

getUndefinedModules

public static java.util.Enumeration getUndefinedModules()

getUndefinedSymbols

public static java.util.Enumeration getUndefinedSymbols()

getUndefinedSymbol

public static java.lang.String getUndefinedSymbol(int id)