All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class edu.gac.max.mcs388.s2000.compiler_support.ScopedIdentifier

java.lang.Object
   |
   +----edu.gac.max.mcs388.s2000.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.


Method Index

 o declare(Declaration)
declare associates some piece of information (the Declaration) with a ScopedIdentifier in the current scope.
 o enterScope()
The static enterScope method serves notice that a new scope is being entered, nested inside the current scope.
 o exitScope()
The static exitScope method serves notice that the current scope is being exited, returning to the outer scope it was nested inside.
 o get(String)
The static get method provides the only way to obtain a ScopedIdentifier, since there is no public constructor.
 o getDeclaration()
getDeclaration returns the Declaration that is currently in effect.
 o getName()
getName simply returns the String that was passed to get

Methods

 o 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.

 o getName
 public String getName()
getName simply returns the String that was passed to get

 o 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)
 o 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

 o 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.

 o 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