scale.clef.symtab
Class SymtabScope

java.lang.Object
  |
  +--scale.clef.symtab.SymtabScope
All Implemented Interfaces:
java.io.Serializable

public class SymtabScope
extends java.lang.Object
implements java.io.Serializable

This class represents a single, local scope (e.g., for a procedure or local block).

$Id: SymtabScope.java,v 1.30 2002/01/03 21:44:08 burrill Exp $

Copyright 2002 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.

The primary function of a scope is to maintain a table of (identifier, decl) pairs. This table is implemented by

See Also:
SymtabLocal, Serialized Form

Constructor Summary
SymtabScope(int depth)
          Constructor to create a symbol table scope.
 
Method Summary
 SymtabEntry addEntry(Declaration decl)
          This method adds a new entry to the local symbol table.
 void appendChild(SymtabScope child)
          Add a child to the scope - represents a nested scope
 SymtabScope getOuterScope()
          Return the scope containing this scope.
 int getScopeDepth()
           
 int getScopeNumber()
           
 SymtabEntries lookup(java.lang.String id)
          This method looks for the identifier in this scope.
 SymtabEntry lookupSymbol(Declaration d)
          Look for a declaration in this scope.
 java.util.Enumeration orderedElements()
          Returns an enumeration of symbols in the scope - in the order that the symbols were added to the scope.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SymtabScope

public SymtabScope(int depth)
Constructor to create a symbol table scope.
Parameters:
depth - the current nesting depth of the scope block
Method Detail

getScopeNumber

public final int getScopeNumber()

getScopeDepth

public final int getScopeDepth()

lookup

public final SymtabEntries lookup(java.lang.String id)
This method looks for the identifier in this scope. If the identifier is present, the list of entry nodes is returned. Otherwise, NULL is returned.
Parameters:
id - the name of a symbol
Returns:
the list of symbol table entries for the name

lookupSymbol

public final SymtabEntry lookupSymbol(Declaration d)
Look for a declaration in this scope. If the declaration is present, then return the symbol table entry. Otherwise, return null

addEntry

public final SymtabEntry addEntry(Declaration decl)
This method adds a new entry to the local symbol table. It is responsible for finding or creating an appropriate "Entries".
Parameters:
decl - the declaration for the symbol
Returns:
a SymtabEntry for the symbol

getOuterScope

public final SymtabScope getOuterScope()
Return the scope containing this scope.

appendChild

public final void appendChild(SymtabScope child)
Add a child to the scope - represents a nested scope
Parameters:
child - the nested scope

orderedElements

public final java.util.Enumeration orderedElements()
Returns an enumeration of symbols in the scope - in the order that the symbols were added to the scope.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object