Package javassist.compiler
Class CodeGen
java.lang.Object
javassist.compiler.ast.Visitor
javassist.compiler.CodeGen
- Direct Known Subclasses:
MemberCodeGen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classdoit() in ReturnHook is called from atReturn(). -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int(package private) static final int[]protected Bytecodeprivate static final int[]protected Stringprotected intprotected booleantrue if the last visited node is a return statement.private static final int[]private static final int[]booleanMust be true if compilation is for a static method.(package private) static final String(package private) static final String(package private) static final String(package private) static final Stringprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprotected CodeGen.ReturnHookprivate int(package private) TypeCheckerFields inherited from interface javassist.bytecode.Opcode
AALOAD, AASTORE, ACONST_NULL, ALOAD, ALOAD_0, ALOAD_1, ALOAD_2, ALOAD_3, ANEWARRAY, ARETURN, ARRAYLENGTH, ASTORE, ASTORE_0, ASTORE_1, ASTORE_2, ASTORE_3, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DLOAD_0, DLOAD_1, DLOAD_2, DLOAD_3, DMUL, DNEG, DREM, DRETURN, DSTORE, DSTORE_0, DSTORE_1, DSTORE_2, DSTORE_3, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FLOAD_0, FLOAD_1, FLOAD_2, FLOAD_3, FMUL, FNEG, FREM, FRETURN, FSTORE, FSTORE_0, FSTORE_1, FSTORE_2, FSTORE_3, FSUB, GETFIELD, GETSTATIC, GOTO, GOTO_W, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, ILOAD_0, ILOAD_1, ILOAD_2, ILOAD_3, IMUL, INEG, INSTANCEOF, INVOKEDYNAMIC, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISTORE_0, ISTORE_1, ISTORE_2, ISTORE_3, ISUB, IUSHR, IXOR, JSR, JSR_W, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDC_W, LDC2_W, LDIV, LLOAD, LLOAD_0, LLOAD_1, LLOAD_2, LLOAD_3, LMUL, LNEG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSTORE_0, LSTORE_1, LSTORE_2, LSTORE_3, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, STACK_GROW, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, WIDEFields inherited from interface javassist.compiler.TokenId
ABSTRACT, AND_E, ANDAND, ARRAY, ARSHIFT, ARSHIFT_E, assignOps, BadToken, BLOCK, BOOLEAN, BREAK, BYTE, CALL, CASE, CATCH, CHAR, CharConstant, CLASS, CONST, CONTINUE, DECL, DEFAULT, DIV_E, DO, DOUBLE, DoubleConstant, ELSE, EQ, EXOR_E, EXPR, EXTENDS, FALSE, FINAL, FINALLY, FLOAT, FloatConstant, FOR, GE, GOTO, Identifier, IF, IMPLEMENTS, IMPORT, INSTANCEOF, INT, IntConstant, INTERFACE, LABEL, LE, LONG, LongConstant, LSHIFT, LSHIFT_E, MEMBER, MINUS_E, MINUSMINUS, MOD_E, MUL_E, NATIVE, NEQ, NEW, NULL, opNames, OR_E, OROR, PACKAGE, PLUS_E, PLUSPLUS, PRIVATE, PROTECTED, PUBLIC, RETURN, RSHIFT, RSHIFT_E, SHORT, STATIC, STRICT, StringL, SUPER, SWITCH, SYNCHRONIZED, THIS, THROW, THROWS, TRANSIENT, TRUE, TRY, VOID, VOLATILE, WHILE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidarrayAccess(ASTree array, ASTree index) private voidatArithBinExpr(Expr expr, int token, int index, int type1) private voidatArrayAssign(Expr expr, int op, Expr array, ASTree right, boolean doDup) abstract voidatArrayInit(ArrayInit init) voidatArrayPlusPlus(int token, boolean isPost, Expr expr, boolean doDup) voidatArrayRead(ASTree array, ASTree index) protected abstract voidatArrayVariableAssign(ArrayInit init, int varType, int varArray, String varClass) protected voidatAssignCore(Expr expr, int op, ASTree right, int type, int dim, String cname) voidatAssignExpr(AssignExpr expr) protected voidatAssignExpr(AssignExpr expr, boolean doDup) voidvoidprivate voidatBreakStmnt(Stmnt st, boolean notCont) abstract voidatCallExpr(CallExpr expr) voidatCastExpr(CastExpr expr) voidatClassObject(Expr expr) protected voidatClassObject2(String cname) voidatCondExpr(CondExpr expr) voidvoidvoidprotected abstract voidatFieldAssign(Expr expr, int op, ASTree left, ASTree right, boolean doDup) voidatFieldDecl(FieldDecl field) protected abstract voidatFieldPlusPlus(int token, boolean isPost, ASTree oprand, Expr expr, boolean doDup) protected abstract voidatFieldRead(ASTree expr) private voidatForStmnt(Stmnt st) private voidvoidvoidvoidabstract voidvoidatMethodBody(Stmnt s, boolean isCons, boolean isVoid) voidatMethodDecl(MethodDecl method) abstract void(package private) voidatNumCastExpr(int srcType, int destType) voidprivate voidatPlusPlus(int token, ASTree oprand, Expr expr, boolean doDup) protected voidatPlusPlusCore(int dup_code, boolean doDup, int token, boolean isPost, Expr expr) protected voidatReturnStmnt(Stmnt st) protected final voidatReturnStmnt2(ASTree result) voidprivate voidatStringConcatExpr(Expr expr, int type1, int dim1, String cname1) voidprivate voidatStringPlusEq(Expr expr, int type, int dim, String cname, ASTree right) private voidatSwitchStmnt(Stmnt st) voidprivate voidatSyncStmnt(Stmnt st) private voidatThrowStmnt(Stmnt st) protected voidatTryStmnt(Stmnt st) voidprivate voidatVariableAssign(Expr expr, int op, Variable var, Declarator d, ASTree right, boolean doDup) private voidatWhileStmnt(Stmnt st, boolean notDo) protected static voidprotected static voidprotected static voidprivate booleanbooleanExpr(boolean branchIf, ASTree expr) private StringcheckCastExpr(CastExpr expr, String name) private voidcompareExpr(boolean branchIf, int token, int type1, BinExpr expr) booleancompileBooleanExpr(boolean branchIf, ASTree expr) voidcompileExpr(ASTree expr) private intcompileOprands(BinExpr expr) private intcomputeLabel(ASTree expr) private intcomputeStringLabel(ASTree expr, int tmpVar, List<Integer> gotoDefaults) private voidconvertOprandTypes(int type1, int type2, Expr expr) private voidconvToString(int type, int dim) voiddoTypeCheck(ASTree expr) protected static voidfatal()protected static intgetArrayReadOp(int type, int dim) protected static intgetArrayWriteOp(int type, int dim) (package private) static intgetCompOperator(ASTree expr) private static intgetListSize(List<Integer> list) protected intintprotected abstract StringReturns the JVM-internal representation of this super class name.protected intReturns a local variable that single or double words can be stored in.protected abstract StringReturns the JVM-internal representation of this class name.protected voidincMaxLocals(int size) protected abstract voidprivate booleaninvalidDim(int srcType, int srcDim, String srcClass, int destType, int destDim, String destClass, boolean isCast) static booleanis2word(int type, int dim) private static booleanisAlwaysBranch(ASTree expr, boolean branchIf) (package private) static booleanisP_INT(int type) private static booleanisPlusPlusExpr(ASTree expr) protected static booleanisRefType(int type) (package private) static intlookupBinOp(int token) private booleanneedsSuperCall(Stmnt body) protected voidprotected abstract StringresolveClassName(String jvmClassName) protected abstract StringresolveClassName(ASTList name) (package private) static booleanrightIsStrong(int type1, int type2) voidsetMaxLocals(int n) voidsetTypeChecker(TypeChecker checker) protected static StringtoJvmArrayName(String name, int dim) protected static StringtoJvmTypeName(int type, int dim) private static inttypePrecedence(int type)
-
Field Details
-
javaLangObject
- See Also:
-
jvmJavaLangObject
- See Also:
-
javaLangString
- See Also:
-
jvmJavaLangString
- See Also:
-
bytecode
-
tempVar
private int tempVar -
typeChecker
TypeChecker typeChecker -
hasReturned
protected boolean hasReturnedtrue if the last visited node is a return statement. -
inStaticMethod
public boolean inStaticMethodMust be true if compilation is for a static method. -
breakList
-
continueList
-
returnHooks
-
exprType
protected int exprType -
arrayDim
protected int arrayDim -
className
-
binOp
static final int[] binOp -
ifOp
private static final int[] ifOp -
ifOp2
private static final int[] ifOp2 -
P_DOUBLE
private static final int P_DOUBLE- See Also:
-
P_FLOAT
private static final int P_FLOAT- See Also:
-
P_LONG
private static final int P_LONG- See Also:
-
P_INT
private static final int P_INT- See Also:
-
P_OTHER
private static final int P_OTHER- See Also:
-
castOp
private static final int[] castOp
-
-
Constructor Details
-
CodeGen
-
-
Method Details
-
setTypeChecker
-
fatal
- Throws:
CompileError
-
is2word
public static boolean is2word(int type, int dim) -
getMaxLocals
public int getMaxLocals() -
setMaxLocals
public void setMaxLocals(int n) -
incMaxLocals
protected void incMaxLocals(int size) -
getTempVar
protected int getTempVar()Returns a local variable that single or double words can be stored in. -
getLocalVar
-
getThisName
Returns the JVM-internal representation of this class name. -
getSuperName
Returns the JVM-internal representation of this super class name.- Throws:
CompileError
-
resolveClassName
- Throws:
CompileError
-
resolveClassName
- Throws:
CompileError
-
toJvmArrayName
- Parameters:
name- the JVM-internal representation. name is not exapnded to java.lang.*.
-
toJvmTypeName
-
compileExpr
- Throws:
CompileError
-
compileBooleanExpr
- Throws:
CompileError
-
doTypeCheck
- Throws:
CompileError
-
atASTList
- Overrides:
atASTListin classVisitor- Throws:
CompileError
-
atPair
- Overrides:
atPairin classVisitor- Throws:
CompileError
-
atSymbol
- Overrides:
atSymbolin classVisitor- Throws:
CompileError
-
atFieldDecl
- Overrides:
atFieldDeclin classVisitor- Throws:
CompileError
-
atMethodDecl
- Overrides:
atMethodDeclin classVisitor- Throws:
CompileError
-
atMethodBody
- Parameters:
isCons- true if super() must be called. false if the method is a class initializer.- Throws:
CompileError
-
needsSuperCall
- Throws:
CompileError
-
insertDefaultSuperCall
- Throws:
CompileError
-
atStmnt
- Overrides:
atStmntin classVisitor- Throws:
CompileError
-
atIfStmnt
- Throws:
CompileError
-
atWhileStmnt
- Throws:
CompileError
-
patchGoto
-
atForStmnt
- Throws:
CompileError
-
atSwitchStmnt
- Throws:
CompileError
-
computeLabel
- Throws:
CompileError
-
computeStringLabel
private int computeStringLabel(ASTree expr, int tmpVar, List<Integer> gotoDefaults) throws CompileError - Throws:
CompileError
-
atBreakStmnt
- Throws:
CompileError
-
atReturnStmnt
- Throws:
CompileError
-
atReturnStmnt2
- Throws:
CompileError
-
atThrowStmnt
- Throws:
CompileError
-
atTryStmnt
- Throws:
CompileError
-
atSyncStmnt
- Throws:
CompileError
-
getListSize
-
isPlusPlusExpr
-
atDeclarator
- Overrides:
atDeclaratorin classVisitor- Throws:
CompileError
-
atNewExpr
- Overrides:
atNewExprin classVisitor- Throws:
CompileError
-
atArrayInit
- Overrides:
atArrayInitin classVisitor- Throws:
CompileError
-
atAssignExpr
- Overrides:
atAssignExprin classVisitor- Throws:
CompileError
-
atAssignExpr
- Throws:
CompileError
-
badAssign
- Throws:
CompileError
-
atVariableAssign
private void atVariableAssign(Expr expr, int op, Variable var, Declarator d, ASTree right, boolean doDup) throws CompileError - Throws:
CompileError
-
atArrayVariableAssign
protected abstract void atArrayVariableAssign(ArrayInit init, int varType, int varArray, String varClass) throws CompileError - Throws:
CompileError
-
atArrayAssign
private void atArrayAssign(Expr expr, int op, Expr array, ASTree right, boolean doDup) throws CompileError - Throws:
CompileError
-
atFieldAssign
protected abstract void atFieldAssign(Expr expr, int op, ASTree left, ASTree right, boolean doDup) throws CompileError - Throws:
CompileError
-
atAssignCore
protected void atAssignCore(Expr expr, int op, ASTree right, int type, int dim, String cname) throws CompileError - Throws:
CompileError
-
atStringPlusEq
private void atStringPlusEq(Expr expr, int type, int dim, String cname, ASTree right) throws CompileError - Throws:
CompileError
-
invalidDim
-
atCondExpr
- Overrides:
atCondExprin classVisitor- Throws:
CompileError
-
lookupBinOp
static int lookupBinOp(int token) -
atBinExpr
- Overrides:
atBinExprin classVisitor- Throws:
CompileError
-
atArithBinExpr
- Throws:
CompileError
-
atStringConcatExpr
- Throws:
CompileError
-
convToString
- Throws:
CompileError
-
booleanExpr
- Throws:
CompileError
-
isAlwaysBranch
-
getCompOperator
- Throws:
CompileError
-
compileOprands
- Throws:
CompileError
-
compareExpr
- Throws:
CompileError
-
badTypes
- Throws:
CompileError
-
isRefType
protected static boolean isRefType(int type) -
typePrecedence
private static int typePrecedence(int type) -
isP_INT
static boolean isP_INT(int type) -
rightIsStrong
static boolean rightIsStrong(int type1, int type2) -
convertOprandTypes
- Throws:
CompileError
-
atCastExpr
- Overrides:
atCastExprin classVisitor- Throws:
CompileError
-
atInstanceOfExpr
- Overrides:
atInstanceOfExprin classVisitor- Throws:
CompileError
-
checkCastExpr
- Throws:
CompileError
-
atNumCastExpr
- Throws:
CompileError
-
atExpr
- Overrides:
atExprin classVisitor- Throws:
CompileError
-
badType
- Throws:
CompileError
-
atCallExpr
- Overrides:
atCallExprin classVisitor- Throws:
CompileError
-
atFieldRead
- Throws:
CompileError
-
atClassObject
- Throws:
CompileError
-
atClassObject2
- Throws:
CompileError
-
atArrayRead
- Throws:
CompileError
-
arrayAccess
- Throws:
CompileError
-
getArrayReadOp
protected static int getArrayReadOp(int type, int dim) -
getArrayWriteOp
protected static int getArrayWriteOp(int type, int dim) -
atPlusPlus
- Throws:
CompileError
-
atArrayPlusPlus
public void atArrayPlusPlus(int token, boolean isPost, Expr expr, boolean doDup) throws CompileError - Throws:
CompileError
-
atPlusPlusCore
protected void atPlusPlusCore(int dup_code, boolean doDup, int token, boolean isPost, Expr expr) throws CompileError - Throws:
CompileError
-
atFieldPlusPlus
protected abstract void atFieldPlusPlus(int token, boolean isPost, ASTree oprand, Expr expr, boolean doDup) throws CompileError - Throws:
CompileError
-
atMember
- Overrides:
atMemberin classVisitor- Throws:
CompileError
-
atVariable
- Overrides:
atVariablein classVisitor- Throws:
CompileError
-
atKeyword
- Overrides:
atKeywordin classVisitor- Throws:
CompileError
-
atStringL
- Overrides:
atStringLin classVisitor- Throws:
CompileError
-
atIntConst
- Overrides:
atIntConstin classVisitor- Throws:
CompileError
-
atDoubleConst
- Overrides:
atDoubleConstin classVisitor- Throws:
CompileError
-