List of usage examples for org.objectweb.asm Opcodes DLOAD
int DLOAD
To view the source code for org.objectweb.asm Opcodes DLOAD.
Click Source Link
From source file:org.glassfish.pfl.tf.spi.Util.java
License:Open Source License
public void loadFromXReturn(MethodVisitor mv, int returnOpcode, LocalVariableNode holder) { switch (returnOpcode) { case Opcodes.RETURN: // NOP/* w w w . jav a2 s.c o m*/ break; case Opcodes.ARETURN: mv.visitVarInsn(Opcodes.ALOAD, holder.index); break; case Opcodes.IRETURN: mv.visitVarInsn(Opcodes.ILOAD, holder.index); break; case Opcodes.LRETURN: mv.visitVarInsn(Opcodes.LLOAD, holder.index); break; case Opcodes.FRETURN: mv.visitVarInsn(Opcodes.FLOAD, holder.index); break; case Opcodes.DRETURN: mv.visitVarInsn(Opcodes.DLOAD, holder.index); break; } }
From source file:org.jacoco.core.internal.instr.FrameTracker.java
License:Open Source License
@Override public void visitVarInsn(final int opcode, final int var) { final Object t; switch (opcode) { case Opcodes.ALOAD: push(get(var)); break;/*from w ww.ja v a 2s. c o m*/ case Opcodes.ILOAD: push(Opcodes.INTEGER); break; case Opcodes.FLOAD: push(Opcodes.FLOAT); break; case Opcodes.LLOAD: push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.DLOAD: push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.ASTORE: case Opcodes.ISTORE: case Opcodes.FSTORE: t = pop(); set(var, t); break; case Opcodes.LSTORE: case Opcodes.DSTORE: pop(1); t = pop(); set(var, t); set(var + 1, Opcodes.TOP); break; default: throw new IllegalArgumentException(); } mv.visitVarInsn(opcode, var); }
From source file:org.mbte.groovypp.compiler.bytecode.BytecodeExpr.java
License:Apache License
public static void load(ClassNode type, int idx, MethodVisitor mv) { if (type == double_TYPE) { mv.visitVarInsn(Opcodes.DLOAD, idx); } else if (type == float_TYPE) { mv.visitVarInsn(Opcodes.FLOAD, idx); } else if (type == long_TYPE) { mv.visitVarInsn(Opcodes.LLOAD, idx); } else if (type == boolean_TYPE || type == char_TYPE || type == byte_TYPE || type == int_TYPE || type == short_TYPE) { mv.visitVarInsn(Opcodes.ILOAD, idx); } else {// w w w . j a va 2 s . c o m mv.visitVarInsn(Opcodes.ALOAD, idx); } }
From source file:org.mbte.groovypp.compiler.ClosureUtil.java
License:Apache License
private static void makeOneMethodClass(List<MethodNode> abstractMethods, final ClassNode closureType, ClassNode baseType, CompilerTransformer compiler, final MethodNode doCall) { boolean traitMethods = false; int k = 0;/* w w w. java 2 s . c o m*/ for (final MethodNode missed : abstractMethods) { final Parameter[] parameters = eraseParameterTypes(missed.getParameters()); if (k == 0) { closureType.addMethod(missed.getName(), Opcodes.ACC_PUBLIC, getSubstitutedReturnType(doCall, missed, closureType, baseType), parameters, ClassNode.EMPTY_ARRAY, new BytecodeSequence(new BytecodeInstruction() { public void visit(MethodVisitor mv) { mv.visitVarInsn(Opcodes.ALOAD, 0); Parameter pp[] = parameters; for (int i = 0, k = 1; i != pp.length; ++i) { final ClassNode type = pp[i].getType(); ClassNode expectedType = doCall.getParameters()[i].getType(); if (ClassHelper.isPrimitiveType(type)) { if (type == ClassHelper.long_TYPE) { mv.visitVarInsn(Opcodes.LLOAD, k++); k++; } else if (type == ClassHelper.double_TYPE) { mv.visitVarInsn(Opcodes.DLOAD, k++); k++; } else if (type == ClassHelper.float_TYPE) { mv.visitVarInsn(Opcodes.FLOAD, k++); } else { mv.visitVarInsn(Opcodes.ILOAD, k++); } BytecodeExpr.box(type, mv); BytecodeExpr.cast(TypeUtil.wrapSafely(type), TypeUtil.wrapSafely(expectedType), mv); } else { mv.visitVarInsn(Opcodes.ALOAD, k++); BytecodeExpr.checkCast(TypeUtil.wrapSafely(expectedType), mv); } BytecodeExpr.unbox(expectedType, mv); } mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, BytecodeHelper.getClassInternalName(doCall.getDeclaringClass()), doCall.getName(), BytecodeHelper.getMethodDescriptor(doCall.getReturnType(), doCall.getParameters())); if (missed.getReturnType() != ClassHelper.VOID_TYPE && !missed.getReturnType().equals(doCall.getReturnType())) { BytecodeExpr.box(doCall.getReturnType(), mv); BytecodeExpr.checkCast(TypeUtil.wrapSafely(doCall.getReturnType()), mv); BytecodeExpr.unbox(missed.getReturnType(), mv); } BytecodeExpr.doReturn(mv, missed.getReturnType()); } })); } else { if (traitMethod(missed)) { traitMethods = true; } else if (likeGetter(missed)) { String pname = missed.getName().substring(3); pname = Character.toLowerCase(pname.charAt(0)) + pname.substring(1); final PropertyNode propertyNode = closureType.addProperty(pname, Opcodes.ACC_PUBLIC, missed.getReturnType(), null, null, null); propertyNode.getField().addAnnotation(new AnnotationNode(TypeUtil.NO_EXTERNAL_INITIALIZATION)); } else { if (likeSetter(missed)) { String pname = missed.getName().substring(3); pname = Character.toLowerCase(pname.charAt(0)) + pname.substring(1); final PropertyNode propertyNode = closureType.addProperty(pname, Opcodes.ACC_PUBLIC, parameters[0].getType(), null, null, null); propertyNode.getField() .addAnnotation(new AnnotationNode(TypeUtil.NO_EXTERNAL_INITIALIZATION)); } } } k++; } if (traitMethods) TraitASTTransformFinal.improveAbstractMethods(closureType); }
From source file:org.mbte.groovypp.compiler.ClosureUtil.java
License:Apache License
public static void createClosureConstructor(final ClassNode newType, final Parameter[] constrParams, Expression superArgs, CompilerTransformer compiler) { final ClassNode superClass = newType.getSuperClass(); final Parameter[] finalConstrParams; final ArgumentListExpression superCallArgs = new ArgumentListExpression(); if (superArgs != null) { final ArgumentListExpression args = (ArgumentListExpression) superArgs; if (args.getExpressions().size() > 0) { Parameter[] newParams = new Parameter[constrParams.length + args.getExpressions().size()]; System.arraycopy(constrParams, 0, newParams, 0, constrParams.length); for (int i = 0; i != args.getExpressions().size(); ++i) { final Parameter parameter = new Parameter(args.getExpressions().get(i).getType(), "$super$param$" + i); newParams[i + constrParams.length] = parameter; superCallArgs.addExpression(new VariableExpression(parameter)); }/* w w w . j a v a 2 s. c om*/ finalConstrParams = newParams; } else finalConstrParams = constrParams; } else { if (superClass == ClassHelper.CLOSURE_TYPE) { if (constrParams.length > 0) { superCallArgs.addExpression(new VariableExpression(constrParams[0])); superCallArgs.addExpression(new VariableExpression(constrParams[0])); } else if (compiler.methodNode.isStatic() && !compiler.classNode.getName().endsWith("$TraitImpl")) { ClassNode cn = compiler.classNode; superCallArgs.addExpression(new ClassExpression(cn)); superCallArgs.addExpression(new ClassExpression(getOutermostClass(cn))); } else { superCallArgs.addExpression(ConstantExpression.NULL); superCallArgs.addExpression(ConstantExpression.NULL); } } finalConstrParams = constrParams; } ConstructorCallExpression superCall = new ConstructorCallExpression(ClassNode.SUPER, superCallArgs); BytecodeSequence fieldInit = new BytecodeSequence(new BytecodeInstruction() { public void visit(MethodVisitor mv) { for (int i = 0, k = 1; i != constrParams.length; i++) { mv.visitVarInsn(Opcodes.ALOAD, 0); final ClassNode type = constrParams[i].getType(); if (ClassHelper.isPrimitiveType(type)) { if (type == ClassHelper.long_TYPE) { mv.visitVarInsn(Opcodes.LLOAD, k++); k++; } else if (type == ClassHelper.double_TYPE) { mv.visitVarInsn(Opcodes.DLOAD, k++); k++; } else if (type == ClassHelper.float_TYPE) { mv.visitVarInsn(Opcodes.FLOAD, k++); } else { mv.visitVarInsn(Opcodes.ILOAD, k++); } } else { mv.visitVarInsn(Opcodes.ALOAD, k++); } mv.visitFieldInsn(Opcodes.PUTFIELD, BytecodeHelper.getClassInternalName(newType), constrParams[i].getName(), BytecodeHelper.getTypeDescription(type)); } mv.visitInsn(Opcodes.RETURN); } }); BlockStatement code = new BlockStatement(); code.addStatement(new ExpressionStatement(superCall)); ConstructorNode cn = new ConstructorNode(Opcodes.ACC_PUBLIC, finalConstrParams, ClassNode.EMPTY_ARRAY, code); newType.addConstructor(cn); code.addStatement(fieldInit); CleaningVerifier.getCleaningVerifier().visitClass(newType); compiler.replaceMethodCode(newType, cn); if (newType.getOuterClass() != null && newType.getMethods("methodMissing").isEmpty()) { final ClassNode this0Type = (!compiler.methodNode.isStatic() || compiler.classNode.getName().endsWith("$TraitImpl")) ? newType.getOuterClass() : ClassHelper.CLASS_Type; newType.addMethod("methodMissing", Opcodes.ACC_PUBLIC, ClassHelper.OBJECT_TYPE, new Parameter[] { new Parameter(ClassHelper.STRING_TYPE, "name"), new Parameter(ClassHelper.OBJECT_TYPE, "args") }, ClassNode.EMPTY_ARRAY, new BytecodeSequence(new BytecodeInstruction() { public void visit(MethodVisitor mv) { mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, BytecodeHelper.getClassInternalName(newType), "this$0", BytecodeHelper.getTypeDescription(this0Type)); mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitVarInsn(Opcodes.ALOAD, 2); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "org/codehaus/groovy/runtime/InvokerHelper", "invokeMethod", "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;"); mv.visitInsn(Opcodes.ARETURN); } })); } }
From source file:org.mbte.groovypp.compiler.TraitASTTransformFinal.java
License:Apache License
private static void createGetterSetter(final ClassNode classNode, MethodNode method, final ClassNode fieldType, Parameter[] parameters, final boolean getter, final String fieldName) { classNode.addMethod(method.getName(), ACC_PUBLIC, getter ? fieldType : ClassHelper.VOID_TYPE, parameters, ClassNode.EMPTY_ARRAY, new BytecodeSequence(new BytecodeInstruction() { public void visit(MethodVisitor mv) { if (getter) { mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, BytecodeHelper.getClassInternalName(classNode), fieldName, BytecodeHelper.getTypeDescription(fieldType)); BytecodeExpr.doReturn(mv, fieldType); } else { mv.visitVarInsn(ALOAD, 0); if (fieldType == double_TYPE) { mv.visitVarInsn(Opcodes.DLOAD, 1); } else if (fieldType == float_TYPE) { mv.visitVarInsn(Opcodes.FLOAD, 1); } else if (fieldType == long_TYPE) { mv.visitVarInsn(Opcodes.LLOAD, 1); } else if (fieldType == boolean_TYPE || fieldType == char_TYPE || fieldType == byte_TYPE || fieldType == int_TYPE || fieldType == short_TYPE) { mv.visitVarInsn(Opcodes.ILOAD, 1); } else { mv.visitVarInsn(Opcodes.ALOAD, 1); }//from w w w.j a va 2 s . com mv.visitFieldInsn(PUTFIELD, BytecodeHelper.getClassInternalName(classNode), fieldName, BytecodeHelper.getTypeDescription(fieldType)); mv.visitInsn(RETURN); } } })); }
From source file:org.mutabilitydetector.checkers.settermethod.EffectiveAssignmentInsnVerifier.java
License:Apache License
private static boolean isAliasLoadInstruction(final AbstractInsnNode insn, final int aliasLocalVariable) { switch (insn.getOpcode()) { case Opcodes.ILOAD: case Opcodes.LLOAD: case Opcodes.FLOAD: case Opcodes.DLOAD: case Opcodes.ALOAD: final VarInsnNode varInsnNode = (VarInsnNode) insn; return aliasLocalVariable == varInsnNode.var; default://from w w w.j a v a2s . c om return false; } }
From source file:org.openquark.cal.internal.javamodel.AsmJavaBytecodeGenerator.java
License:Open Source License
private static int getLoadOpCode(JavaTypeName varType) { //ASM automatically handles replacing ILOAD 0, ILOAD 1, ILOAD 2 and ILOAD 3 by the special //0 argument op codes ILOAD_0, ILOAD_1, ILOAD_2, and ILOAD_3 and similarly for the other //types.// w w w .jav a2s .com switch (varType.getTag()) { case JavaTypeName.VOID_TAG: throw new IllegalArgumentException("Cannot load a local variable of void type."); case JavaTypeName.BOOLEAN_TAG: case JavaTypeName.BYTE_TAG: case JavaTypeName.SHORT_TAG: case JavaTypeName.CHAR_TAG: case JavaTypeName.INT_TAG: return Opcodes.ILOAD; case JavaTypeName.LONG_TAG: return Opcodes.LLOAD; case JavaTypeName.DOUBLE_TAG: return Opcodes.DLOAD; case JavaTypeName.FLOAT_TAG: return Opcodes.FLOAD; case JavaTypeName.ARRAY_TAG: case JavaTypeName.OBJECT_TAG: return Opcodes.ALOAD; default: { throw new IllegalArgumentException("Cannot load a local variable of type " + varType); } } }
From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.AODMutator2.java
License:Apache License
@Override public void visitInsn(int opcode) { switch (opcode) { case Opcodes.IADD: case Opcodes.ISUB: case Opcodes.IMUL: case Opcodes.IDIV: case Opcodes.IREM: if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) { int storage = this.newLocal(Type.INT_TYPE); mv.visitVarInsn(Opcodes.ISTORE, storage); mv.visitInsn(Opcodes.POP);/* w w w . ja va 2 s . com*/ mv.visitVarInsn(Opcodes.ILOAD, storage); /* * Alternative : mv.visitInsn(Opcodes.SWAP); * mv.visitInsn(Opcodes.POP); * mv.visitVarInsn(Opcodes.ILOAD,storage); */ } else { mv.visitInsn(opcode); } break; case Opcodes.FADD: case Opcodes.FSUB: case Opcodes.FMUL: case Opcodes.FDIV: case Opcodes.FREM: if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) { int storage = this.newLocal(Type.FLOAT_TYPE); mv.visitVarInsn(Opcodes.FSTORE, storage); mv.visitInsn(Opcodes.POP); mv.visitVarInsn(Opcodes.FLOAD, storage); } else { mv.visitInsn(opcode); } break; case Opcodes.LADD: case Opcodes.LSUB: case Opcodes.LMUL: case Opcodes.LDIV: case Opcodes.LREM: if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) { int storage = this.newLocal(Type.LONG_TYPE); mv.visitVarInsn(Opcodes.LSTORE, storage); mv.visitInsn(Opcodes.POP2); mv.visitVarInsn(Opcodes.LLOAD, storage); } else { mv.visitInsn(opcode); } break; case Opcodes.DADD: case Opcodes.DSUB: case Opcodes.DMUL: case Opcodes.DDIV: case Opcodes.DREM: if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) { int storage = this.newLocal(Type.DOUBLE_TYPE); mv.visitVarInsn(Opcodes.DSTORE, storage); mv.visitInsn(Opcodes.POP2); mv.visitVarInsn(Opcodes.DLOAD, storage); } else { mv.visitInsn(opcode); } break; default: mv.visitInsn(opcode); break; } }
From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator1.java
License:Apache License
@Override public void visitVarInsn(int opcode, int var) { mv.visitVarInsn(opcode, var); switch (opcode) { case Opcodes.ILOAD: if (this.shouldMutate("Incremented (a++) integer local variable number " + var)) { mv.visitIincInsn(var, 1); }/* w ww .j a v a 2 s. c o m*/ break; case Opcodes.FLOAD: if (this.shouldMutate("Incremented (a++) float local variable number " + var)) { mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FADD); mv.visitVarInsn(Opcodes.FSTORE, var); } break; case Opcodes.LLOAD: if (this.shouldMutate("Incremented (a++) long local variable number " + var)) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LADD); mv.visitVarInsn(Opcodes.LSTORE, var); } break; case Opcodes.DLOAD: if (this.shouldMutate("Incremented (a++) double local variable number " + var)) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(Opcodes.DCONST_1); mv.visitInsn(Opcodes.DADD); mv.visitVarInsn(Opcodes.DSTORE, var); } break; default: break; } }