| java.lang.Object com.sun.tools.javac.tree.JCTree com.sun.tools.javac.jvm.Gen
Gen | public class Gen extends JCTree.Visitor (Code) | | This pass maps flat Java (i.e. without inner classes) to bytecodes.
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 :abstract class GenFinalizer | |
Inner Class :static class GenContext | |
Field Summary | |
Env<GenContext> | env Visitor argument: The current environment. | final protected static Context.Key<Gen> | genKey | Type | pt Visitor argument: The expected type (prototype). | Item | result Visitor result: The item representing the computed value. |
Constructor Summary | |
protected | Gen(Context context) |
Method Summary | |
void | appendString(JCTree tree) Append value (on tos) to string buffer (on tos - 1). | void | appendStrings(JCTree tree) Add all strings in tree to string buffer. | Symbol | binaryQualifier(Symbol sym, Type site) Construct a symbol to reflect the qualifying type that should
appear in the byte code as per JLS 13.1. | void | bufferToString(DiagnosticPosition pos) Convert string buffer on tos to string. | void | callMethod(DiagnosticPosition pos, Type site, Name name, List<Type> argtypes, boolean isStatic) Generate code to call a non-private method or constructor. | Item | completeBinop(JCTree lhs, JCTree rhs, OperatorSymbol operator) Complete generating code for operation, with left operand
already on stack. | void | emitMinusOne(int tc) Generate code to load -1 of the given type code (either int or long). | void | endFinalizerGap(Env<GenContext> env) Mark end of gap in catch-all range for finalizer. | void | endFinalizerGaps(Env<GenContext> from, Env<GenContext> to) Mark end of all gaps in catch-all ranges for finalizers of environments
lying between, and including to two environments. | int | estimateCodeComplexity(JCTree tree) Very roughly estimate the number of instructions needed for
the given tree. | public void | genArgs(List<JCExpression> trees, List<Type> pts) Derived visitor method: generate code for a list of method arguments.
Parameters: trees - The argument expressions to be visited. Parameters: pts - The expression's expected types (i.e. | void | genCatch(JCCatch tree, Env<GenContext> env, int startpc, int endpc, List<Integer> gaps) Generate code for a catch clause. | public boolean | genClass(Env<AttrContext> env, JCClassDecl cdef) Generate code for a class definition.
Parameters: env - The attribution environment that belongs to theoutermost class containing this class definition.We need this for resolving some additional symbols. Parameters: cdef - The tree representing the class definition. | public CondItem | genCond(JCTree tree, int crtFlags) Derived visitor method: check whether CharacterRangeTable
should be emitted, if so, put a new entry into CRTable
and call method to generate bytecode. | public CondItem | genCond(JCTree _tree, boolean markBranches) Derived visitor method: generate code for a boolean
expression in a control-flow context. | public void | genDef(JCTree tree, Env<GenContext> env) Visitor method: generate code for a definition, catching and reporting
any completion failures. | public Item | genExpr(JCTree tree, Type pt) Visitor method: generate code for an expression, catching and reporting
any completion failures. | void | genFinalizer(Env<GenContext> env) Generate code to invoke the finalizer associated with given
environment. | void | genMethod(JCMethodDecl tree, Env<GenContext> env, boolean fatcode) Generate code for a method.
Parameters: tree - The tree representing the method definition. Parameters: env - The environment current for the method body. Parameters: fatcode - A flag that indicates whether all jumps arewithin 32K. | public void | genStat(JCTree tree, Env<GenContext> env, int crtFlags) Derived visitor method: check whether CharacterRangeTable
should be emitted, if so, put a new entry into CRTable
and call method to generate bytecode. | public void | genStat(JCTree tree, Env<GenContext> env) Derived visitor method: generate code for a statement. | public void | genStats(List<JCStatement> trees, Env<GenContext> env, int crtFlags) Derived visitor method: check whether CharacterRangeTable
should be emitted, if so, put a new entry into CRTable
and call method to generate bytecode. | public void | genStats(List<? extends JCTree> trees, Env<GenContext> env) Derived visitor method: generate code for a list of statements. | void | genTry(JCTree body, List<JCCatch> catchers, Env<GenContext> env) | Symbol | getStringBufferAppend(JCTree tree, Type t) | boolean | hasFinally(JCTree target, Env<GenContext> env) | void | implementInterfaceMethods(ClassSymbol c) Add abstract methods for all methods defined in one of
the interfaces of a given class,
provided they are not already implemented in the class. | void | implementInterfaceMethods(ClassSymbol c, ClassSymbol site) Add abstract methods for all methods defined in one of
the interfaces of a given class,
provided they are not already implemented in the class. | public static Gen | instance(Context context) | void | loadIntConst(int n) Generate code to load an integer constant. | Item | makeNewArray(DiagnosticPosition pos, Type type, int ndims) Generate code to create an array with given element type and number
of dimensions. | int | makeRef(DiagnosticPosition pos, Type type) Insert a reference to given type in the constant pool,
checking for an array with too many dimensions;
return the reference's index. | void | makeStringBuffer(DiagnosticPosition pos) Make a new string buffer. | LocalItem | makeTemp(Type type) Create a tempory variable. | List<JCTree> | normalizeDefs(List<JCTree> defs, ClassSymbol c) Distribute member initializer code into constructors and
method. | void | normalizeMethod(JCMethodDecl md, List<JCStatement> initCode) Insert instance initializer code into initial constructor. | public static int | one(int tc) The opcode that loads a one constant of a given type code. | static void | qsort2(int[] keys, int[] values, int lo, int hi) | void | registerCatch(DiagnosticPosition pos, int startpc, int endpc, int handler_pc, int catch_type) Register a catch clause in the "Exceptions" code-attribute. | Env<GenContext> | unwind(JCTree target, Env<GenContext> env) Generate code to call all finalizers of structures aborted by
a non-local
exit. | public void | visitApply(JCMethodInvocation tree) | public void | visitAssign(JCAssign tree) | public void | visitAssignop(JCAssignOp tree) | public void | visitBinary(JCBinary tree) | public void | visitBlock(JCBlock tree) | public void | visitBreak(JCBreak tree) | public void | visitConditional(JCConditional tree) | public void | visitContinue(JCContinue tree) | public void | visitDoLoop(JCDoWhileLoop tree) | public void | visitExec(JCExpressionStatement tree) | public void | visitForLoop(JCForLoop tree) | public void | visitForeachLoop(JCEnhancedForLoop tree) | public void | visitIdent(JCIdent tree) | public void | visitIf(JCIf tree) | public void | visitIndexed(JCArrayAccess tree) | public void | visitLabelled(JCLabeledStatement tree) | public void | visitLetExpr(LetExpr tree) | public void | visitLiteral(JCLiteral tree) | public void | visitMethodDef(JCMethodDecl tree) | public void | visitNewArray(JCNewArray tree) | public void | visitNewClass(JCNewClass tree) | public void | visitParens(JCParens tree) | public void | visitReturn(JCReturn tree) | public void | visitSelect(JCFieldAccess tree) | public void | visitSkip(JCSkip tree) | public void | visitSwitch(JCSwitch tree) | public void | visitSynchronized(JCSynchronized tree) | public void | visitThrow(JCThrow tree) | public void | visitTry(JCTry tree) | public void | visitTypeCast(JCTypeCast tree) | public void | visitTypeTest(JCInstanceOf tree) | public void | visitUnary(JCUnary tree) | public void | visitVarDef(JCVariableDecl tree) | public void | visitWhileLoop(JCWhileLoop tree) | public void | visitWildcard(JCWildcard tree) | public static int | zero(int tc) The opcode that loads a zero constant of a given type code. |
env | Env<GenContext> env(Code) | | Visitor argument: The current environment.
|
pt | Type pt(Code) | | Visitor argument: The expected type (prototype).
|
result | Item result(Code) | | Visitor result: The item representing the computed value.
|
appendString | void appendString(JCTree tree)(Code) | | Append value (on tos) to string buffer (on tos - 1).
|
appendStrings | void appendStrings(JCTree tree)(Code) | | Add all strings in tree to string buffer.
|
binaryQualifier | Symbol binaryQualifier(Symbol sym, Type site)(Code) | | Construct a symbol to reflect the qualifying type that should
appear in the byte code as per JLS 13.1.
For target >= 1.2: Clone a method with the qualifier as owner (except
for those cases where we need to work around VM bugs).
For target <= 1.1: If qualified variable or method is defined in a
non-accessible class, clone it with the qualifier class as owner.
Parameters: sym - The accessed symbol Parameters: site - The qualifier's type. |
bufferToString | void bufferToString(DiagnosticPosition pos)(Code) | | Convert string buffer on tos to string.
|
callMethod | void callMethod(DiagnosticPosition pos, Type site, Name name, List<Type> argtypes, boolean isStatic)(Code) | | Generate code to call a non-private method or constructor.
Parameters: pos - Position to be used for error reporting. Parameters: site - The type of which the method is a member. Parameters: name - The method's name. Parameters: argtypes - The method's argument types. Parameters: isStatic - A flag that indicates whether we call astatic or instance method. |
completeBinop | Item completeBinop(JCTree lhs, JCTree rhs, OperatorSymbol operator)(Code) | | Complete generating code for operation, with left operand
already on stack.
Parameters: lhs - The tree representing the left operand. Parameters: rhs - The tree representing the right operand. Parameters: operator - The operator symbol. |
emitMinusOne | void emitMinusOne(int tc)(Code) | | Generate code to load -1 of the given type code (either int or long).
Parameters: tc - The given type code (@see ByteCode). |
endFinalizerGap | void endFinalizerGap(Env<GenContext> env)(Code) | | Mark end of gap in catch-all range for finalizer.
Parameters: env - the environment which might contain the finalizer(if it does, env.info.gaps != null). |
endFinalizerGaps | void endFinalizerGaps(Env<GenContext> from, Env<GenContext> to)(Code) | | Mark end of all gaps in catch-all ranges for finalizers of environments
lying between, and including to two environments.
Parameters: from - the most deeply nested environment to mark Parameters: to - the least deeply nested environment to mark |
estimateCodeComplexity | int estimateCodeComplexity(JCTree tree)(Code) | | Very roughly estimate the number of instructions needed for
the given tree.
|
genArgs | public void genArgs(List<JCExpression> trees, List<Type> pts)(Code) | | Derived visitor method: generate code for a list of method arguments.
Parameters: trees - The argument expressions to be visited. Parameters: pts - The expression's expected types (i.e. the formal parametertypes of the invoked method). |
genCatch | void genCatch(JCCatch tree, Env<GenContext> env, int startpc, int endpc, List<Integer> gaps)(Code) | | Generate code for a catch clause.
Parameters: tree - The catch clause. Parameters: env - The environment current in the enclosing try. Parameters: startpc - Start pc of try-block. Parameters: endpc - End pc of try-block. |
genClass | public boolean genClass(Env<AttrContext> env, JCClassDecl cdef)(Code) | | Generate code for a class definition.
Parameters: env - The attribution environment that belongs to theoutermost class containing this class definition.We need this for resolving some additional symbols. Parameters: cdef - The tree representing the class definition. True if code is generated with no errors. |
genCond | public CondItem genCond(JCTree tree, int crtFlags)(Code) | | Derived visitor method: check whether CharacterRangeTable
should be emitted, if so, put a new entry into CRTable
and call method to generate bytecode.
If not, just call method to generate bytecode.
See Also: Gen.genCond(Tree,boolean) Parameters: tree - The tree to be visited. Parameters: crtFlags - The CharacterRangeTable flagsindicating type of the entry. |
genCond | public CondItem genCond(JCTree _tree, boolean markBranches)(Code) | | Derived visitor method: generate code for a boolean
expression in a control-flow context.
Parameters: _tree - The expression to be visited. Parameters: markBranches - The flag to indicate that the condition isa flow controller so produced conditionsshould contain a proper tree to generateCharacterRangeTable branches for them. |
genDef | public void genDef(JCTree tree, Env<GenContext> env)(Code) | | Visitor method: generate code for a definition, catching and reporting
any completion failures.
Parameters: tree - The definition to be visited. Parameters: env - The environment current at the definition. |
genExpr | public Item genExpr(JCTree tree, Type pt)(Code) | | Visitor method: generate code for an expression, catching and reporting
any completion failures.
Parameters: tree - The expression to be visited. Parameters: pt - The expression's expected type (proto-type). |
genFinalizer | void genFinalizer(Env<GenContext> env)(Code) | | Generate code to invoke the finalizer associated with given
environment.
Any calls to finalizers are appended to the environments `cont' chain.
Mark beginning of gap in catch all range for finalizer.
|
genMethod | void genMethod(JCMethodDecl tree, Env<GenContext> env, boolean fatcode)(Code) | | Generate code for a method.
Parameters: tree - The tree representing the method definition. Parameters: env - The environment current for the method body. Parameters: fatcode - A flag that indicates whether all jumps arewithin 32K. We first invoke this method underthe assumption that fatcode == false, i.e. alljumps are within 32K. If this fails, fatcodeis set to true and we try again. |
genStat | public void genStat(JCTree tree, Env<GenContext> env, int crtFlags)(Code) | | Derived visitor method: check whether CharacterRangeTable
should be emitted, if so, put a new entry into CRTable
and call method to generate bytecode.
If not, just call method to generate bytecode.
See Also: Gen.genStat(Tree,Env) Parameters: tree - The tree to be visited. Parameters: env - The environment to use. Parameters: crtFlags - The CharacterRangeTable flagsindicating type of the entry. |
genStat | public void genStat(JCTree tree, Env<GenContext> env)(Code) | | Derived visitor method: generate code for a statement.
|
genStats | public void genStats(List<JCStatement> trees, Env<GenContext> env, int crtFlags)(Code) | | Derived visitor method: check whether CharacterRangeTable
should be emitted, if so, put a new entry into CRTable
and call method to generate bytecode.
If not, just call method to generate bytecode.
See Also: Gen.genStats(List,Env) Parameters: trees - The list of trees to be visited. Parameters: env - The environment to use. Parameters: crtFlags - The CharacterRangeTable flagsindicating type of the entry. |
genStats | public void genStats(List<? extends JCTree> trees, Env<GenContext> env)(Code) | | Derived visitor method: generate code for a list of statements.
|
genTry | void genTry(JCTree body, List<JCCatch> catchers, Env<GenContext> env)(Code) | | Generate code for a try or synchronized statement
Parameters: body - The body of the try or synchronized statement. Parameters: catchers - The lis of catch clauses. Parameters: env - the environment current for the body. |
hasFinally | boolean hasFinally(JCTree target, Env<GenContext> env)(Code) | | Do any of the structures aborted by a non-local exit have
finalizers that require an empty stack?
Parameters: target - The tree representing the structure that's aborted Parameters: env - The environment current at the non-local exit. |
implementInterfaceMethods | void implementInterfaceMethods(ClassSymbol c)(Code) | | Add abstract methods for all methods defined in one of
the interfaces of a given class,
provided they are not already implemented in the class.
Parameters: c - The class whose interfaces are searched for methodsfor which Miranda methods should be added. |
implementInterfaceMethods | void implementInterfaceMethods(ClassSymbol c, ClassSymbol site)(Code) | | Add abstract methods for all methods defined in one of
the interfaces of a given class,
provided they are not already implemented in the class.
Parameters: c - The class whose interfaces are searched for methodsfor which Miranda methods should be added. Parameters: site - The class in which a definition may be needed. |
loadIntConst | void loadIntConst(int n)(Code) | | Generate code to load an integer constant.
Parameters: n - The integer to be loaded. |
makeNewArray | Item makeNewArray(DiagnosticPosition pos, Type type, int ndims)(Code) | | Generate code to create an array with given element type and number
of dimensions.
|
makeRef | int makeRef(DiagnosticPosition pos, Type type)(Code) | | Insert a reference to given type in the constant pool,
checking for an array with too many dimensions;
return the reference's index.
Parameters: type - The type for which a reference is inserted. |
makeStringBuffer | void makeStringBuffer(DiagnosticPosition pos)(Code) | | Make a new string buffer.
|
makeTemp | LocalItem makeTemp(Type type)(Code) | | Create a tempory variable.
Parameters: type - The variable's type. |
normalizeDefs | List<JCTree> normalizeDefs(List<JCTree> defs, ClassSymbol c)(Code) | | Distribute member initializer code into constructors and
method.
Parameters: defs - The list of class member declarations. Parameters: c - The enclosing class. |
normalizeMethod | void normalizeMethod(JCMethodDecl md, List<JCStatement> initCode)(Code) | | Insert instance initializer code into initial constructor.
Parameters: md - The tree potentially representing aconstructor's definition. Parameters: initCode - The list of instance initializer statements. |
one | public static int one(int tc)(Code) | | The opcode that loads a one constant of a given type code.
Parameters: tc - The given type code (@see ByteCode). |
qsort2 | static void qsort2(int[] keys, int[] values, int lo, int hi)(Code) | | Sort (int) arrays of keys and values
|
registerCatch | void registerCatch(DiagnosticPosition pos, int startpc, int endpc, int handler_pc, int catch_type)(Code) | | Register a catch clause in the "Exceptions" code-attribute.
|
unwind | Env<GenContext> unwind(JCTree target, Env<GenContext> env)(Code) | | Generate code to call all finalizers of structures aborted by
a non-local
exit. Return target environment of the non-local exit.
Parameters: target - The tree representing the structure that's aborted Parameters: env - The environment current at the non-local exit. |
visitApply | public void visitApply(JCMethodInvocation tree)(Code) | | |
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) | | |
visitBreak | public void visitBreak(JCBreak tree)(Code) | | |
visitConditional | public void visitConditional(JCConditional tree)(Code) | | |
visitContinue | public void visitContinue(JCContinue tree)(Code) | | |
visitDoLoop | public void visitDoLoop(JCDoWhileLoop tree)(Code) | | |
visitExec | public void visitExec(JCExpressionStatement tree)(Code) | | |
visitForLoop | public void visitForLoop(JCForLoop tree)(Code) | | |
visitForeachLoop | public void visitForeachLoop(JCEnhancedForLoop tree)(Code) | | |
visitIdent | public void visitIdent(JCIdent tree)(Code) | | |
visitIf | public void visitIf(JCIf tree)(Code) | | |
visitIndexed | public void visitIndexed(JCArrayAccess tree)(Code) | | |
visitLabelled | public void visitLabelled(JCLabeledStatement tree)(Code) | | |
visitLetExpr | public void visitLetExpr(LetExpr tree)(Code) | | |
visitLiteral | public void visitLiteral(JCLiteral 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) | | |
visitReturn | public void visitReturn(JCReturn tree)(Code) | | |
visitSelect | public void visitSelect(JCFieldAccess tree)(Code) | | |
visitSkip | public void visitSkip(JCSkip tree)(Code) | | |
visitSwitch | public void visitSwitch(JCSwitch tree)(Code) | | |
visitSynchronized | public void visitSynchronized(JCSynchronized tree)(Code) | | |
visitThrow | public void visitThrow(JCThrow tree)(Code) | | |
visitTry | public void visitTry(JCTry tree)(Code) | | |
visitTypeCast | public void visitTypeCast(JCTypeCast tree)(Code) | | |
visitTypeTest | public void visitTypeTest(JCInstanceOf tree)(Code) | | |
visitUnary | public void visitUnary(JCUnary tree)(Code) | | |
visitVarDef | public void visitVarDef(JCVariableDecl tree)(Code) | | |
visitWhileLoop | public void visitWhileLoop(JCWhileLoop tree)(Code) | | |
visitWildcard | public void visitWildcard(JCWildcard tree)(Code) | | |
zero | public static int zero(int tc)(Code) | | The opcode that loads a zero constant of a given type code.
Parameters: tc - The given type code (@see ByteCode). |
|
|