int compile(Bytecode code) throws CannotCompileException { code.addLdc(param); return 1; }
@Override int compile(Bytecode code) throws CannotCompileException { code.addLdc(param); return 1; }
/** * Appends LDC or LDC_W. The pushed item is a <code>String</code> * object. * * @param s the character string pushed by LDC or LDC_W. */ public void addLdc(String s) { addLdc(constPool.addStringInfo(s)); }
public void atStringL(StringL s) throws CompileError { exprType = CLASS; arrayDim = 0; className = jvmJavaLangString; bytecode.addLdc(s.get()); }
/** * Appends LDC or LDC_W. The pushed item is a <code>String</code> * object. * * @param s the character string pushed by LDC or LDC_W. */ public void addLdc(String s) { addLdc(constPool.addStringInfo(s)); }
@Override public void atStringL(StringL s) throws CompileError { exprType = CLASS; arrayDim = 0; className = jvmJavaLangString; bytecode.addLdc(s.get()); }
/** * 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)); }
int compileIfStatic(CtClass type, String name, Bytecode code, Javac drv) throws CannotCompileException { code.addLdc(value); code.addPutstatic(Bytecode.THIS, name, Descriptor.of(type)); return 1; // stack size }
/** * Appends instructions for executing * <code>java.lang.System.println(<i>message</i>)</code>. * * @param message printed message. */ public void addPrintln(String message) { addGetstatic("java.lang.System", "err", "Ljava/io/PrintStream;"); addLdc(message); addInvokevirtual("java.io.PrintStream", "println", "(Ljava/lang/String;)V"); } }
/** * @param thisMethod might be null. */ private static void callFind2Methods(Bytecode code, String superMethod, String thisMethod, int index, String desc, int classVar, int arrayVar) { String findClass = RuntimeSupport.class.getName(); String findDesc = "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/reflect/Method;)V"; code.addAload(classVar); code.addLdc(superMethod); if (thisMethod == null) code.addOpcode(Opcode.ACONST_NULL); else code.addLdc(thisMethod); code.addIconst(index); code.addLdc(desc); code.addAload(arrayVar); code.addInvokestatic(findClass, "find2Methods", findDesc); }
/** * 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)); }
@Override int compileIfStatic(CtClass type, String name, Bytecode code, Javac drv) throws CannotCompileException { code.addLdc(value); code.addPutstatic(Bytecode.THIS, name, Descriptor.of(type)); return 1; // stack size }
int compile(CtClass type, String name, Bytecode code, CtClass[] parameters, Javac drv) throws CannotCompileException { code.addAload(0); code.addLdc(value); code.addPutfield(Bytecode.THIS, name, Descriptor.of(type)); return 2; // stack size }
/** * Appends instructions for executing * <code>java.lang.System.println(<i>message</i>)</code>. * * @param message printed message. */ public void addPrintln(String message) { addGetstatic("java.lang.System", "err", "Ljava/io/PrintStream;"); addLdc(message); addInvokevirtual("java.io.PrintStream", "println", "(Ljava/lang/String;)V"); } }
protected void atClassObject2(String cname) throws CompileError { if (getMajorVersion() < ClassFile.JAVA_5) super.atClassObject2(cname); else bytecode.addLdc(bytecode.getConstPool().addClassInfo(cname)); }
@Override int compile(CtClass type, String name, Bytecode code, CtClass[] parameters, Javac drv) throws CannotCompileException { code.addAload(0); code.addLdc(value); code.addPutfield(Bytecode.THIS, name, Descriptor.of(type)); return 2; // stack size }
@Override protected void atClassObject2(String cname) throws CompileError { if (getMajorVersion() < ClassFile.JAVA_5) super.atClassObject2(cname); else bytecode.addLdc(bytecode.getConstPool().addClassInfo(cname)); }
protected final int compileStringParameter(Bytecode code) throws CannotCompileException { int nparam = stringParams.length; code.addIconst(nparam); code.addAnewarray(javaLangString); for (int j = 0; j < nparam; ++j) { code.add(Bytecode.DUP); // dup code.addIconst(j); // iconst_<j> code.addLdc(stringParams[j]); // ldc ... code.add(Bytecode.AASTORE); // aastore } return 4; }
protected final int compileStringParameter(Bytecode code) throws CannotCompileException { int nparam = stringParams.length; code.addIconst(nparam); code.addAnewarray(javaLangString); for (int j = 0; j < nparam; ++j) { code.add(Bytecode.DUP); // dup code.addIconst(j); // iconst_<j> code.addLdc(stringParams[j]); // ldc ... code.add(Bytecode.AASTORE); // aastore } return 4; }
/** * Appends ICONST or ICONST_<n> * * @param n the pushed integer constant. */ public void addIconst(int n) { if (n < 6 && -2 < n) addOpcode(3 + n); // iconst_<i> -1..5 else if (n <= 127 && -128 <= n) { addOpcode(16); // bipush add(n); } else if (n <= 32767 && -32768 <= n) { addOpcode(17); // sipush add(n >> 8); add(n); } else addLdc(constPool.addIntegerInfo(n)); }