javassist.compiler
Class CodeGen
java.lang.Object
javassist.compiler.ast.Visitor
javassist.compiler.CodeGen
- All Implemented Interfaces:
- Opcode, TokenId
- Direct Known Subclasses:
- MemberCodeGen
public abstract class CodeGen
- extends Visitor
- implements Opcode, TokenId
Nested Class Summary |
protected static class |
CodeGen.ReturnHook
doit() in ReturnHook is called from atReturn(). |
Fields 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, 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, WIDE |
Fields 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 |
Method Summary |
protected void |
arrayAccess(ASTree array,
ASTree index)
|
abstract void |
atArrayInit(ArrayInit init)
|
void |
atArrayPlusPlus(int token,
boolean isPost,
Expr expr,
boolean doDup)
|
void |
atArrayRead(ASTree array,
ASTree index)
|
protected abstract void |
atArrayVariableAssign(ArrayInit init,
int varType,
int varArray,
java.lang.String varClass)
|
protected void |
atAssignCore(Expr expr,
int op,
ASTree right,
int type,
int dim,
java.lang.String cname)
|
void |
atAssignExpr(AssignExpr expr)
|
protected void |
atAssignExpr(AssignExpr expr,
boolean doDup)
|
void |
atASTList(ASTList n)
|
void |
atBinExpr(BinExpr expr)
|
abstract void |
atCallExpr(CallExpr expr)
|
void |
atCastExpr(CastExpr expr)
|
void |
atClassObject(Expr expr)
|
protected void |
atClassObject2(java.lang.String cname)
|
void |
atCondExpr(CondExpr expr)
|
void |
atDeclarator(Declarator d)
|
void |
atDoubleConst(DoubleConst d)
|
void |
atExpr(Expr expr)
|
protected abstract void |
atFieldAssign(Expr expr,
int op,
ASTree left,
ASTree right,
boolean doDup)
|
void |
atFieldDecl(FieldDecl field)
|
protected abstract void |
atFieldPlusPlus(int token,
boolean isPost,
ASTree oprand,
Expr expr,
boolean doDup)
|
protected abstract void |
atFieldRead(ASTree expr)
|
void |
atInstanceOfExpr(InstanceOfExpr expr)
|
void |
atIntConst(IntConst i)
|
void |
atKeyword(Keyword k)
|
abstract void |
atMember(Member n)
|
void |
atMethodBody(Stmnt s,
boolean isCons,
boolean isVoid)
|
void |
atMethodDecl(MethodDecl method)
|
abstract void |
atNewExpr(NewExpr n)
|
void |
atPair(Pair n)
|
protected void |
atPlusPlusCore(int dup_code,
boolean doDup,
int token,
boolean isPost,
Expr expr)
|
protected void |
atReturnStmnt(Stmnt st)
|
protected void |
atReturnStmnt2(ASTree result)
|
void |
atStmnt(Stmnt st)
|
void |
atStringL(StringL s)
|
void |
atSymbol(Symbol n)
|
protected void |
atTryStmnt(Stmnt st)
|
void |
atVariable(Variable v)
|
protected static void |
badAssign(Expr expr)
|
protected static void |
badType(Expr expr)
|
protected static void |
badTypes(Expr expr)
|
boolean |
compileBooleanExpr(boolean branchIf,
ASTree expr)
|
void |
compileExpr(ASTree expr)
|
void |
doTypeCheck(ASTree expr)
|
protected static void |
fatal()
|
protected static int |
getArrayReadOp(int type,
int dim)
|
protected static int |
getArrayWriteOp(int type,
int dim)
|
protected int |
getLocalVar(Declarator d)
|
int |
getMaxLocals()
|
protected abstract java.lang.String |
getSuperName()
Returns the JVM-internal representation of this super class name. |
protected int |
getTempVar()
Returns a local variable that single or double words can be
stored in. |
protected abstract java.lang.String |
getThisName()
Returns the JVM-internal representation of this class name. |
protected void |
incMaxLocals(int size)
|
protected abstract void |
insertDefaultSuperCall()
|
static boolean |
is2word(int type,
int dim)
|
protected static boolean |
isRefType(int type)
|
protected void |
patchGoto(java.util.ArrayList list,
int targetPc)
|
protected abstract java.lang.String |
resolveClassName(ASTList name)
|
protected abstract java.lang.String |
resolveClassName(java.lang.String jvmClassName)
|
void |
setMaxLocals(int n)
|
void |
setTypeChecker(TypeChecker checker)
|
protected static java.lang.String |
toJvmArrayName(java.lang.String name,
int dim)
|
protected static java.lang.String |
toJvmTypeName(int type,
int dim)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
bytecode
protected Bytecode bytecode
hasReturned
protected boolean hasReturned
- true if the last visited node is a return statement.
inStaticMethod
public boolean inStaticMethod
- Must be true if compilation is for a static method.
breakList
protected java.util.ArrayList breakList
continueList
protected java.util.ArrayList continueList
returnHooks
protected CodeGen.ReturnHook returnHooks
exprType
protected int exprType
arrayDim
protected int arrayDim
className
protected java.lang.String className
CodeGen
public CodeGen(Bytecode b)
setTypeChecker
public void setTypeChecker(TypeChecker checker)
fatal
protected static void fatal()
throws CompileError
- 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
protected int getLocalVar(Declarator d)
getThisName
protected abstract java.lang.String getThisName()
- Returns the JVM-internal representation of this class name.
getSuperName
protected abstract java.lang.String getSuperName()
throws CompileError
- Returns the JVM-internal representation of this super class name.
- Throws:
CompileError
resolveClassName
protected abstract java.lang.String resolveClassName(ASTList name)
throws CompileError
- Throws:
CompileError
resolveClassName
protected abstract java.lang.String resolveClassName(java.lang.String jvmClassName)
throws CompileError
- Throws:
CompileError
toJvmArrayName
protected static java.lang.String toJvmArrayName(java.lang.String name,
int dim)
- Parameters:
name
- the JVM-internal representation.
name is not exapnded to java.lang.*.
toJvmTypeName
protected static java.lang.String toJvmTypeName(int type,
int dim)
compileExpr
public void compileExpr(ASTree expr)
throws CompileError
- Throws:
CompileError
compileBooleanExpr
public boolean compileBooleanExpr(boolean branchIf,
ASTree expr)
throws CompileError
- Throws:
CompileError
doTypeCheck
public void doTypeCheck(ASTree expr)
throws CompileError
- Throws:
CompileError
atASTList
public void atASTList(ASTList n)
throws CompileError
- Overrides:
atASTList
in class Visitor
- Throws:
CompileError
atPair
public void atPair(Pair n)
throws CompileError
- Overrides:
atPair
in class Visitor
- Throws:
CompileError
atSymbol
public void atSymbol(Symbol n)
throws CompileError
- Overrides:
atSymbol
in class Visitor
- Throws:
CompileError
atFieldDecl
public void atFieldDecl(FieldDecl field)
throws CompileError
- Overrides:
atFieldDecl
in class Visitor
- Throws:
CompileError
atMethodDecl
public void atMethodDecl(MethodDecl method)
throws CompileError
- Overrides:
atMethodDecl
in class Visitor
- Throws:
CompileError
atMethodBody
public void atMethodBody(Stmnt s,
boolean isCons,
boolean isVoid)
throws CompileError
- Parameters:
isCons
- true if super() must be called.
false if the method is a class initializer.
- Throws:
CompileError
insertDefaultSuperCall
protected abstract void insertDefaultSuperCall()
throws CompileError
- Throws:
CompileError
atStmnt
public void atStmnt(Stmnt st)
throws CompileError
- Overrides:
atStmnt
in class Visitor
- Throws:
CompileError
patchGoto
protected void patchGoto(java.util.ArrayList list,
int targetPc)
atReturnStmnt
protected void atReturnStmnt(Stmnt st)
throws CompileError
- Throws:
CompileError
atReturnStmnt2
protected final void atReturnStmnt2(ASTree result)
throws CompileError
- Throws:
CompileError
atTryStmnt
protected void atTryStmnt(Stmnt st)
throws CompileError
- Throws:
CompileError
atDeclarator
public void atDeclarator(Declarator d)
throws CompileError
- Overrides:
atDeclarator
in class Visitor
- Throws:
CompileError
atNewExpr
public abstract void atNewExpr(NewExpr n)
throws CompileError
- Overrides:
atNewExpr
in class Visitor
- Throws:
CompileError
atArrayInit
public abstract void atArrayInit(ArrayInit init)
throws CompileError
- Overrides:
atArrayInit
in class Visitor
- Throws:
CompileError
atAssignExpr
public void atAssignExpr(AssignExpr expr)
throws CompileError
- Overrides:
atAssignExpr
in class Visitor
- Throws:
CompileError
atAssignExpr
protected void atAssignExpr(AssignExpr expr,
boolean doDup)
throws CompileError
- Throws:
CompileError
badAssign
protected static void badAssign(Expr expr)
throws CompileError
- Throws:
CompileError
atArrayVariableAssign
protected abstract void atArrayVariableAssign(ArrayInit init,
int varType,
int varArray,
java.lang.String varClass)
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,
java.lang.String cname)
throws CompileError
- Throws:
CompileError
atCondExpr
public void atCondExpr(CondExpr expr)
throws CompileError
- Overrides:
atCondExpr
in class Visitor
- Throws:
CompileError
atBinExpr
public void atBinExpr(BinExpr expr)
throws CompileError
- Overrides:
atBinExpr
in class Visitor
- Throws:
CompileError
badTypes
protected static void badTypes(Expr expr)
throws CompileError
- Throws:
CompileError
isRefType
protected static boolean isRefType(int type)
atCastExpr
public void atCastExpr(CastExpr expr)
throws CompileError
- Overrides:
atCastExpr
in class Visitor
- Throws:
CompileError
atInstanceOfExpr
public void atInstanceOfExpr(InstanceOfExpr expr)
throws CompileError
- Overrides:
atInstanceOfExpr
in class Visitor
- Throws:
CompileError
atExpr
public void atExpr(Expr expr)
throws CompileError
- Overrides:
atExpr
in class Visitor
- Throws:
CompileError
badType
protected static void badType(Expr expr)
throws CompileError
- Throws:
CompileError
atCallExpr
public abstract void atCallExpr(CallExpr expr)
throws CompileError
- Overrides:
atCallExpr
in class Visitor
- Throws:
CompileError
atFieldRead
protected abstract void atFieldRead(ASTree expr)
throws CompileError
- Throws:
CompileError
atClassObject
public void atClassObject(Expr expr)
throws CompileError
- Throws:
CompileError
atClassObject2
protected void atClassObject2(java.lang.String cname)
throws CompileError
- Throws:
CompileError
atArrayRead
public void atArrayRead(ASTree array,
ASTree index)
throws CompileError
- Throws:
CompileError
arrayAccess
protected void arrayAccess(ASTree array,
ASTree index)
throws CompileError
- Throws:
CompileError
getArrayReadOp
protected static int getArrayReadOp(int type,
int dim)
getArrayWriteOp
protected static int getArrayWriteOp(int type,
int dim)
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
public abstract void atMember(Member n)
throws CompileError
- Overrides:
atMember
in class Visitor
- Throws:
CompileError
atVariable
public void atVariable(Variable v)
throws CompileError
- Overrides:
atVariable
in class Visitor
- Throws:
CompileError
atKeyword
public void atKeyword(Keyword k)
throws CompileError
- Overrides:
atKeyword
in class Visitor
- Throws:
CompileError
atStringL
public void atStringL(StringL s)
throws CompileError
- Overrides:
atStringL
in class Visitor
- Throws:
CompileError
atIntConst
public void atIntConst(IntConst i)
throws CompileError
- Overrides:
atIntConst
in class Visitor
- Throws:
CompileError
atDoubleConst
public void atDoubleConst(DoubleConst d)
throws CompileError
- Overrides:
atDoubleConst
in class Visitor
- Throws:
CompileError
Copyright © 2011. All Rights Reserved.