|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.SymbolTable
public class SymbolTable
Class for representing a class symbol table
| Constructor Summary | |
|---|---|
SymbolTable()
SymbolTable constructor create an empty symbol table |
|
| Method Summary | |
|---|---|
void |
add(java.lang.String s,
java.lang.Object value)
Adds a symbol to the symbol table if one does not already exist Sets the value of the symbol to the specified parameter |
SymbolTable |
clone()
clone this symbol table as well as all parent symbol tables Note: does a shallow clone, does not copy keys or values Note also: this is an expensive operation |
void |
dump()
For debugging -- dumps out entire symbol table Starts from highest scope level (Object class) and works towards the lowest scope level (current level) |
void |
enterScope()
Enter a new scope |
void |
exitScope()
Exit a scope |
int |
getCurrScopeLevel()
Gets the current scope level of the symbol table (first scope starts at 1) |
int |
getCurrScopeSize()
Gets the number of entries in the current scope of the symbol table |
int |
getScopeLevel(java.lang.String s)
Gets scope level of a symbol in the table (<0 means symbol not in table) |
int |
getSize()
Gets the number of entries in all scopes of the symbol table Note: includes inherited scopes |
java.lang.Object |
lookup(java.lang.String s)
Looks up a symbol in any scope in the symbol table |
java.lang.Object |
lookup(java.lang.String s,
int level)
Looks up a symbol in a particular scope in the symbol table as well as any outer scopes from that specified scope Note: an exception is thrown if the specified level is <0 or >= largest scope level |
java.lang.Object |
peek(java.lang.String s)
Looks up a symbol in the current scope in the table |
java.lang.Object |
peek(java.lang.String s,
int level)
Looks up a symbol in a particular scope in the symbol table Note: an exception is thrown if the specified level is <0 or >= largest scope level |
void |
set(java.lang.String s,
java.lang.Object val)
Sets the value of an existing symbol in the innermost scope of the symbol table |
void |
set(java.lang.String s,
java.lang.Object val,
int level)
Sets the value of an existing symbol in a particular scope of the symbol table (or an outer scope containing the specified scope) |
void |
setParent(SymbolTable parent)
Set the parent symbol table |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SymbolTable()
| Method Detail |
|---|
public void setParent(SymbolTable parent)
parent - symbol table of the parent classpublic void enterScope()
public void exitScope()
public void add(java.lang.String s,
java.lang.Object value)
s - symbol name (i.e., name of variable or method)value - value of symbol (i.e., type)public java.lang.Object lookup(java.lang.String s)
s - string of symbol to lookup
public java.lang.Object lookup(java.lang.String s,
int level)
s - string of symbol to lookuplevel - scope level to lookup string (outermost scope is at level 0)
public java.lang.Object peek(java.lang.String s)
s - string of symbol to lookup
public java.lang.Object peek(java.lang.String s,
int level)
s - string of symbol to lookuplevel - scope level to lookup string (outermost scope is at level 0)
public void set(java.lang.String s,
java.lang.Object val)
s - string of symbol to setval - value to set the symbol to
public void set(java.lang.String s,
java.lang.Object val,
int level)
s - string of symbol to setval - value to set the symbol tolevel - scope level containing symbol to be setpublic int getScopeLevel(java.lang.String s)
s - string of symbol to lookup
public int getSize()
public int getCurrScopeSize()
public int getCurrScopeLevel()
public SymbolTable clone()
clone in class java.lang.Objectpublic void dump()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||