All Packages Class Hierarchy This Package Previous Next Index
Class edu.gac.max.mcs388.s2002.compiler_support.ScopedIdentifier
java.lang.Object
|
+----edu.gac.max.mcs388.s2002.compiler_support.ScopedIdentifier
- public class ScopedIdentifier
- extends Object
The ScopedIdentifier class represents the programming language concept of
an identifier, i.e., a name that can have declarations associated
with it.
-
declare(Declaration)
- declare associates some piece of information (the Declaration)
with a ScopedIdentifier in the current scope.
-
enterScope()
- The static enterScope method serves notice that a new scope is being
entered, nested inside the current scope.
-
exitScope()
- The static exitScope method serves notice that the current scope
is being exited, returning to the outer scope it was nested inside.
-
get(String)
- The static get method provides the only way to obtain a ScopedIdentifier,
since there is no public constructor.
-
getDeclaration()
- getDeclaration returns the Declaration that is currently in effect.
-
toString()
- toString returns the String that was passed to the get method
get
public static ScopedIdentifier get(String nm)
- The static get method provides the only way to obtain a ScopedIdentifier,
since there is no public constructor. The same ScopedIdentifier object
will consistently be returned every time get is passed an equal
String; this is the point of get. The String becomes the
ScopedIdentifier's name.
toString
public String toString()
- toString returns the String that was passed to the get method
- Overrides:
- toString in class Object
declare
public void declare(Declaration decl) throws RedeclarationException
- declare associates some piece of information (the Declaration)
with a ScopedIdentifier in the current scope.
- Throws: RedeclarationException
- If the ScopedIdentifier already has been declared
in this exact scope (not counting surrounding scopes)
getDeclaration
public Declaration getDeclaration()
- getDeclaration returns the Declaration that is currently in effect.
This is the one that was declared in the innermost scope that has
not yet been exited
enterScope
public static void enterScope()
- The static enterScope method serves notice that a new scope is being
entered, nested inside the current scope. Thus all identifiers are
once again eligible for declaration without it being an illegal
redeclaration. This also delimits how many declarations are to be
undone when the scope is exited.
exitScope
public static void exitScope()
- The static exitScope method serves notice that the current scope
is being exited, returning to the outer scope it was nested inside.
This does two things. First of all, all declarations done within
the scope being exited is forgotten, i.e., will no longer be returned
by getDeclaration. Second, each of the forgotten Declaration objects
has its leavingScope method invoked as
a form of "callback", so that any additional operation can be done
that the particular form of Declaration needs, e.g., deallocating
a register.
All Packages Class Hierarchy This Package Previous Next Index