|
||||||||||
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 | |
---|---|
protected static Context.Key<Enter> |
enterKey
|
protected Env<AttrContext> |
env
Visitor argument: the current environment. |
Constructor Summary | |
---|---|
protected |
Enter(Context context)
|
Method Summary | |
---|---|
Env<AttrContext> |
classEnv(JCTree.JCClassDecl tree,
Env<AttrContext> env)
Create a fresh environment for class bodies. |
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. |
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. |
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 com.sun.tools.javac.tree.JCTree.Visitor |
---|
visitAnnotation, visitApply, visitAssert, visitAssign, visitAssignop, visitBinary, visitBlock, visitBreak, visitCase, visitCatch, visitConditional, visitContinue, visitDoLoop, visitErroneous, visitExec, visitForeachLoop, visitForLoop, visitIdent, visitIf, visitImport, visitIndexed, visitLabelled, visitLetExpr, visitLiteral, visitMethodDef, visitModifiers, visitNewArray, visitNewClass, visitParens, visitReturn, visitSelect, visitSkip, visitSwitch, visitSynchronized, visitThrow, visitTry, visitTypeApply, visitTypeArray, visitTypeBoundKind, visitTypeCast, visitTypeIdent, visitTypeTest, visitUnary, visitVarDef, visitWhileLoop, visitWildcard |
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
protected Env<AttrContext> env
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.public Env<AttrContext> getTopLevelEnv(JCTree.JCCompilationUnit tree)
public void visitTopLevel(JCTree.JCCompilationUnit tree)
visitTopLevel
in class JCTree.Visitor
public void visitClassDef(JCTree.JCClassDecl tree)
visitClassDef
in class JCTree.Visitor
protected void duplicateClass(JCDiagnostic.DiagnosticPosition pos, Symbol.ClassSymbol c)
public void visitTypeParameter(JCTree.JCTypeParameter tree)
visitTypeParameter
in class JCTree.Visitor
public void visitTree(JCTree tree)
visitTree
in class JCTree.Visitor
public 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 |