|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.clef.symtab.Symtab
public final class Symtab
A class to represent a program's symbol table.
$Id: Symtab.java,v 1.48 2007-08-30 01:48:30 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
A symbol table comprises many scopes arranged in a tree. Each scope has a unique identification (the scope number) and a local symbol table. A local symbol table is a dictionary which pairs identifiers with entries. A single "entries" is a list of entry nodes, where each node represents a single declared entity. We maintain a list of entry nodes because an identifier could conceivably be used to name multiple entities even within a single scope. Though not currently used, we do assume that with a scope, each use of a single identifier names a different kind of entity. The other classes are:
SymtabScope
SymtabEntry
Constructor Summary | |
---|---|
Symtab()
Create a symbol table. |
Method Summary | |
---|---|
SymtabEntry |
addRootSymbol(Declaration decl)
Add a symbol to the current scope. |
SymtabEntry |
addSymbol(Declaration decl)
Add a symbol to the current scope. |
SymtabScope |
beginScope()
Open a new scope as a child of the current socpe. |
SymtabScope |
endScope()
Ends the current scope, and the current scope's outer scope becomes the current scope. |
RoutineDecl |
findRoutine(java.lang.String rname)
Return the RoutineDecl specified. |
SymtabScope |
getCurrentScope()
Return the current scope. |
SymtabScope |
getRootScope()
Return the root scope. |
boolean |
isAtRoot()
Return true if the current scope is the root scope. |
SymtabScope |
lookupScope(Declaration decl)
Return the scope associated with the Declaration. |
SymtabEntry |
lookupSymbol(Declaration d)
Return the symbol table entry for a specific declaration. |
Vector<SymtabEntry> |
lookupSymbol(java.lang.String id)
Look in the current scope for a symbol table entry matching a specific name. |
SymtabEntry |
replaceSymbol(Declaration oldDecl,
Declaration newDecl)
Replace an existing symbol in the current scope. |
void |
setCurrentScope(SymtabScope scope)
Set the current scope. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Symtab()
Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public final SymtabScope beginScope()
InvalidTableError
- if we have incorrectly created a new
scopepublic final SymtabScope endScope()
public final SymtabScope getCurrentScope()
public final SymtabScope getRootScope()
public boolean isAtRoot()
public final void setCurrentScope(SymtabScope scope)
scope
- the scopepublic final SymtabEntry addSymbol(Declaration decl)
decl
- the declaration for the symbol
public final SymtabEntry replaceSymbol(Declaration oldDecl, Declaration newDecl)
oldDecl
- the old declaration for the symbolnewDecl
- the new declaration for the symbol
null
if not foundpublic final SymtabEntry addRootSymbol(Declaration decl)
decl
- the declaration for the symbol
public SymtabScope lookupScope(Declaration decl)
public final Vector<SymtabEntry> lookupSymbol(java.lang.String id)
id
- the symbol's name
public final SymtabEntry lookupSymbol(Declaration d)
d
- the declaration
public RoutineDecl findRoutine(java.lang.String rname)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |