Class EDU.gac.max.MC97.S97.compiler_support.Identifier
All Packages Class Hierarchy This Package Previous Next Index
Class EDU.gac.max.MC97.S97.compiler_support.Identifier
java.lang.Object
|
+----EDU.gac.max.MC97.S97.compiler_support.Identifier
- public class Identifier
- extends Object
The Identifier 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 an Identifier 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 an Identifier,
since there is no public constructor.
-
getDeclaration()
- getDeclaration returns the Declaration that is currently in effect.
-
getName()
- getName simply returns the String that was passed to get
get
public static Identifier get(String nm)
- The static get method provides the only way to obtain an Identifier,
since there is no public constructor. The same Identifier object
will consistently be returned every time get is passed an equal
String; this is the point of get. The String becomes the Identifier's
name.
getName
public String getName()
- getName simply returns the String that was passed to get
declare
public void declare(Declaration decl) throws RedeclarationException
- declare associates some piece of information (the Declaration)
with an Identifier in the current scope. It throws a
RedeclarationException if the Identifier 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