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 |
(package private) static int[] |
binOp |
protected java.util.ArrayList |
breakList |
protected Bytecode |
bytecode |
private static int[] |
castOp |
protected java.lang.String |
className |
protected java.util.ArrayList |
continueList |
protected int |
exprType |
protected boolean |
hasReturned
true if the last visited node is a return statement.
|
private static int[] |
ifOp |
private static int[] |
ifOp2 |
boolean |
inStaticMethod
Must be true if compilation is for a static method.
|
(package private) static java.lang.String |
javaLangObject |
(package private) static java.lang.String |
javaLangString |
(package private) static java.lang.String |
jvmJavaLangObject |
(package private) static java.lang.String |
jvmJavaLangString |
private static int |
P_DOUBLE |
private static int |
P_FLOAT |
private static int |
P_INT |
private static int |
P_LONG |
private static int |
P_OTHER |
protected CodeGen.ReturnHook |
returnHooks |
private int |
tempVar |
(package private) TypeChecker |
typeChecker |
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) |
private void |
atArithBinExpr(Expr expr,
int token,
int index,
int type1) |
private void |
atArrayAssign(Expr expr,
int op,
Expr array,
ASTree right,
boolean doDup) |
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) |
private void |
atBreakStmnt(Stmnt st,
boolean notCont) |
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) |
private void |
atForStmnt(Stmnt st) |
private void |
atIfStmnt(Stmnt st) |
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) |
(package private) void |
atNumCastExpr(int srcType,
int destType) |
void |
atPair(Pair n) |
private void |
atPlusPlus(int token,
ASTree oprand,
Expr expr,
boolean doDup) |
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) |
private void |
atStringConcatExpr(Expr expr,
int type1,
int dim1,
java.lang.String cname1) |
void |
atStringL(StringL s) |
private void |
atStringPlusEq(Expr expr,
int type,
int dim,
java.lang.String cname,
ASTree right) |
private void |
atSwitchStmnt(Stmnt st) |
void |
atSymbol(Symbol n) |
private void |
atSyncStmnt(Stmnt st) |
private void |
atThrowStmnt(Stmnt st) |
protected void |
atTryStmnt(Stmnt st) |
void |
atVariable(Variable v) |
private void |
atVariableAssign(Expr expr,
int op,
Variable var,
Declarator d,
ASTree right,
boolean doDup) |
private void |
atWhileStmnt(Stmnt st,
boolean notDo) |
protected static void |
badAssign(Expr expr) |
protected static void |
badType(Expr expr) |
protected static void |
badTypes(Expr expr) |
private boolean |
booleanExpr(boolean branchIf,
ASTree expr) |
private java.lang.String |
checkCastExpr(CastExpr expr,
java.lang.String name) |
private void |
compareExpr(boolean branchIf,
int token,
int type1,
BinExpr expr) |
boolean |
compileBooleanExpr(boolean branchIf,
ASTree expr) |
void |
compileExpr(ASTree expr) |
private int |
compileOprands(BinExpr expr) |
private int |
computeLabel(ASTree expr) |
private void |
convertOprandTypes(int type1,
int type2,
Expr expr) |
private void |
convToString(int type,
int dim) |
void |
doTypeCheck(ASTree expr) |
protected static void |
fatal() |
protected static int |
getArrayReadOp(int type,
int dim) |
protected static int |
getArrayWriteOp(int type,
int dim) |
(package private) static int |
getCompOperator(ASTree expr) |
private static int |
getListSize(java.util.ArrayList list) |
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() |
private boolean |
invalidDim(int srcType,
int srcDim,
java.lang.String srcClass,
int destType,
int destDim,
java.lang.String destClass,
boolean isCast) |
static boolean |
is2word(int type,
int dim) |
private static boolean |
isAlwaysBranch(ASTree expr,
boolean branchIf) |
(package private) static boolean |
isP_INT(int type) |
private static boolean |
isPlusPlusExpr(ASTree expr) |
protected static boolean |
isRefType(int type) |
(package private) static int |
lookupBinOp(int token) |
private boolean |
needsSuperCall(Stmnt body) |
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) |
(package private) static boolean |
rightIsStrong(int type1,
int type2) |
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) |
private static int |
typePrecedence(int type) |
static final java.lang.String javaLangObject
static final java.lang.String jvmJavaLangObject
static final java.lang.String javaLangString
static final java.lang.String jvmJavaLangString
protected Bytecode bytecode
private int tempVar
TypeChecker typeChecker
protected boolean hasReturned
public boolean inStaticMethod
protected java.util.ArrayList breakList
protected java.util.ArrayList continueList
protected CodeGen.ReturnHook returnHooks
protected int exprType
protected int arrayDim
protected java.lang.String className
static final int[] binOp
private static final int[] ifOp
private static final int[] ifOp2
private static final int P_DOUBLE
private static final int P_FLOAT
private static final int P_LONG
private static final int P_INT
private static final int P_OTHER
private static final int[] castOp
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 java.lang.String getThisName()
protected abstract java.lang.String getSuperName() throws CompileError
CompileError
protected abstract java.lang.String resolveClassName(ASTList name) throws CompileError
CompileError
protected abstract java.lang.String resolveClassName(java.lang.String jvmClassName) throws CompileError
CompileError
protected static java.lang.String toJvmArrayName(java.lang.String name, int dim)
name
- the JVM-internal representation.
name is not exapnded to java.lang.*.protected static java.lang.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
private boolean needsSuperCall(Stmnt body) throws CompileError
CompileError
protected abstract void insertDefaultSuperCall() throws CompileError
CompileError
public void atStmnt(Stmnt st) throws CompileError
atStmnt
in class Visitor
CompileError
private void atIfStmnt(Stmnt st) throws CompileError
CompileError
private void atWhileStmnt(Stmnt st, boolean notDo) throws CompileError
CompileError
protected void patchGoto(java.util.ArrayList list, int targetPc)
private void atForStmnt(Stmnt st) throws CompileError
CompileError
private void atSwitchStmnt(Stmnt st) throws CompileError
CompileError
private int computeLabel(ASTree expr) throws CompileError
CompileError
private void atBreakStmnt(Stmnt st, boolean notCont) throws CompileError
CompileError
protected void atReturnStmnt(Stmnt st) throws CompileError
CompileError
protected final void atReturnStmnt2(ASTree result) throws CompileError
CompileError
private void atThrowStmnt(Stmnt st) throws CompileError
CompileError
protected void atTryStmnt(Stmnt st) throws CompileError
CompileError
private void atSyncStmnt(Stmnt st) throws CompileError
CompileError
private static int getListSize(java.util.ArrayList list)
private static boolean isPlusPlusExpr(ASTree expr)
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
private void atVariableAssign(Expr expr, int op, Variable var, Declarator d, ASTree right, boolean doDup) throws CompileError
CompileError
protected abstract void atArrayVariableAssign(ArrayInit init, int varType, int varArray, java.lang.String varClass) throws CompileError
CompileError
private void atArrayAssign(Expr expr, int op, Expr array, ASTree right, boolean doDup) 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, java.lang.String cname) throws CompileError
CompileError
private void atStringPlusEq(Expr expr, int type, int dim, java.lang.String cname, ASTree right) throws CompileError
CompileError
private boolean invalidDim(int srcType, int srcDim, java.lang.String srcClass, int destType, int destDim, java.lang.String destClass, boolean isCast)
public void atCondExpr(CondExpr expr) throws CompileError
atCondExpr
in class Visitor
CompileError
static int lookupBinOp(int token)
public void atBinExpr(BinExpr expr) throws CompileError
atBinExpr
in class Visitor
CompileError
private void atArithBinExpr(Expr expr, int token, int index, int type1) throws CompileError
CompileError
private void atStringConcatExpr(Expr expr, int type1, int dim1, java.lang.String cname1) throws CompileError
CompileError
private void convToString(int type, int dim) throws CompileError
CompileError
private boolean booleanExpr(boolean branchIf, ASTree expr) throws CompileError
CompileError
private static boolean isAlwaysBranch(ASTree expr, boolean branchIf)
static int getCompOperator(ASTree expr) throws CompileError
CompileError
private int compileOprands(BinExpr expr) throws CompileError
CompileError
private void compareExpr(boolean branchIf, int token, int type1, BinExpr expr) throws CompileError
CompileError
protected static void badTypes(Expr expr) throws CompileError
CompileError
protected static boolean isRefType(int type)
private static int typePrecedence(int type)
static boolean isP_INT(int type)
static boolean rightIsStrong(int type1, int type2)
private void convertOprandTypes(int type1, int type2, Expr expr) throws CompileError
CompileError
public void atCastExpr(CastExpr expr) throws CompileError
atCastExpr
in class Visitor
CompileError
public void atInstanceOfExpr(InstanceOfExpr expr) throws CompileError
atInstanceOfExpr
in class Visitor
CompileError
private java.lang.String checkCastExpr(CastExpr expr, java.lang.String name) throws CompileError
CompileError
void atNumCastExpr(int srcType, int destType) throws CompileError
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(java.lang.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)
private void atPlusPlus(int token, ASTree oprand, Expr expr, boolean doDup) throws CompileError
CompileError
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