private static int addLoad(Bytecode code, int n, Class type) { if (type.isPrimitive()) { if (type == Long.TYPE) { code.addLload(n); return 2; } else if (type == Float.TYPE) code.addFload(n); else if (type == Double.TYPE) { code.addDload(n); return 2; } else code.addIload(n); } else code.addAload(n); return 1; }
private static int addLoad(Bytecode code, int n, Class<?> type) { if (type.isPrimitive()) { if (type == Long.TYPE) { code.addLload(n); return 2; } else if (type == Float.TYPE) code.addFload(n); else if (type == Double.TYPE) { code.addDload(n); return 2; } else code.addIload(n); } else code.addAload(n); return 1; }
addFload(n); else if(type == CtClass.doubleType) { addDload(n); return 2;
addFload(n); else if(type == CtClass.doubleType) { addDload(n); return 2;
public void atVariable(Variable v) throws CompileError { Declarator d = v.getDeclarator(); exprType = d.getType(); arrayDim = d.getArrayDim(); className = d.getClassName(); int var = getLocalVar(d); if (arrayDim > 0) bytecode.addAload(var); else switch (exprType) { case CLASS : bytecode.addAload(var); break; case LONG : bytecode.addLload(var); break; case FLOAT : bytecode.addFload(var); break; case DOUBLE : bytecode.addDload(var); break; default : // BOOLEAN, BYTE, CHAR, SHORT, INT bytecode.addIload(var); break; } }
private void addDoubleSetter(ClassFile classFile, String fieldName) throws DuplicateMemberException { ConstPool constPool = classFile.getConstPool(); // void setFoo(double) MethodInfo setter = new MethodInfo(constPool, "set" + ucfirst(fieldName), "(D)V"); Bytecode code = new Bytecode(constPool, 3, 3); // load this code.addAload(0); // load param code.addDload(1); code.addPutfield(ctClass, fieldName, "D"); code.addOpcode(Opcode.RETURN); setter.setCodeAttribute(code.toCodeAttribute()); setter.setAccessFlags(AccessFlag.PUBLIC); classFile.addMethod(setter); } }
@Override public void atVariable(Variable v) throws CompileError { Declarator d = v.getDeclarator(); exprType = d.getType(); arrayDim = d.getArrayDim(); className = d.getClassName(); int var = getLocalVar(d); if (arrayDim > 0) bytecode.addAload(var); else switch (exprType) { case CLASS : bytecode.addAload(var); break; case LONG : bytecode.addLload(var); break; case FLOAT : bytecode.addFload(var); break; case DOUBLE : bytecode.addDload(var); break; default : // BOOLEAN, BYTE, CHAR, SHORT, INT bytecode.addIload(var); break; } }
b.addDstore(getVar(2)); jsrJmp(b); b.addDload(var); break; case FRETURN :
b.addDstore(getVar(2)); jsrJmp(b); b.addDload(var); break; case FRETURN :
bytecode.addDload(var); if (doDup && isPost) bytecode.addOpcode(DUP2);
bytecode.addDload(var); if (doDup && isPost) bytecode.addOpcode(DUP2);
private static void addTypeDependDataLoad(Bytecode code, String typeName, int i) { if ((typeName.charAt(0) == 'L') && (typeName.charAt(typeName.length() - 1) == ';') || (typeName.charAt(0) == '[')) { // reference type code.addAload(i); } else if (typeName.equals("Z") || typeName.equals("B") || typeName.equals("C") || typeName.equals("I") || typeName.equals("S")) { // boolean, byte, char, int, short code.addIload(i); } else if (typeName.equals("D")) { // double code.addDload(i); } else if (typeName.equals("F")) { // float code.addFload(i); } else if (typeName.equals("J")) { // long code.addLload(i); } else { // bad type throw new RuntimeException("bad type: " + typeName); } }
static Bytecode makeBytecodeForLVStore(CtMethod method, String sig, String name, int slot) { Bytecode b = new Bytecode(method.getMethodInfo().getConstPool()); b.addLdc(name); if ("I".equals(sig) || "B".equals(sig) || "C".equals(sig) || "S".equals(sig) || "Z".equals(sig)) b.addIload(slot); else if ("F".equals(sig)) b.addFload(slot); else if ("J".equals(sig)) b.addLload(slot); else if ("D".equals(sig)) b.addDload(slot); else b.addAload(slot); String localVarDescriptor = sig; if (!"B".equals(sig) && !"C".equals(sig) && !"D".equals(sig) && !"F".equals(sig) && !"I".equals(sig) && !"J".equals(sig) && !"S".equals(sig) && !"Z".equals(sig)) localVarDescriptor = "Ljava/lang/Object;"; Logger.trace("for variable '%s' in slot=%s, sig was '%s' and is now '%s'", name, slot, sig, localVarDescriptor); b.addInvokestatic("play.classloading.enhancers.LocalvariablesNamesEnhancer$LocalVariablesNamesTracer", "addVariable", "(Ljava/lang/String;" + localVarDescriptor + ")V"); return b; }
private static int addLoad(Bytecode code, int n, Class type) { if (type.isPrimitive()) { if (type == Long.TYPE) { code.addLload(n); return 2; } else if (type == Float.TYPE) code.addFload(n); else if (type == Double.TYPE) { code.addDload(n); return 2; } else code.addIload(n); } else code.addAload(n); return 1; }
private static int addLoad(Bytecode code, int n, Class type) { if (type.isPrimitive()) { if (type == Long.TYPE) { code.addLload(n); return 2; } else if (type == Float.TYPE) code.addFload(n); else if (type == Double.TYPE) { code.addDload(n); return 2; } else code.addIload(n); } else code.addAload(n); return 1; }
private static int addLoad(Bytecode code, int n, Class type) { if (type.isPrimitive()) { if (type == Long.TYPE) { code.addLload(n); return 2; } else if (type == Float.TYPE) code.addFload(n); else if (type == Double.TYPE) { code.addDload(n); return 2; } else code.addIload(n); } else code.addAload(n); return 1; }
private static int addLoad(Bytecode code, int n, Class type) { if (type.isPrimitive()) { if (type == Long.TYPE) { code.addLload(n); return 2; } else if (type == Float.TYPE) code.addFload(n); else if (type == Double.TYPE) { code.addDload(n); return 2; } else code.addIload(n); } else code.addAload(n); return 1; }
private static int addLoad(Bytecode code, int n, Class type) { if (type.isPrimitive()) { if (type == Long.TYPE) { code.addLload(n); return 2; } else if (type == Float.TYPE) code.addFload(n); else if (type == Double.TYPE) { code.addDload(n); return 2; } else code.addIload(n); } else code.addAload(n); return 1; }
private static int addLoad(Bytecode code, int n, Class type) { if (type.isPrimitive()) { if (type == Long.TYPE) { code.addLload(n); return 2; } else if (type == Float.TYPE) code.addFload(n); else if (type == Double.TYPE) { code.addDload(n); return 2; } else code.addIload(n); } else code.addAload(n); return 1; }
public void atVariable(Variable v) throws CompileError { Declarator d = v.getDeclarator(); exprType = d.getType(); arrayDim = d.getArrayDim(); className = d.getClassName(); int var = getLocalVar(d); if (arrayDim > 0) bytecode.addAload(var); else switch (exprType) { case CLASS : bytecode.addAload(var); break; case LONG : bytecode.addLload(var); break; case FLOAT : bytecode.addFload(var); break; case DOUBLE : bytecode.addDload(var); break; default : // BOOLEAN, BYTE, CHAR, SHORT, INT bytecode.addIload(var); break; } }