|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sun.tools.javac.tree.JCTree.Visitor
com.sun.tools.javac.comp.Enter
public class Enter
This class enters symbols for all encountered definitions into the symbol table. The pass consists of two phases, organized as follows:
In the first phase, all class symbols are intered into their enclosing scope, descending recursively down the tree for classes which are members of other classes. The class symbols are given a MemberEnter object as completer.
In the second phase classes are completed using MemberEnter.complete(). Completion might occur on demand, but any classes that are not completed that way will be eventually completed by processing the `uncompleted' queue. Completion entails (1) determination of a class's parameters, supertype and interfaces, as well as (2) entering all symbols defined in the class into its scope, with the exception of class symbols which have been entered in phase 1. (2) depends on (1) having been completed for a class and all its superclasses and enclosing classes. That's why, after doing (1), we put classes in a `halfcompleted' queue. Only when we have performed (1) for a class and all it's superclasses and enclosing classes, we proceed to (2).
Whereas the first phase is organized as a sweep through all compiled syntax trees, the second phase is demand. Members of a class are entered when the contents of a class are first accessed. This is accomplished by installing completer objects in class symbols for compiled classes which invoke the member-enter phase for the corresponding class tree.
Classes migrate from one phase to the next via queues:
class enter -> (Enter.uncompleted) --> member enter (1)
-> (MemberEnter.halfcompleted) --> member enter (2)
-> (Todo) --> attribute
(only for toplevel classes)
This is NOT part of any API supported by Sun Microsystems. 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.
| Field Summary | |
|---|---|
(package private) Annotate |
annotate
|
(package private) Check |
chk
|
protected static Context.Key<Enter> |
enterKey
|
protected Env<AttrContext> |
env
Visitor argument: the current environment. |
(package private) JavaFileManager |
fileManager
|
(package private) Lint |
lint
|
(package private) Log |
log
|
(package private) TreeMaker |
make
|
(package private) MemberEnter |
memberEnter
|
private JCTree.JCClassDecl |
predefClassDef
A dummy class to serve as enclClass for toplevel environments. |
(package private) ClassReader |
reader
|
(package private) Type |
result
Visitor result: the computed type. |
(package private) Symtab |
syms
|
private Todo |
todo
|
(package private) java.util.Map<Symbol.TypeSymbol,Env<AttrContext>> |
typeEnvs
A hashtable mapping classes and packages to the environments current at the points of their definitions. |
(package private) Types |
types
|
(package private) ListBuffer<Symbol.ClassSymbol> |
uncompleted
The queue of all classes that might still need to be completed; saved and initialized by main(). |
| Constructor Summary | |
|---|---|
protected |
Enter(Context context)
|
| Method Summary | ||
|---|---|---|
Env<AttrContext> |
bracketEnv(JCTree.JCExpression tree,
Env<AttrContext> env)
Create a fresh environment for bracket bodies. |
|
(package private) Type |
classEnter(JCTree tree,
Env<AttrContext> env)
Visitor method: enter all classes in given tree, catching any completion failure exceptions. |
|
(package private)
|
classEnter(List<T> trees,
Env<AttrContext> env)
Visitor method: enter classes of a list of trees, returning a list of types. |
|
Env<AttrContext> |
classEnv(JCTree.JCClassDecl tree,
Env<AttrContext> env)
Create a fresh environment for class bodies. |
|
private static boolean |
classNameMatchesFileName(Symbol.ClassSymbol c,
Env<AttrContext> env)
Does class have the same name as the file it appears in? |
|
void |
complete(List<JCTree.JCCompilationUnit> trees,
Symbol.ClassSymbol c)
Main method: enter one class from a list of toplevel trees and place the rest on uncompleted for later processing. |
|
protected void |
duplicateClass(JCDiagnostic.DiagnosticPosition pos,
Symbol.ClassSymbol c)
Complain about a duplicate class. |
|
(package private) Scope |
enterScope(Env<AttrContext> env)
The scope in which a member definition in environment env is to be entered This is usually the environment's scope, except for class environments, where the local scope is for type variables, and the this and super symbol only, and members go into the class member scope. |
|
Env<AttrContext> |
escapeEnv(JCTree tree,
Env<AttrContext> env)
Create a fresh environment for escape bodies. |
|
Env<AttrContext> |
getClassEnv(Symbol.TypeSymbol sym)
|
|
Env<AttrContext> |
getEnv(Symbol.TypeSymbol sym)
Accessor for typeEnvs |
|
Env<AttrContext> |
getTopLevelEnv(JCTree.JCCompilationUnit tree)
|
|
static Enter |
instance(Context context)
|
|
void |
main(List<JCTree.JCCompilationUnit> trees)
Main method: enter all classes in a list of toplevel trees. |
|
(package private) Env<AttrContext> |
topLevelEnv(JCTree.JCCompilationUnit tree)
Create a fresh environment for toplevels. |
|
void |
visitClassDef(JCTree.JCClassDecl tree)
|
|
void |
visitTopLevel(JCTree.JCCompilationUnit tree)
|
|
void |
visitTree(JCTree tree)
Default class enter visitor method: do nothing. |
|
void |
visitTypeParameter(JCTree.JCTypeParameter tree)
Class enter visitor method for type parameters. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Context.Key<Enter> enterKey
Log log
Symtab syms
Check chk
TreeMaker make
ClassReader reader
Annotate annotate
MemberEnter memberEnter
Types types
Lint lint
JavaFileManager fileManager
private final Todo todo
java.util.Map<Symbol.TypeSymbol,Env<AttrContext>> typeEnvs
ListBuffer<Symbol.ClassSymbol> uncompleted
private JCTree.JCClassDecl predefClassDef
protected Env<AttrContext> env
Type result
| Constructor Detail |
|---|
protected Enter(Context context)
| Method Detail |
|---|
public static Enter instance(Context context)
public Env<AttrContext> getEnv(Symbol.TypeSymbol sym)
public Env<AttrContext> getClassEnv(Symbol.TypeSymbol sym)
public Env<AttrContext> classEnv(JCTree.JCClassDecl tree,
Env<AttrContext> env)
tree - The class definition.env - The environment current outside of the class definition.Env<AttrContext> topLevelEnv(JCTree.JCCompilationUnit tree)
tree - The toplevel tree.public Env<AttrContext> getTopLevelEnv(JCTree.JCCompilationUnit tree)
Scope enterScope(Env<AttrContext> env)
public Env<AttrContext> bracketEnv(JCTree.JCExpression tree,
Env<AttrContext> env)
tree - The bracket expression.env - The environment current outside of the bracket.
public Env<AttrContext> escapeEnv(JCTree tree,
Env<AttrContext> env)
tree - The escape expression.env - The environment current outside of the escape.
Type classEnter(JCTree tree,
Env<AttrContext> env)
tree - The tree to be visited.env - The environment visitor argument.
<T extends JCTree> List<Type> classEnter(List<T> trees,
Env<AttrContext> env)
public void visitTopLevel(JCTree.JCCompilationUnit tree)
visitTopLevel in class JCTree.Visitorpublic void visitClassDef(JCTree.JCClassDecl tree)
visitClassDef in class JCTree.Visitor
private static boolean classNameMatchesFileName(Symbol.ClassSymbol c,
Env<AttrContext> env)
protected void duplicateClass(JCDiagnostic.DiagnosticPosition pos,
Symbol.ClassSymbol c)
public void visitTypeParameter(JCTree.JCTypeParameter tree)
visitTypeParameter in class JCTree.Visitorpublic void visitTree(JCTree tree)
visitTree in class JCTree.Visitorpublic void main(List<JCTree.JCCompilationUnit> trees)
trees - The list of trees to be processed.
public void complete(List<JCTree.JCCompilationUnit> trees,
Symbol.ClassSymbol c)
trees - The list of trees to be processed.c - The class symbol to be processed.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||