public void addNullIfVoid() { if (exprType == VOID) { bytecode.addOpcode(ACONST_NULL); exprType = CLASS; arrayDim = 0; className = jvmJavaLangObject; } }
/** * Appends DCONST or DCONST_<n> * * @param d the pushed double constant. */ public void addDconst(double d) { if (d == 0.0 || d == 1.0) addOpcode(14 + (int)d); // dconst_<n> else addLdc2w(d); }
private void atArrayLength(ASTree expr) throws CompileError { if (arrayDim == 0) throw new CompileError(".length applied to a non array"); bytecode.addOpcode(ARRAYLENGTH); exprType = INT; arrayDim = 0; }
/** * Appends LCONST or LCONST_<n> * * @param n the pushed long integer constant. */ public void addLconst(long n) { if (n == 0 || n == 1) addOpcode(9 + (int)n); // lconst_<n> else addLdc2w(n); }
private void jsrJmp(Bytecode b) { b.addOpcode(Opcode.GOTO); jsrList.add(new int[] {b.currentPc(), var}); b.addIndex(0); }
/** * Appends CHECKCAST. * * @param classname a fully-qualified class name. */ public void addCheckcast(String classname) { addOpcode(CHECKCAST); addIndex(constPool.addClassInfo(classname)); }
/** * Appends ANEWARRAY. * * @param classname the qualified class name of the element type. */ public void addAnewarray(String classname) { addOpcode(ANEWARRAY); addIndex(constPool.addClassInfo(classname)); }
protected void atReturnStmnt(Stmnt st) throws CompileError { ASTree result = st.getLeft(); if (result != null && returnType == CtClass.voidType) { compileExpr(result); if (is2word(exprType, arrayDim)) bytecode.addOpcode(POP2); else if (exprType != VOID) bytecode.addOpcode(POP); result = null; } atReturnStmnt2(result); }
public void atArrayRead(ASTree array, ASTree index) throws CompileError { arrayAccess(array, index); bytecode.addOpcode(getArrayReadOp(exprType, arrayDim)); }
/** * Appends CHECKCAST. * * @param c the type. */ public void addCheckcast(CtClass c) { addOpcode(CHECKCAST); addIndex(constPool.addClassInfo(c)); }
/** * Appends INSTANCEOF. * * @param classname the class name. */ public void addInstanceof(String classname) { addOpcode(INSTANCEOF); addIndex(constPool.addClassInfo(classname)); }
/** * Appends NEW. * * @param clazz the class of the created instance. */ public void addNew(CtClass clazz) { addOpcode(NEW); addIndex(constPool.addClassInfo(clazz)); }
static final void storeStack(CtClass[] params, boolean isStaticCall, int regno, Bytecode bytecode) { storeStack0(0, params.length, params, regno + 1, bytecode); if (isStaticCall) bytecode.addOpcode(ACONST_NULL); bytecode.addAstore(regno); }
/** * Appends FCONST or FCONST_<n> * * @param f the pushed float constant. */ public void addFconst(float f) { if (f == 0.0f || f == 1.0f || f == 2.0f) addOpcode(11 + (int)f); // fconst_<n> else addLdc(constPool.addFloatInfo(f)); }
/** * Appends LDC2_W. The pushed item is a double value. */ public void addLdc2w(double d) { addOpcode(LDC2_W); addIndex(constPool.addDoubleInfo(d)); }
private void atThrowStmnt(Stmnt st) throws CompileError { ASTree e = st.getLeft(); compileExpr(e); if (exprType != CLASS || arrayDim > 0) throw new CompileError("bad throw statement"); bytecode.addOpcode(ATHROW); hasReturned = true; }
/** * Appends ICONST and ANEWARRAY. * * @param clazz the elememnt type. * @param length the array length. */ public void addAnewarray(CtClass clazz, int length) { addIconst(length); addOpcode(ANEWARRAY); addIndex(constPool.addClassInfo(clazz)); }
private static int makeWrapper(Bytecode code, Class type, int regno) { int index = FactoryHelper.typeIndex(type); String wrapper = FactoryHelper.wrapperTypes[index]; code.addNew(wrapper); code.addOpcode(Opcode.DUP); addLoad(code, regno, type); code.addInvokespecial(wrapper, "<init>", FactoryHelper.wrapperDesc[index]); return regno + FactoryHelper.dataSize[index]; }
public void doit(JvstCodeGen gen, Bytecode bytecode, ASTList args) throws CompileError { if (gen.getMethodArgsLength(args) != 1) throw new CompileError(Javac.proceedName + "() cannot take more than one parameter " + "for cast"); gen.atMethodArgs(args, new int[1], new int[1], new String[1]); bytecode.addOpcode(Opcode.CHECKCAST); bytecode.addIndex(index); gen.setType(retType); }