com.sun.tools.javac.jvm
Class Gen

java.lang.Object
  extended by com.sun.tools.javac.tree.JCTree.Visitor
      extended by com.sun.tools.javac.jvm.Gen

public class Gen
extends JCTree.Visitor

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.


Nested Class Summary
static class Gen.CodeSizeOverflow
          Thrown when the byte code size exceeds limit.
(package private) static class Gen.GenContext
          code generation contexts, to be used as type parameter for environments.
(package private)  class Gen.GenFinalizer
          An abstract class for finalizer generation.
 
Field Summary
private  Name accessDollar
           
private  boolean allowGenerics
          Switch: GJ mode?
private  Env<AttrContext> attrEnv
          Environment for symbol lookup, set by genClass
private  Check chk
           
private  Code code
          Code buffer, set by genMethod.
private  boolean debugCode
           
private  java.util.Map<JCTree,java.lang.Integer> endPositions
          A hash table mapping syntax trees to their ending source positions.
(package private)  Env<Gen.GenContext> env
          Visitor argument: The current environment.
private  boolean genCrt
           
private  boolean generateIproxies
          Set when Miranda method stubs are to be generated.
protected static Context.Key<Gen> genKey
           
private  Items items
          Items structure, set by genMethod.
private  int jsrlimit
          Default limit of (approximate) size of finalizer to inline.
private  boolean lineDebugInfo
          Switches
private  Log log
           
private  TreeMaker make
           
private  Type methodType
          A type that serves as the expected type for all method expressions.
private  Names names
           
private  int nerrs
          The number of code-gen errors in this class.
private  Pool pool
           
(package private)  Type pt
          Visitor argument: The expected type (prototype).
(package private)  Items.Item result
          Visitor result: The item representing the computed value.
private  Resolve rs
           
private  Code.StackMapFormat stackMap
          Format of stackmap tables to be generated.
private  java.util.Map<Type,Symbol> stringBufferAppend
           
private  Type stringBufferType
           
private  Symtab syms
           
private  Target target
           
private  JCTree.JCCompilationUnit toplevel
          The top level tree.
private  Types types
           
private  boolean useJsrLocally
          True if jsr is used.
private  boolean varDebugInfo
           
 
Constructor Summary
protected Gen(Context context)
           
 
Method Summary
private  void addAbstractMethod(Symbol.ClassSymbol c, Symbol.MethodSymbol m)
          Add an abstract methods to a class which implicitly implements a method defined in some interface implemented by the class.
private  void adjustAbstractMethod(Symbol.ClassSymbol c, Symbol.MethodSymbol pm, Symbol.MethodSymbol im)
           
(package private)  void appendString(JCTree tree)
          Append value (on tos) to string buffer (on tos - 1).
(package private)  void appendStrings(JCTree tree)
          Add all strings in tree to string buffer.
(package private)  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.
(package private)  void bufferToString(JCDiagnostic.DiagnosticPosition pos)
          Convert string buffer on tos to string.
(package private)  void callMethod(JCDiagnostic.DiagnosticPosition pos, Type site, Name name, List<Type> argtypes, boolean isStatic)
          Generate code to call a non-private method or constructor.
private  void checkDimension(JCDiagnostic.DiagnosticPosition pos, Type t)
          Check if the given type is an array with too many dimensions.
private  void checkStringConstant(JCDiagnostic.DiagnosticPosition pos, java.lang.Object constValue)
          Check a constant value and report if it is a string that is too large.
(package private)  Items.Item completeBinop(JCTree lhs, JCTree rhs, Symbol.OperatorSymbol operator)
          Complete generating code for operation, with left operand already on stack.
(package private)  void emitMinusOne(int tc)
          Generate code to load -1 of the given type code (either int or long).
(package private)  void endFinalizerGap(Env<Gen.GenContext> env)
          Mark end of gap in catch-all range for finalizer.
(package private)  void endFinalizerGaps(Env<Gen.GenContext> from, Env<Gen.GenContext> to)
          Mark end of all gaps in catch-all ranges for finalizers of environments lying between, and including to two environments.
(package private)  int estimateCodeComplexity(JCTree tree)
          Very roughly estimate the number of instructions needed for the given tree.
 void genArgs(List<JCTree.JCExpression> trees, List<Type> pts)
          Derived visitor method: generate code for a list of method arguments.
(package private)  void genCatch(JCTree.JCCatch tree, Env<Gen.GenContext> env, int startpc, int endpc, List<java.lang.Integer> gaps)
          Generate code for a catch clause.
 boolean genClass(Env<AttrContext> env, JCTree.JCClassDecl cdef)
          Generate code for a class definition.
 Items.CondItem genCond(JCTree _tree, boolean markBranches)
          Derived visitor method: generate code for a boolean expression in a control-flow context.
 Items.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.
 void genDef(JCTree tree, Env<Gen.GenContext> env)
          Visitor method: generate code for a definition, catching and reporting any completion failures.
 Items.Item genExpr(JCTree tree, Type pt)
          Visitor method: generate code for an expression, catching and reporting any completion failures.
(package private)  void genFinalizer(Env<Gen.GenContext> env)
          Generate code to invoke the finalizer associated with given environment.
private  void genLoop(JCTree.JCStatement loop, JCTree.JCStatement body, JCTree.JCExpression cond, List<JCTree.JCExpressionStatement> step, boolean testFirst)
          Generate code for a loop.
(package private)  void genMethod(JCTree.JCMethodDecl tree, Env<Gen.GenContext> env, boolean fatcode)
          Generate code for a method.
private  void genNullCheck(JCDiagnostic.DiagnosticPosition pos)
          Generate a null check from the object value at stack top.
 void genStat(JCTree tree, Env<Gen.GenContext> env)
          Derived visitor method: generate code for a statement.
 void genStat(JCTree tree, Env<Gen.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.
 void genStats(List<? extends JCTree> trees, Env<Gen.GenContext> env)
          Derived visitor method: generate code for a list of statements.
 void genStats(List<JCTree.JCStatement> trees, Env<Gen.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.
(package private)  void genTry(JCTree body, List<JCTree.JCCatch> catchers, Env<Gen.GenContext> env)
          Generate code for a try or synchronized statement
(package private)  Symbol getStringBufferAppend(JCTree tree, Type t)
           
(package private)  boolean hasFinally(JCTree target, Env<Gen.GenContext> env)
          Do any of the structures aborted by a non-local exit have finalizers that require an empty stack?
(package private)  void implementInterfaceMethods(Symbol.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.
(package private)  void implementInterfaceMethods(Symbol.ClassSymbol c, Symbol.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.
private  int initCode(JCTree.JCMethodDecl tree, Env<Gen.GenContext> env, boolean fatcode)
           
static Gen instance(Context context)
           
private  boolean isAccessSuper(JCTree.JCMethodDecl enclMethod)
          Is the given method definition an access method resulting from a qualified super? This is signified by an odd access code.
private  boolean isOddAccessName(Name name)
          Does given name start with "access$" and end in an odd digit?
(package private)  void loadIntConst(int n)
          Generate code to load an integer constant.
(package private)  Items.Item makeNewArray(JCDiagnostic.DiagnosticPosition pos, Type type, int ndims)
          Generate code to create an array with given element type and number of dimensions.
(package private)  int makeRef(JCDiagnostic.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.
(package private)  void makeStringBuffer(JCDiagnostic.DiagnosticPosition pos)
          Make a new string buffer.
(package private)  Items.LocalItem makeTemp(Type type)
          Create a tempory variable.
(package private)  List<JCTree> normalizeDefs(List<JCTree> defs, Symbol.ClassSymbol c)
          Distribute member initializer code into constructors and method.
(package private)  void normalizeMethod(JCTree.JCMethodDecl md, List<JCTree.JCStatement> initCode)
          Insert instance initializer code into initial constructor.
static int one(int tc)
          The opcode that loads a one constant of a given type code.
(package private) static void qsort2(int[] keys, int[] values, int lo, int hi)
          Sort (int) arrays of keys and values
(package private)  void registerCatch(JCDiagnostic.DiagnosticPosition pos, int startpc, int endpc, int handler_pc, int catch_type)
          Register a catch clause in the "Exceptions" code-attribute.
(package private)  Env<Gen.GenContext> unwind(JCTree target, Env<Gen.GenContext> env)
          Generate code to call all finalizers of structures aborted by a non-local exit.
 void visitApply(JCTree.JCMethodInvocation tree)
           
 void visitAssign(JCTree.JCAssign tree)
           
 void visitAssignop(JCTree.JCAssignOp tree)
           
 void visitBinary(JCTree.JCBinary tree)
           
 void visitBlock(JCTree.JCBlock tree)
           
 void visitBreak(JCTree.JCBreak tree)
           
 void visitConditional(JCTree.JCConditional tree)
           
 void visitContinue(JCTree.JCContinue tree)
           
 void visitDoLoop(JCTree.JCDoWhileLoop tree)
           
 void visitExec(JCTree.JCExpressionStatement tree)
           
 void visitForeachLoop(JCTree.JCEnhancedForLoop tree)
           
 void visitForLoop(JCTree.JCForLoop tree)
           
 void visitIdent(JCTree.JCIdent tree)
           
 void visitIf(JCTree.JCIf tree)
           
 void visitIndexed(JCTree.JCArrayAccess tree)
           
 void visitLabelled(JCTree.JCLabeledStatement tree)
           
 void visitLetExpr(JCTree.LetExpr tree)
           
 void visitLiteral(JCTree.JCLiteral tree)
           
 void visitMethodDef(JCTree.JCMethodDecl tree)
           
 void visitNewArray(JCTree.JCNewArray tree)
           
 void visitNewClass(JCTree.JCNewClass tree)
           
 void visitParens(JCTree.JCParens tree)
           
 void visitReturn(JCTree.JCReturn tree)
           
 void visitSelect(JCTree.JCFieldAccess tree)
           
 void visitSkip(JCTree.JCSkip tree)
           
 void visitSwitch(JCTree.JCSwitch tree)
           
 void visitSynchronized(JCTree.JCSynchronized tree)
           
 void visitThrow(JCTree.JCThrow tree)
           
 void visitTry(JCTree.JCTry tree)
           
 void visitTypeCast(JCTree.JCTypeCast tree)
           
 void visitTypeTest(JCTree.JCInstanceOf tree)
           
 void visitUnary(JCTree.JCUnary tree)
           
 void visitVarDef(JCTree.JCVariableDecl tree)
           
 void visitWhileLoop(JCTree.JCWhileLoop tree)
           
 void visitWildcard(JCTree.JCWildcard tree)
           
static int zero(int tc)
          The opcode that loads a zero constant of a given type code.
 
Methods inherited from class com.sun.tools.javac.tree.JCTree.Visitor
visitAnnotation, visitAssert, visitBracketExpr, visitBracketStat, visitCase, visitCatch, visitClassDef, visitErroneous, visitEscapeExpr, visitEscapeStat, visitImport, visitModifiers, visitTopLevel, visitTree, visitTypeApply, visitTypeArray, visitTypeBoundKind, visitTypeIdent, visitTypeParameter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

genKey

protected static final Context.Key<Gen> genKey

log

private final Log log

syms

private final Symtab syms

chk

private final Check chk

rs

private final Resolve rs

make

private final TreeMaker make

names

private final Names names

target

private final Target target

stringBufferType

private final Type stringBufferType

stringBufferAppend

private final java.util.Map<Type,Symbol> stringBufferAppend

accessDollar

private Name accessDollar

types

private final Types types

allowGenerics

private final boolean allowGenerics
Switch: GJ mode?


generateIproxies

private final boolean generateIproxies
Set when Miranda method stubs are to be generated.


stackMap

private final Code.StackMapFormat stackMap
Format of stackmap tables to be generated.


methodType

private final Type methodType
A type that serves as the expected type for all method expressions.


lineDebugInfo

private final boolean lineDebugInfo
Switches


varDebugInfo

private final boolean varDebugInfo

genCrt

private final boolean genCrt

debugCode

private final boolean debugCode

jsrlimit

private final int jsrlimit
Default limit of (approximate) size of finalizer to inline. Zero means always use jsr. 100 or greater means never use jsr.


useJsrLocally

private boolean useJsrLocally
True if jsr is used.


pool

private Pool pool

code

private Code code
Code buffer, set by genMethod.


items

private Items items
Items structure, set by genMethod.


attrEnv

private Env<AttrContext> attrEnv
Environment for symbol lookup, set by genClass


toplevel

private JCTree.JCCompilationUnit toplevel
The top level tree.


nerrs

private int nerrs
The number of code-gen errors in this class.


endPositions

private java.util.Map<JCTree,java.lang.Integer> endPositions
A hash table mapping syntax trees to their ending source positions.


env

Env<Gen.GenContext> env
Visitor argument: The current environment.


pt

Type pt
Visitor argument: The expected type (prototype).


result

Items.Item result
Visitor result: The item representing the computed value.

Constructor Detail

Gen

protected Gen(Context context)
Method Detail

instance

public static Gen instance(Context context)

loadIntConst

void loadIntConst(int n)
Generate code to load an integer constant.

Parameters:
n - The integer to be loaded.

zero

public static int zero(int tc)
The opcode that loads a zero constant of a given type code.

Parameters:
tc - The given type code (@see ByteCode).

one

public static int one(int tc)
The opcode that loads a one constant of a given type code.

Parameters:
tc - The given type code (@see ByteCode).

emitMinusOne

void emitMinusOne(int tc)
Generate code to load -1 of the given type code (either int or long).

Parameters:
tc - The given type code (@see ByteCode).

binaryQualifier

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. 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
site - The qualifier's type.

makeRef

int makeRef(JCDiagnostic.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.

Parameters:
type - The type for which a reference is inserted.

checkDimension

private void checkDimension(JCDiagnostic.DiagnosticPosition pos,
                            Type t)
Check if the given type is an array with too many dimensions.


makeTemp

Items.LocalItem makeTemp(Type type)
Create a tempory variable.

Parameters:
type - The variable's type.

callMethod

void callMethod(JCDiagnostic.DiagnosticPosition pos,
                Type site,
                Name name,
                List<Type> argtypes,
                boolean isStatic)
Generate code to call a non-private method or constructor.

Parameters:
pos - Position to be used for error reporting.
site - The type of which the method is a member.
name - The method's name.
argtypes - The method's argument types.
isStatic - A flag that indicates whether we call a static or instance method.

isAccessSuper

private boolean isAccessSuper(JCTree.JCMethodDecl enclMethod)
Is the given method definition an access method resulting from a qualified super? This is signified by an odd access code.


isOddAccessName

private boolean isOddAccessName(Name name)
Does given name start with "access$" and end in an odd digit?


genFinalizer

void genFinalizer(Env<Gen.GenContext> env)
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.


unwind

Env<Gen.GenContext> unwind(JCTree target,
                           Env<Gen.GenContext> env)
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
env - The environment current at the non-local exit.

endFinalizerGap

void endFinalizerGap(Env<Gen.GenContext> env)
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<Gen.GenContext> from,
                      Env<Gen.GenContext> to)
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
to - the least deeply nested environment to mark

hasFinally

boolean hasFinally(JCTree target,
                   Env<Gen.GenContext> env)
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
env - The environment current at the non-local exit.

normalizeDefs

List<JCTree> normalizeDefs(List<JCTree> defs,
                           Symbol.ClassSymbol c)
Distribute member initializer code into constructors and method.

Parameters:
defs - The list of class member declarations.
c - The enclosing class.

checkStringConstant

private void checkStringConstant(JCDiagnostic.DiagnosticPosition pos,
                                 java.lang.Object constValue)
Check a constant value and report if it is a string that is too large.


normalizeMethod

void normalizeMethod(JCTree.JCMethodDecl md,
                     List<JCTree.JCStatement> initCode)
Insert instance initializer code into initial constructor.

Parameters:
md - The tree potentially representing a constructor's definition.
initCode - The list of instance initializer statements.

implementInterfaceMethods

void implementInterfaceMethods(Symbol.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.

Parameters:
c - The class whose interfaces are searched for methods for which Miranda methods should be added.

implementInterfaceMethods

void implementInterfaceMethods(Symbol.ClassSymbol c,
                               Symbol.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.

Parameters:
c - The class whose interfaces are searched for methods for which Miranda methods should be added.
site - The class in which a definition may be needed.

addAbstractMethod

private void addAbstractMethod(Symbol.ClassSymbol c,
                               Symbol.MethodSymbol m)
Add an abstract methods to a class which implicitly implements a method defined in some interface implemented by the class. These methods are called "Miranda methods". Enter the newly created method into its enclosing class scope. Note that it is not entered into the class tree, as the emitter doesn't need to see it there to emit an abstract method.

Parameters:
c - The class to which the Miranda method is added.
m - The interface method symbol for which a Miranda method is added.

adjustAbstractMethod

private void adjustAbstractMethod(Symbol.ClassSymbol c,
                                  Symbol.MethodSymbol pm,
                                  Symbol.MethodSymbol im)

genDef

public void genDef(JCTree tree,
                   Env<Gen.GenContext> env)
Visitor method: generate code for a definition, catching and reporting any completion failures.

Parameters:
tree - The definition to be visited.
env - The environment current at the definition.

genStat

public void genStat(JCTree tree,
                    Env<Gen.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. If not, just call method to generate bytecode.

Parameters:
tree - The tree to be visited.
env - The environment to use.
crtFlags - The CharacterRangeTable flags indicating type of the entry.
See Also:
#genStat(Tree, Env)

genStat

public void genStat(JCTree tree,
                    Env<Gen.GenContext> env)
Derived visitor method: generate code for a statement.


genStats

public void genStats(List<JCTree.JCStatement> trees,
                     Env<Gen.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. If not, just call method to generate bytecode.

Parameters:
trees - The list of trees to be visited.
env - The environment to use.
crtFlags - The CharacterRangeTable flags indicating type of the entry.
See Also:
genStats(List, Env)

genStats

public void genStats(List<? extends JCTree> trees,
                     Env<Gen.GenContext> env)
Derived visitor method: generate code for a list of statements.


genCond

public Items.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. If not, just call method to generate bytecode.

Parameters:
tree - The tree to be visited.
crtFlags - The CharacterRangeTable flags indicating type of the entry.
See Also:
#genCond(Tree,boolean)

genCond

public Items.CondItem genCond(JCTree _tree,
                              boolean markBranches)
Derived visitor method: generate code for a boolean expression in a control-flow context.

Parameters:
_tree - The expression to be visited.
markBranches - The flag to indicate that the condition is a flow controller so produced conditions should contain a proper tree to generate CharacterRangeTable branches for them.

genExpr

public Items.Item genExpr(JCTree tree,
                          Type pt)
Visitor method: generate code for an expression, catching and reporting any completion failures.

Parameters:
tree - The expression to be visited.
pt - The expression's expected type (proto-type).

genArgs

public void genArgs(List<JCTree.JCExpression> trees,
                    List<Type> pts)
Derived visitor method: generate code for a list of method arguments.

Parameters:
trees - The argument expressions to be visited.
pts - The expression's expected types (i.e. the formal parameter types of the invoked method).

visitMethodDef

public void visitMethodDef(JCTree.JCMethodDecl tree)
Overrides:
visitMethodDef in class JCTree.Visitor

genMethod

void genMethod(JCTree.JCMethodDecl tree,
               Env<Gen.GenContext> env,
               boolean fatcode)
Generate code for a method.

Parameters:
tree - The tree representing the method definition.
env - The environment current for the method body.
fatcode - A flag that indicates whether all jumps are within 32K. We first invoke this method under the assumption that fatcode == false, i.e. all jumps are within 32K. If this fails, fatcode is set to true and we try again.

initCode

private int initCode(JCTree.JCMethodDecl tree,
                     Env<Gen.GenContext> env,
                     boolean fatcode)

visitVarDef

public void visitVarDef(JCTree.JCVariableDecl tree)
Overrides:
visitVarDef in class JCTree.Visitor

visitSkip

public void visitSkip(JCTree.JCSkip tree)
Overrides:
visitSkip in class JCTree.Visitor

visitBlock

public void visitBlock(JCTree.JCBlock tree)
Overrides:
visitBlock in class JCTree.Visitor

visitDoLoop

public void visitDoLoop(JCTree.JCDoWhileLoop tree)
Overrides:
visitDoLoop in class JCTree.Visitor

visitWhileLoop

public void visitWhileLoop(JCTree.JCWhileLoop tree)
Overrides:
visitWhileLoop in class JCTree.Visitor

visitForLoop

public void visitForLoop(JCTree.JCForLoop tree)
Overrides:
visitForLoop in class JCTree.Visitor

genLoop

private void genLoop(JCTree.JCStatement loop,
                     JCTree.JCStatement body,
                     JCTree.JCExpression cond,
                     List<JCTree.JCExpressionStatement> step,
                     boolean testFirst)
Generate code for a loop.

Parameters:
loop - The tree representing the loop.
body - The loop's body.
cond - The loop's controling condition.
step - "Step" statements to be inserted at end of each iteration.
testFirst - True if the loop test belongs before the body.

visitForeachLoop

public void visitForeachLoop(JCTree.JCEnhancedForLoop tree)
Overrides:
visitForeachLoop in class JCTree.Visitor

visitLabelled

public void visitLabelled(JCTree.JCLabeledStatement tree)
Overrides:
visitLabelled in class JCTree.Visitor

visitSwitch

public void visitSwitch(JCTree.JCSwitch tree)
Overrides:
visitSwitch in class JCTree.Visitor

qsort2

static void qsort2(int[] keys,
                   int[] values,
                   int lo,
                   int hi)
Sort (int) arrays of keys and values


visitSynchronized

public void visitSynchronized(JCTree.JCSynchronized tree)
Overrides:
visitSynchronized in class JCTree.Visitor

visitTry

public void visitTry(JCTree.JCTry tree)
Overrides:
visitTry in class JCTree.Visitor

genTry

void genTry(JCTree body,
            List<JCTree.JCCatch> catchers,
            Env<Gen.GenContext> env)
Generate code for a try or synchronized statement

Parameters:
body - The body of the try or synchronized statement.
catchers - The lis of catch clauses.
env - the environment current for the body.

genCatch

void genCatch(JCTree.JCCatch tree,
              Env<Gen.GenContext> env,
              int startpc,
              int endpc,
              List<java.lang.Integer> gaps)
Generate code for a catch clause.

Parameters:
tree - The catch clause.
env - The environment current in the enclosing try.
startpc - Start pc of try-block.
endpc - End pc of try-block.

registerCatch

void registerCatch(JCDiagnostic.DiagnosticPosition pos,
                   int startpc,
                   int endpc,
                   int handler_pc,
                   int catch_type)
Register a catch clause in the "Exceptions" code-attribute.


estimateCodeComplexity

int estimateCodeComplexity(JCTree tree)
Very roughly estimate the number of instructions needed for the given tree.


visitIf

public void visitIf(JCTree.JCIf tree)
Overrides:
visitIf in class JCTree.Visitor

visitExec

public void visitExec(JCTree.JCExpressionStatement tree)
Overrides:
visitExec in class JCTree.Visitor

visitBreak

public void visitBreak(JCTree.JCBreak tree)
Overrides:
visitBreak in class JCTree.Visitor

visitContinue

public void visitContinue(JCTree.JCContinue tree)
Overrides:
visitContinue in class JCTree.Visitor

visitReturn

public void visitReturn(JCTree.JCReturn tree)
Overrides:
visitReturn in class JCTree.Visitor

visitThrow

public void visitThrow(JCTree.JCThrow tree)
Overrides:
visitThrow in class JCTree.Visitor

visitApply

public void visitApply(JCTree.JCMethodInvocation tree)
Overrides:
visitApply in class JCTree.Visitor

visitConditional

public void visitConditional(JCTree.JCConditional tree)
Overrides:
visitConditional in class JCTree.Visitor

visitNewClass

public void visitNewClass(JCTree.JCNewClass tree)
Overrides:
visitNewClass in class JCTree.Visitor

visitNewArray

public void visitNewArray(JCTree.JCNewArray tree)
Overrides:
visitNewArray in class JCTree.Visitor

makeNewArray

Items.Item makeNewArray(JCDiagnostic.DiagnosticPosition pos,
                        Type type,
                        int ndims)
Generate code to create an array with given element type and number of dimensions.


visitParens

public void visitParens(JCTree.JCParens tree)
Overrides:
visitParens in class JCTree.Visitor

visitAssign

public void visitAssign(JCTree.JCAssign tree)
Overrides:
visitAssign in class JCTree.Visitor

visitAssignop

public void visitAssignop(JCTree.JCAssignOp tree)
Overrides:
visitAssignop in class JCTree.Visitor

visitUnary

public void visitUnary(JCTree.JCUnary tree)
Overrides:
visitUnary in class JCTree.Visitor

genNullCheck

private void genNullCheck(JCDiagnostic.DiagnosticPosition pos)
Generate a null check from the object value at stack top.


visitBinary

public void visitBinary(JCTree.JCBinary tree)
Overrides:
visitBinary in class JCTree.Visitor

makeStringBuffer

void makeStringBuffer(JCDiagnostic.DiagnosticPosition pos)
Make a new string buffer.


appendString

void appendString(JCTree tree)
Append value (on tos) to string buffer (on tos - 1).


getStringBufferAppend

Symbol getStringBufferAppend(JCTree tree,
                             Type t)

appendStrings

void appendStrings(JCTree tree)
Add all strings in tree to string buffer.


bufferToString

void bufferToString(JCDiagnostic.DiagnosticPosition pos)
Convert string buffer on tos to string.


completeBinop

Items.Item completeBinop(JCTree lhs,
                         JCTree rhs,
                         Symbol.OperatorSymbol operator)
Complete generating code for operation, with left operand already on stack.

Parameters:
lhs - The tree representing the left operand.
rhs - The tree representing the right operand.
operator - The operator symbol.

visitTypeCast

public void visitTypeCast(JCTree.JCTypeCast tree)
Overrides:
visitTypeCast in class JCTree.Visitor

visitWildcard

public void visitWildcard(JCTree.JCWildcard tree)
Overrides:
visitWildcard in class JCTree.Visitor

visitTypeTest

public void visitTypeTest(JCTree.JCInstanceOf tree)
Overrides:
visitTypeTest in class JCTree.Visitor

visitIndexed

public void visitIndexed(JCTree.JCArrayAccess tree)
Overrides:
visitIndexed in class JCTree.Visitor

visitIdent

public void visitIdent(JCTree.JCIdent tree)
Overrides:
visitIdent in class JCTree.Visitor

visitSelect

public void visitSelect(JCTree.JCFieldAccess tree)
Overrides:
visitSelect in class JCTree.Visitor

visitLiteral

public void visitLiteral(JCTree.JCLiteral tree)
Overrides:
visitLiteral in class JCTree.Visitor

visitLetExpr

public void visitLetExpr(JCTree.LetExpr tree)
Overrides:
visitLetExpr in class JCTree.Visitor

genClass

public boolean genClass(Env<AttrContext> env,
                        JCTree.JCClassDecl cdef)
Generate code for a class definition.

Parameters:
env - The attribution environment that belongs to the outermost class containing this class definition. We need this for resolving some additional symbols.
cdef - The tree representing the class definition.
Returns:
True if code is generated with no errors.