gov.llnl.babel.symbols
Class SymbolTable
java.lang.Object
gov.llnl.babel.symbols.SymbolTable
- SymbolResolver
public class SymbolTable
extends java.lang.Object
SymbolTable
is a singleton class that represents the
locally cached SIDL symbols used during the parse of a SIDL file
or XML type descriptions. Only one version of a particular symbol
may exist in the table, although different versions may exist in
the resolver search path. A symbol may not be added to the table
if it already exists in the table. A symbol may not be added to
the table if already exists in the SymbolResolver
search path with the same version. The symbol table keeps a list
of modified symbols that must be written to a database at the end
of the parsing.
SymbolTable
public SymbolTable()
Create a new instance of a symbol table. Although singleton classes
do not typically define a public constructor, this implementation does
so to support multiple symbol tables in the same application. Most
implementations, however, will not directly create a symbol table
through the constructor and will instead use the one available in
the Context.
addSymbolResolver
public void addSymbolResolver(SymbolResolver resolver)
Add a new symbol resolver to the end of the list of current
resolvers. The symbol resolvers will be searched in order of
addition to the symbol table resolver list.
freezeAll
public void freezeAll()
generateDependencies
public Set generateDependencies(Set symbols)
throws SymbolNotFoundException,
SymbolRedefinitionException
Generate dependencies for the symbols in the input Set
.
The input set contains a set of SymbolID
symbol names.
All dependencies will be loaded into the symbol table and their
SymbolID
names will be returned in the Set
return argument. If the input argument is null or if there are no
dependencies, then the return argument will be null.
getModifiedSymbolNames
public Set getModifiedSymbolNames()
Return the set of symbol names in the symbol table that are new
or modified. The set contains the symbol names as objects of type
SymbolID
.
getSymbolNames
public Set getSymbolNames()
Return the set of symbol names in the symbol table. The set contains
the keys for the hash table as objects of type SymbolID
.
getTable
public Map getTable()
Return the current symbol table as a Map
. The keys
for the hash table are of type SymbolID
and the values
are of type Symbol
.
lookupSymbol
public Symbol lookupSymbol(String fqn)
Look up a symbol in the symbol table based on the fully qualified
name. If the symbol does not exist in the symbol table, then null
is returned.
- lookupSymbol in interface SymbolResolver
lookupSymbol
public Symbol lookupSymbol(SymbolID id)
Look up a symbol in the symbol table based on the fully qualified
name and the version number. If the symbol does not exist in the
table with the same version number, then null is returned.
- lookupSymbol in interface SymbolResolver
markSymbolAsModified
public void markSymbolAsModified(SymbolID id)
Mark a symbol in the symbol table as modified. If the specified
symbol identifier does not exist in the symbol table, then this
routine does nothing.
putSymbol
public void putSymbol(Symbol symbol)
throws SymbolRedefinitionException
Add a new symbol to the symbol table. This method will throw a
SymbolRedefinitionException
if the symbol already exists
in the symbol table with the same name or if the symbol exists in the
resolver search path with the same name and version. This symbol
is also placed on the new or modified symbol list.
removeSymbolResolver
public void removeSymbolResolver(SymbolResolver resolver)
resolveAllParents
public void resolveAllParents()
throws SymbolNotFoundException
Resolve all external symbol references for all parents of symbols in
the symbol table.
resolveAllReferences
public void resolveAllReferences()
throws SymbolNotFoundException,
SymbolRedefinitionException
Resolve all external symbol references for all symbols in the symbol
table. If a symbol reference is not found, then an exception of the
type SymbolNotFoundException
is thrown. If a symbol
reference redefines a symbol with a different version number, then
a SymbolRedefinitionException
is thrown.
resolveSymbol
public Symbol resolveSymbol(String fqn)
Resolve the specified symbol by fully qualified name and cache the
symbol in the symbol table. This method will return the symbol with
the specified name if it already exists in the symbol table. If the
symbol does not exist in the symbol table, then this method will search
through the resolver list for the symbol with the most recent version
number. If no symbol is found, then null is returned.
resolveSymbol
public Symbol resolveSymbol(SymbolID id)
throws SymbolRedefinitionException
Resolve the specified symbol by fully qualified name and version number
and cache the symbol in the symbol table. This method will return the
symbol with the specified ID if it already exists in the symbol table.
If a symbol exists in the symbol table with the same name but different
version, then a SymbolRedefinitionException
is thrown.
If the symbol does not exist in the symbol table, then this method will
search through the resolver list for the symbol with the matching
version number. If no symbol is found, then null is returned.
setInputFromSIDL
public void setInputFromSIDL()
setTargetIsXML
public void setTargetIsXML(boolean value)
verifyReferences
public void verifyReferences()
throws SymbolNotFoundException
Verify that all references in the table have been satisfied. If
a symbol reference is not defined, then a symbol not found exception
is thrown.