| java.lang.Object com.sun.tools.javac.tree.JCTree com.sun.tools.javac.tree.TreeTranslator com.sun.tools.javac.comp.Lower
Lower | public class Lower extends TreeTranslator (Code) | | This pass translates away some syntactic sugar: inner classes,
class literals, assertions, foreach loops, etc.
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.
|
Inner Class :class FreeVarCollector extends TreeScanner | |
Inner Class :class EnumMapping | |
Inner Class :interface TreeBuilder | |
Method Summary | |
JCTree | abstractLval(JCTree lval, TreeBuilder builder) | JCTree | abstractRval(JCTree rval, Type type, TreeBuilder builder) Construct an expression using the builder, with the given rval
expression as an argument to the builder. | JCTree | abstractRval(JCTree rval, TreeBuilder builder) | JCExpression | access(Symbol sym, JCExpression tree, JCExpression enclOp, boolean refSuper) Ensure that identifier is accessible, return tree accessing the identifier. | JCExpression | access(JCExpression tree) Ensure that identifier is accessible, return tree accessing the identifier. | JCExpression | accessBase(DiagnosticPosition pos, Symbol sym) The qualifier to be used for accessing a symbol in an outer class. | ClassSymbol | accessClass(Symbol sym, boolean protAccess, JCTree tree) The class in which an access method for given symbol goes. | Symbol | accessConstructor(DiagnosticPosition pos, Symbol constr) Return access constructor for a private constructor,
or the constructor itself, if no access constructor is needed. | JCTree | accessConstructorDef(int pos, Symbol constr, MethodSymbol accessor) Construct definition of an access constructor. | ClassSymbol | accessConstructorTag() Return an anonymous class nested in this toplevel class. | JCTree | accessDef(int pos, Symbol vsym, MethodSymbol accessor, int acode) Construct definition of an access method. | Name | accessName(int anum, int acode) The name of the access method with number `anum' and access code `acode'. | MethodSymbol | accessSymbol(Symbol sym, JCTree tree, JCTree enclOp, boolean protAccess, boolean refSuper) Return access symbol for a private or protected symbol from an inner class. | List<JCExpression> | boxArgs(List<Type> parameters, List<JCExpression> _args, Type varargsElement) | T | boxIfNeeded(T tree, Type type) Expand a boxing or unboxing conversion if needed. | JCExpression | boxPrimitive(JCExpression tree) Box up a single primitive expression. | JCExpression | boxPrimitive(JCExpression tree, Type box) Box up a single primitive expression. | JCClassDecl | classDef(ClassSymbol c) Map a class symbol to its definition. | JCBlock | classDollarSymBody(DiagnosticPosition pos, JCMethodDecl md) Generate code for class$(String name). | List<JCVariableDecl> | freevarDefs(int pos, List<VarSymbol> freevars, Symbol owner) Proxy definitions for all free variables in given list, in reverse order. | List<VarSymbol> | freevars(ClassSymbol c) Return the variables accessed from within a local class, which
are declared in the local class' owner. | JCStatement | initField(int pos, Name name) Return tree simulating the assignment , where
name is the name of a free variable. | JCStatement | initOuterThis(int pos) Return tree simulating the assignment . | public static Lower | instance(Context context) | JCExpression | loadFreevar(DiagnosticPosition pos, VarSymbol v) | List<JCExpression> | loadFreevars(DiagnosticPosition pos, List<VarSymbol> freevars) Return a list of trees that load the free variables in given list,
in reverse order. | JCTree | lowerBoxedPostop(JCUnary tree) | void | makeAccessible(Symbol sym) Add all required access methods for a private symbol to enclosing class. | JCAssignOp | makeAssignop(int optag, JCTree lhs, JCTree rhs) Make an attributed assignop expression. | JCBinary | makeBinary(int optag, JCExpression lhs, JCExpression rhs) Make an attributed binary expression. | JCTree | makeComma(JCTree expr1, JCTree expr2) | ClassSymbol | makeEmptyClass(long flags, ClassSymbol owner) Create an empty anonymous class definition and enter and complete
its symbol. | JCExpression | makeLit(Type type, Object value) Make an attributed tree representing a literal. | JCNewClass | makeNewClass(Type ctype, List<JCExpression> args) Make an attributed class instance creation expression. | JCExpression | makeNull() Make an attributed tree representing null. | JCExpression | makeOuterThis(DiagnosticPosition pos, TypeSymbol c) Construct a tree that represents the outer instance
. | JCExpression | makeOwnerThis(DiagnosticPosition pos, Symbol sym, boolean preciseMatch) Construct a tree that represents the closest outer instance
such that the given symbol is a member of C. | JCExpression | makeOwnerThisN(DiagnosticPosition pos, Symbol sym, boolean preciseMatch) Similar to makeOwnerThis but will never pick "this". | JCExpression | makeString(JCExpression tree) Convert tree into string object, unless it has already a
reference type.. | JCExpression | makeThis(DiagnosticPosition pos, TypeSymbol c) Construct a tree simulating the expression . | JCUnary | makeUnary(int optag, JCExpression arg) Make an attributed unary expression. | TreeMaker | make_at(DiagnosticPosition pos) Equivalent to make.at(pos.getStartPosition()) with side effect of caching
pos as make_pos, for use in diagnostics. | EnumMapping | mapForEnum(DiagnosticPosition pos, TypeSymbol enumClass) | boolean | needsPrivateAccess(Symbol sym) | boolean | needsProtectedAccess(Symbol sym, JCTree tree) | JCVariableDecl | outerThisDef(int pos, Symbol owner) Definition for this$n field. | Name | outerThisName(Type type, Symbol owner) | Name | proxyName(Name name) The name of a free variable proxy. | public T | translate(T tree) Visitor method: Translate a single node. | public T | translate(T tree, Type type) Visitor method: Translate a single node, boxing or unboxing if needed. | public T | translate(T tree, JCExpression enclOp) Visitor method: Translate tree. | public List<T> | translate(List<T> trees, JCExpression enclOp) Visitor method: Translate list of trees. | public List<T> | translate(List<T> trees, Type type) Visitor method: Translate list of trees. | public List<JCTree> | translateTopLevelClass(Env<AttrContext> env, JCTree cdef, TreeMaker make) Translate a toplevel class and return a list consisting of
the translated class and translated versions of all inner classes. | JCExpression | unbox(JCExpression tree, Type primitive) Unbox an object to a primitive value. | public void | visitAnnotation(JCAnnotation tree) | public void | visitApply(JCMethodInvocation tree) | public void | visitAssert(JCAssert tree) Visitor method for assert statements. | public void | visitAssign(JCAssign tree) | public void | visitAssignop(JCAssignOp tree) | public void | visitBinary(JCBinary tree) | public void | visitBlock(JCBlock tree) | public void | visitClassDef(JCClassDecl tree) | public void | visitConditional(JCConditional tree) Visitor method for conditional expressions. | public void | visitDoLoop(JCDoWhileLoop tree) | public JCTree | visitEnumSwitch(JCSwitch tree) | public void | visitForLoop(JCForLoop tree) | public void | visitForeachLoop(JCEnhancedForLoop tree) Translate away the foreach loop. | public void | visitIdent(JCIdent tree) | public void | visitIf(JCIf tree) Visitor method for if statements. | public void | visitIndexed(JCArrayAccess tree) | public void | visitLetExpr(LetExpr tree) | public void | visitMethodDef(JCMethodDecl tree) | public void | visitNewArray(JCNewArray tree) | public void | visitNewClass(JCNewClass tree) | public void | visitParens(JCParens tree) Visitor method for parenthesized expressions. | public void | visitReturn(JCReturn tree) | public void | visitSelect(JCFieldAccess tree) | public void | visitSwitch(JCSwitch tree) | public void | visitTopLevel(JCCompilationUnit tree) | public void | visitTypeCast(JCTypeCast tree) | public void | visitUnary(JCUnary tree) | public void | visitVarDef(JCVariableDecl tree) | public void | visitWhileLoop(JCWhileLoop tree) |
actualSymbols | Map<Symbol, Symbol> actualSymbols(Code) | | A hash table mapping virtual accessed symbols in outer subclasses
to the actually referred symbol in superclasses.
|
attrEnv | Env<AttrContext> attrEnv(Code) | | Environment for symbol lookup, set by translateTopLevelClass.
|
classMap | ClassMap classMap(Code) | | |
classdefs | Map<ClassSymbol, JCClassDecl> classdefs(Code) | | A hash table mapping local classes to their definitions.
|
currentClass | ClassSymbol currentClass(Code) | | The currently enclosing class.
|
currentMethodDef | JCMethodDecl currentMethodDef(Code) | | The current method definition.
|
currentMethodSym | MethodSymbol currentMethodSym(Code) | | The current method symbol.
|
endPositions | Map<JCTree, Integer> endPositions(Code) | | A hash table mapping syntax trees to their ending source positions.
|
enumSwitchMap | Map<TypeSymbol, EnumMapping> enumSwitchMap(Code) | | |
freevarCache | Map<ClassSymbol, List<VarSymbol>> freevarCache(Code) | | A hash table mapping class symbols to lists of free variables.
accessed by them. Only free variables of the method immediately containing
a class are associated with that class.
|
outerThisStack | List<VarSymbol> outerThisStack(Code) | | A stack containing the this$n field of the currently translated
classes (if needed) in innermost first order.
Inside a constructor, proxies and any this$n symbol are duplicated
in an additional innermost scope, where they represent the constructor
parameters.
|
outermostClassDef | JCClassDecl outermostClassDef(Code) | | The currently enclosing outermost class definition.
|
outermostMemberDef | JCTree outermostMemberDef(Code) | | The currently enclosing outermost member definition.
|
proxies | Scope proxies(Code) | | A scope containing all free variable proxies for currently translated
class, as well as its this$n symbol (if needed).
Proxy scopes are nested in the same way classes are.
Inside a constructor, proxies and any this$n symbol are duplicated
in an additional innermost scope, where they represent the constructor
parameters.
|
abstractRval | JCTree abstractRval(JCTree rval, Type type, TreeBuilder builder)(Code) | | Construct an expression using the builder, with the given rval
expression as an argument to the builder. However, the rval
expression must be computed only once, even if used multiple
times in the result of the builder. We do that by
constructing a "let" expression that saves the rvalue into a
temporary variable and then uses the temporary variable in
place of the expression built by the builder. The complete
resulting expression is of the form
(let TYPE TEMP = RVAL;
in (BUILDER(TEMP)))
where TEMP is a newly declared variable
in the let expression.
|
access | JCExpression access(Symbol sym, JCExpression tree, JCExpression enclOp, boolean refSuper)(Code) | | Ensure that identifier is accessible, return tree accessing the identifier.
Parameters: sym - The accessed symbol. Parameters: tree - The tree referring to the symbol. Parameters: enclOp - The closest enclosing operation node of tree,null if tree is not a subtree of an operation. Parameters: refSuper - Is access via a (qualified) C.super? |
access | JCExpression access(JCExpression tree)(Code) | | Ensure that identifier is accessible, return tree accessing the identifier.
Parameters: tree - The identifier tree. |
accessBase | JCExpression accessBase(DiagnosticPosition pos, Symbol sym)(Code) | | The qualifier to be used for accessing a symbol in an outer class.
This is either C.sym or C.this.sym, depending on whether or not
sym is static.
Parameters: sym - The accessed symbol. |
accessClass | ClassSymbol accessClass(Symbol sym, boolean protAccess, JCTree tree)(Code) | | The class in which an access method for given symbol goes.
Parameters: sym - The access symbol Parameters: protAccess - Is access to a protected symbol in anotherpackage? |
accessConstructor | Symbol accessConstructor(DiagnosticPosition pos, Symbol constr)(Code) | | Return access constructor for a private constructor,
or the constructor itself, if no access constructor is needed.
Parameters: pos - The position to report diagnostics, if any. Parameters: constr - The private constructor. |
accessConstructorDef | JCTree accessConstructorDef(int pos, Symbol constr, MethodSymbol accessor)(Code) | | Construct definition of an access constructor.
Parameters: pos - The source code position of the definition. Parameters: constr - The private constructor. Parameters: accessor - The access method for the constructor. |
accessConstructorTag | ClassSymbol accessConstructorTag()(Code) | | Return an anonymous class nested in this toplevel class.
|
accessDef | JCTree accessDef(int pos, Symbol vsym, MethodSymbol accessor, int acode)(Code) | | Construct definition of an access method.
Parameters: pos - The source code position of the definition. Parameters: vsym - The private or protected symbol. Parameters: accessor - The access method for the symbol. Parameters: acode - The access code. |
accessName | Name accessName(int anum, int acode)(Code) | | The name of the access method with number `anum' and access code `acode'.
|
accessSymbol | MethodSymbol accessSymbol(Symbol sym, JCTree tree, JCTree enclOp, boolean protAccess, boolean refSuper)(Code) | | Return access symbol for a private or protected symbol from an inner class.
Parameters: sym - The accessed private symbol. Parameters: tree - The accessing tree. Parameters: enclOp - The closest enclosing operation node of tree,null if tree is not a subtree of an operation. Parameters: protAccess - Is access to a protected symbol in anotherpackage? Parameters: refSuper - Is access via a (qualified) C.super? |
boxIfNeeded | T boxIfNeeded(T tree, Type type)(Code) | | Expand a boxing or unboxing conversion if needed.
|
boxPrimitive | JCExpression boxPrimitive(JCExpression tree)(Code) | | Box up a single primitive expression.
|
boxPrimitive | JCExpression boxPrimitive(JCExpression tree, Type box)(Code) | | Box up a single primitive expression.
|
classDef | JCClassDecl classDef(ClassSymbol c)(Code) | | Map a class symbol to its definition.
Parameters: c - The class symbol of which we want to determine the definition. |
classDollarSymBody | JCBlock classDollarSymBody(DiagnosticPosition pos, JCMethodDecl md)(Code) | | Generate code for class$(String name).
|
freevarDefs | List<JCVariableDecl> freevarDefs(int pos, List<VarSymbol> freevars, Symbol owner)(Code) | | Proxy definitions for all free variables in given list, in reverse order.
Parameters: pos - The source code position of the definition. Parameters: freevars - The free variables. Parameters: owner - The class in which the definitions go. |
freevars | List<VarSymbol> freevars(ClassSymbol c)(Code) | | Return the variables accessed from within a local class, which
are declared in the local class' owner.
(in reverse order of first access).
|
initField | JCStatement initField(int pos, Name name)(Code) | | Return tree simulating the assignment , where
name is the name of a free variable.
|
initOuterThis | JCStatement initOuterThis(int pos)(Code) | | Return tree simulating the assignment .
|
loadFreevar | JCExpression loadFreevar(DiagnosticPosition pos, VarSymbol v)(Code) | | |
loadFreevars | List<JCExpression> loadFreevars(DiagnosticPosition pos, List<VarSymbol> freevars)(Code) | | Return a list of trees that load the free variables in given list,
in reverse order.
Parameters: pos - The source code position to be used for the trees. Parameters: freevars - The list of free variables. |
lowerBoxedPostop | JCTree lowerBoxedPostop(JCUnary tree)(Code) | | Lower a tree of the form e++ or e-- where e is an object type
|
makeAccessible | void makeAccessible(Symbol sym)(Code) | | Add all required access methods for a private symbol to enclosing class.
Parameters: sym - The symbol. |
makeAssignop | JCAssignOp makeAssignop(int optag, JCTree lhs, JCTree rhs)(Code) | | Make an attributed assignop expression.
Parameters: optag - The operators tree tag. Parameters: lhs - The operator's left argument. Parameters: rhs - The operator's right argument. |
makeBinary | JCBinary makeBinary(int optag, JCExpression lhs, JCExpression rhs)(Code) | | Make an attributed binary expression.
Parameters: optag - The operators tree tag. Parameters: lhs - The operator's left argument. Parameters: rhs - The operator's right argument. |
makeEmptyClass | ClassSymbol makeEmptyClass(long flags, ClassSymbol owner)(Code) | | Create an empty anonymous class definition and enter and complete
its symbol. Return the class definition's symbol.
and create
Parameters: flags - The class symbol's flags Parameters: owner - The class symbol's owner |
makeLit | JCExpression makeLit(Type type, Object value)(Code) | | Make an attributed tree representing a literal. This will be an
Ident node in the case of boolean literals, a Literal node in all
other cases.
Parameters: type - The literal's type. Parameters: value - The literal's value. |
makeNewClass | JCNewClass makeNewClass(Type ctype, List<JCExpression> args)(Code) | | Make an attributed class instance creation expression.
Parameters: ctype - The class type. Parameters: args - The constructor arguments. |
makeNull | JCExpression makeNull()(Code) | | Make an attributed tree representing null.
|
makeOuterThis | JCExpression makeOuterThis(DiagnosticPosition pos, TypeSymbol c)(Code) | | Construct a tree that represents the outer instance
. Never pick the current `this'.
Parameters: pos - The source code position to be used for the tree. Parameters: c - The qualifier class. |
makeOwnerThis | JCExpression makeOwnerThis(DiagnosticPosition pos, Symbol sym, boolean preciseMatch)(Code) | | Construct a tree that represents the closest outer instance
such that the given symbol is a member of C.
Parameters: pos - The source code position to be used for the tree. Parameters: sym - The accessed symbol. Parameters: preciseMatch - should we accept a type that is a subtype ofsym's owner, even if it doesn't contain symdue to hiding, overriding, or non-inheritancedue to protection? |
makeOwnerThisN | JCExpression makeOwnerThisN(DiagnosticPosition pos, Symbol sym, boolean preciseMatch)(Code) | | Similar to makeOwnerThis but will never pick "this".
|
makeString | JCExpression makeString(JCExpression tree)(Code) | | Convert tree into string object, unless it has already a
reference type..
|
makeThis | JCExpression makeThis(DiagnosticPosition pos, TypeSymbol c)(Code) | | Construct a tree simulating the expression .
Parameters: pos - The source code position to be used for the tree. Parameters: c - The qualifier class. |
makeUnary | JCUnary makeUnary(int optag, JCExpression arg)(Code) | | Make an attributed unary expression.
Parameters: optag - The operators tree tag. Parameters: arg - The operator's argument. |
make_at | TreeMaker make_at(DiagnosticPosition pos)(Code) | | Equivalent to make.at(pos.getStartPosition()) with side effect of caching
pos as make_pos, for use in diagnostics.
|
mapForEnum | EnumMapping mapForEnum(DiagnosticPosition pos, TypeSymbol enumClass)(Code) | | |
needsPrivateAccess | boolean needsPrivateAccess(Symbol sym)(Code) | | Do we need an access method to reference private symbol?
|
needsProtectedAccess | boolean needsProtectedAccess(Symbol sym, JCTree tree)(Code) | | Do we need an access method to reference symbol in other package?
|
outerThisDef | JCVariableDecl outerThisDef(int pos, Symbol owner)(Code) | | Definition for this$n field.
Parameters: pos - The source code position of the definition. Parameters: owner - The class in which the definition goes. |
outerThisName | Name outerThisName(Type type, Symbol owner)(Code) | | The name of a this$n field
Parameters: type - The class referenced by the this$n field |
proxyName | Name proxyName(Name name)(Code) | | The name of a free variable proxy.
|
translate | public T translate(T tree)(Code) | | Visitor method: Translate a single node.
Attach the source position from the old tree to its replacement tree.
|
translate | public T translate(T tree, Type type)(Code) | | Visitor method: Translate a single node, boxing or unboxing if needed.
|
translate | public T translate(T tree, JCExpression enclOp)(Code) | | Visitor method: Translate tree.
|
translate | public List<T> translate(List<T> trees, JCExpression enclOp)(Code) | | Visitor method: Translate list of trees.
|
translate | public List<T> translate(List<T> trees, Type type)(Code) | | Visitor method: Translate list of trees.
|
translateTopLevelClass | public List<JCTree> translateTopLevelClass(Env<AttrContext> env, JCTree cdef, TreeMaker make)(Code) | | Translate a toplevel class and return a list consisting of
the translated class and translated versions of all inner classes.
Parameters: env - The attribution environment current at the class definition.We need this for resolving some additional symbols. Parameters: cdef - The tree representing the class definition. |
unbox | JCExpression unbox(JCExpression tree, Type primitive)(Code) | | Unbox an object to a primitive value.
|
visitAnnotation | public void visitAnnotation(JCAnnotation tree)(Code) | | |
visitApply | public void visitApply(JCMethodInvocation tree)(Code) | | |
visitAssert | public void visitAssert(JCAssert tree)(Code) | | Visitor method for assert statements. Translate them away.
|
visitAssign | public void visitAssign(JCAssign tree)(Code) | | |
visitAssignop | public void visitAssignop(JCAssignOp tree)(Code) | | |
visitBinary | public void visitBinary(JCBinary tree)(Code) | | |
visitBlock | public void visitBlock(JCBlock tree)(Code) | | |
visitClassDef | public void visitClassDef(JCClassDecl tree)(Code) | | |
visitConditional | public void visitConditional(JCConditional tree)(Code) | | Visitor method for conditional expressions.
|
visitDoLoop | public void visitDoLoop(JCDoWhileLoop tree)(Code) | | |
visitEnumSwitch | public JCTree visitEnumSwitch(JCSwitch tree)(Code) | | |
visitForLoop | public void visitForLoop(JCForLoop tree)(Code) | | |
visitForeachLoop | public void visitForeachLoop(JCEnhancedForLoop tree)(Code) | | Translate away the foreach loop.
|
visitIdent | public void visitIdent(JCIdent tree)(Code) | | |
visitIf | public void visitIf(JCIf tree)(Code) | | Visitor method for if statements.
|
visitIndexed | public void visitIndexed(JCArrayAccess tree)(Code) | | |
visitLetExpr | public void visitLetExpr(LetExpr tree)(Code) | | |
visitMethodDef | public void visitMethodDef(JCMethodDecl tree)(Code) | | |
visitNewArray | public void visitNewArray(JCNewArray tree)(Code) | | |
visitNewClass | public void visitNewClass(JCNewClass tree)(Code) | | |
visitParens | public void visitParens(JCParens tree)(Code) | | Visitor method for parenthesized expressions.
If the subexpression has changed, omit the parens.
|
visitReturn | public void visitReturn(JCReturn tree)(Code) | | |
visitSelect | public void visitSelect(JCFieldAccess tree)(Code) | | |
visitSwitch | public void visitSwitch(JCSwitch tree)(Code) | | |
visitTopLevel | public void visitTopLevel(JCCompilationUnit tree)(Code) | | |
visitTypeCast | public void visitTypeCast(JCTypeCast tree)(Code) | | |
visitUnary | public void visitUnary(JCUnary tree)(Code) | | |
visitVarDef | public void visitVarDef(JCVariableDecl tree)(Code) | | |
visitWhileLoop | public void visitWhileLoop(JCWhileLoop tree)(Code) | | |
|
|