Save This Page
Home » openjdk-7 » com.sun.tools » javac » code » [javadoc | source]
com.sun.tools.javac.code
public class: Scope [javadoc | source]
java.lang.Object
   com.sun.tools.javac.code.Scope

Direct Known Subclasses:
    CompoundScope, StarImportScope, DelegatedScope, ErrorScope, ImportScope

A scope represents an area of visibility in a Java program. The Scope class is a container for symbols which provides efficient access to symbols given their names. Scopes are implemented as hash tables with "open addressing" and "double hashing". Scopes can be nested; the next field of a scope points to its next outer scope. Nested scopes can share their hash tables.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
Nested Class Summary:
public interface  Scope.ScopeListener   
public static class  Scope.Entry  A class for scope entries. 
public static class  Scope.ImportScope   
public static class  Scope.StarImportScope   
public static class  Scope.DelegatedScope  An empty scope, into which you can't place anything. Used for the scope for a variable initializer. 
public static class  Scope.CompoundScope  A class scope adds capabilities to keep track of changes in related class scopes - this allows client to realize whether a class scope has changed, either directly (because a new member has been added/removed to this scope) or indirectly (i.e. because a new member has been added/removed into a supertype scope) 
public static class  Scope.ErrorScope  An error scope, for which the owner should be an error symbol. 
Field Summary
public  Scope next    Next enclosing scope (with whom this scope may share a hashtable) 
public  Symbol owner    The scope's owner. 
 Entry[] table    A hash table for the scope's entries. 
 int hashMask    Mask for hash codes, always equal to (table.length - 1). 
public  Entry elems    A linear list that also contains all entries in reverse order of appearance (i.e later entries are pushed on top). 
 int nelems    The number of elements in this scope. This includes deleted elements, whose value is the sentinel. 
 List<ScopeListener> listeners    A list of scopes to be notified if items are to be removed from this scope. 
public static final  Scope emptyScope    A value for the empty scope. 
static final  Filter<Symbol> noFilter     
Constructor:
 public Scope(Symbol owner) 
    Construct a new scope, within scope next, with given owner, using a fresh table of length INITIAL_SIZE.
Method from com.sun.tools.javac.code.Scope Summary:
addScopeListener,   dup,   dup,   dupUnshared,   enter,   enter,   enter,   enterIfAbsent,   getElements,   getElements,   getElementsByName,   getElementsByName,   getIndex,   includes,   leave,   lookup,   lookup,   makeEntry,   remove,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sun.tools.javac.code.Scope Detail:
 public  void addScopeListener(ScopeListener sl) 
 public Scope dup() 
    Construct a fresh scope within this scope, with same owner, which shares its table with the outer scope. Used in connection with method leave if scope access is stack-like in order to avoid allocation of fresh tables.
 public Scope dup(Symbol newOwner) 
    Construct a fresh scope within this scope, with new owner, which shares its table with the outer scope. Used in connection with method leave if scope access is stack-like in order to avoid allocation of fresh tables.
 public Scope dupUnshared() 
    Construct a fresh scope within this scope, with same owner, with a new hash table, whose contents initially are those of the table of its outer scope.
 public  void enter(Symbol sym) 
    Enter symbol sym in this scope.
 public  void enter(Symbol sym,
    Scope s) 
 public  void enter(Symbol sym,
    Scope s,
    Scope origin) 
    Enter symbol sym in this scope, but mark that it comes from given scope `s' accessed through `origin'. The last two arguments are only used in import scopes.
 public  void enterIfAbsent(Symbol sym) 
    Enter symbol sym in this scope if not already there.
 public Iterable<Symbol> getElements() 
 public Iterable<Symbol> getElements(Filter<Symbol> sf) 
 public Iterable<Symbol> getElementsByName(Name name) 
 public Iterable<Symbol> getElementsByName(Name name,
    Filter<Symbol> sf) 
 int getIndex(Name name) 
    Look for slot in the table. We use open addressing with double hashing.
 public boolean includes(Symbol c) 
    Given a class, is there already a class with same fully qualified name in this (import) scope?
 public Scope leave() 
    Remove all entries of this scope from its table, if shared with next.
 public Entry lookup(Name name) 
    Return the entry associated with given name, starting in this scope and proceeding outwards. If no entry was found, return the sentinel, which is characterized by having a null in both its scope and sym fields, whereas both fields are non-null for regular entries.
 public Entry lookup(Name name,
    Filter<Symbol> sf) 
 Entry makeEntry(Symbol sym,
    Entry shadowed,
    Entry sibling,
    Scope scope,
    Scope origin) 
 public  void remove(Symbol sym) 
    Remove symbol from this scope. Used when an inner class attribute tells us that the class isn't a package member.
 public String toString()