Modifier and Type | Class and Description |
---|---|
protected static class |
CodeGen.ReturnHook
doit() in ReturnHook is called from atReturn().
|
Modifier and Type | Field and Description |
---|---|
protected int |
arrayDim |
protected ArrayList |
breakList |
protected Bytecode |
bytecode |
protected String |
className |
protected ArrayList |
continueList |
protected int |
exprType |
protected boolean |
hasReturned
true if the last visited node is a return statement.
|
boolean |
inStaticMethod
Must be true if compilation is for a static method.
|
protected CodeGen.ReturnHook |
returnHooks |
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, WIDE
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
Modifier and Type | Method and Description |
---|---|
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,
String varClass) |
protected void |
atAssignCore(Expr expr,
int op,
ASTree right,
int type,
int dim,
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(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 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 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(ArrayList list,
int targetPc) |
protected abstract String |
resolveClassName(ASTList name) |
protected abstract String |
resolveClassName(String jvmClassName) |
void |
setMaxLocals(int n) |
void |
setTypeChecker(TypeChecker checker) |
protected static String |
toJvmArrayName(String name,
int dim) |
protected static String |
toJvmTypeName(int type,
int dim) |
protected Bytecode bytecode
protected boolean hasReturned
public boolean inStaticMethod
protected ArrayList breakList
protected ArrayList continueList
protected CodeGen.ReturnHook returnHooks
protected int exprType
protected int arrayDim
protected String className
public CodeGen(Bytecode b)
public void setTypeChecker(TypeChecker checker)
protected static void fatal() throws CompileError
CompileError
public static boolean is2word(int type, int dim)
public int getMaxLocals()
public void setMaxLocals(int n)
protected void incMaxLocals(int size)
protected int getTempVar()
protected int getLocalVar(Declarator d)
protected abstract String getThisName()
protected abstract String getSuperName() throws CompileError
CompileError
protected abstract String resolveClassName(ASTList name) throws CompileError
CompileError
protected abstract String resolveClassName(String jvmClassName) throws CompileError
CompileError
protected static String toJvmArrayName(String name, int dim)
name
- the JVM-internal representation.
name is not exapnded to java.lang.*.protected static String toJvmTypeName(int type, int dim)
public void compileExpr(ASTree expr) throws CompileError
CompileError
public boolean compileBooleanExpr(boolean branchIf, ASTree expr) throws CompileError
CompileError
public void doTypeCheck(ASTree expr) throws CompileError
CompileError
public void atASTList(ASTList n) throws CompileError
atASTList
in class Visitor
CompileError
public void atPair(Pair n) throws CompileError
atPair
in class Visitor
CompileError
public void atSymbol(Symbol n) throws CompileError
atSymbol
in class Visitor
CompileError
public void atFieldDecl(FieldDecl field) throws CompileError
atFieldDecl
in class Visitor
CompileError
public void atMethodDecl(MethodDecl method) throws CompileError
atMethodDecl
in class Visitor
CompileError
public void atMethodBody(Stmnt s, boolean isCons, boolean isVoid) throws CompileError
isCons
- true if super() must be called.
false if the method is a class initializer.CompileError
protected abstract void insertDefaultSuperCall() throws CompileError
CompileError
public void atStmnt(Stmnt st) throws CompileError
atStmnt
in class Visitor
CompileError
protected void patchGoto(ArrayList list, int targetPc)
protected void atReturnStmnt(Stmnt st) throws CompileError
CompileError
protected final void atReturnStmnt2(ASTree result) throws CompileError
CompileError
protected void atTryStmnt(Stmnt st) throws CompileError
CompileError
public void atDeclarator(Declarator d) throws CompileError
atDeclarator
in class Visitor
CompileError
public abstract void atNewExpr(NewExpr n) throws CompileError
atNewExpr
in class Visitor
CompileError
public abstract void atArrayInit(ArrayInit init) throws CompileError
atArrayInit
in class Visitor
CompileError
public void atAssignExpr(AssignExpr expr) throws CompileError
atAssignExpr
in class Visitor
CompileError
protected void atAssignExpr(AssignExpr expr, boolean doDup) throws CompileError
CompileError
protected static void badAssign(Expr expr) throws CompileError
CompileError
protected abstract void atArrayVariableAssign(ArrayInit init, int varType, int varArray, String varClass) throws CompileError
CompileError
protected abstract void atFieldAssign(Expr expr, int op, ASTree left, ASTree right, boolean doDup) throws CompileError
CompileError
protected void atAssignCore(Expr expr, int op, ASTree right, int type, int dim, String cname) throws CompileError
CompileError
public void atCondExpr(CondExpr expr) throws CompileError
atCondExpr
in class Visitor
CompileError
public void atBinExpr(BinExpr expr) throws CompileError
atBinExpr
in class Visitor
CompileError
protected static void badTypes(Expr expr) throws CompileError
CompileError
protected static boolean isRefType(int type)
public void atCastExpr(CastExpr expr) throws CompileError
atCastExpr
in class Visitor
CompileError
public void atInstanceOfExpr(InstanceOfExpr expr) throws CompileError
atInstanceOfExpr
in class Visitor
CompileError
public void atExpr(Expr expr) throws CompileError
atExpr
in class Visitor
CompileError
protected static void badType(Expr expr) throws CompileError
CompileError
public abstract void atCallExpr(CallExpr expr) throws CompileError
atCallExpr
in class Visitor
CompileError
protected abstract void atFieldRead(ASTree expr) throws CompileError
CompileError
public void atClassObject(Expr expr) throws CompileError
CompileError
protected void atClassObject2(String cname) throws CompileError
CompileError
public void atArrayRead(ASTree array, ASTree index) throws CompileError
CompileError
protected void arrayAccess(ASTree array, ASTree index) throws CompileError
CompileError
protected static int getArrayReadOp(int type, int dim)
protected static int getArrayWriteOp(int type, int dim)
public void atArrayPlusPlus(int token, boolean isPost, Expr expr, boolean doDup) throws CompileError
CompileError
protected void atPlusPlusCore(int dup_code, boolean doDup, int token, boolean isPost, Expr expr) throws CompileError
CompileError
protected abstract void atFieldPlusPlus(int token, boolean isPost, ASTree oprand, Expr expr, boolean doDup) throws CompileError
CompileError
public abstract void atMember(Member n) throws CompileError
atMember
in class Visitor
CompileError
public void atVariable(Variable v) throws CompileError
atVariable
in class Visitor
CompileError
public void atKeyword(Keyword k) throws CompileError
atKeyword
in class Visitor
CompileError
public void atStringL(StringL s) throws CompileError
atStringL
in class Visitor
CompileError
public void atIntConst(IntConst i) throws CompileError
atIntConst
in class Visitor
CompileError
public void atDoubleConst(DoubleConst d) throws CompileError
atDoubleConst
in class Visitor
CompileError
Copyright © 2024. All rights reserved.