List of usage examples for org.objectweb.asm Opcodes DCONST_1
int DCONST_1
To view the source code for org.objectweb.asm Opcodes DCONST_1.
Click Source Link
From source file:org.jooby.internal.apitool.BytecodeRouteParser.java
License:Apache License
private Object paramValue(final ClassLoader loader, final ClassNode owner, final MethodNode method, final AbstractInsnNode n) { if (n instanceof LdcInsnNode) { Object cst = ((LdcInsnNode) n).cst; if (cst instanceof Type) { boolean typePresent = new Insn<>(method, n).next().filter(is(MethodInsnNode.class)).findFirst() .map(MethodInsnNode.class::cast).filter(mutantToSomething().or(getOrCreateKotlinClass())) .isPresent();/*from ww w . java 2 s . co m*/ if (typePresent) { return null; } return loadType(loader, ((Type) cst).getClassName()); } return cst; } else if (n instanceof InsnNode) { InsnNode insn = (InsnNode) n; switch (insn.getOpcode()) { case Opcodes.ICONST_0: return 0; case Opcodes.ICONST_1: return 1; case Opcodes.ICONST_2: return 2; case Opcodes.ICONST_3: return 3; case Opcodes.ICONST_4: return 4; case Opcodes.ICONST_5: return 5; case Opcodes.LCONST_0: return 0L; case Opcodes.LCONST_1: return 1L; case Opcodes.FCONST_0: return 0f; case Opcodes.FCONST_1: return 1f; case Opcodes.FCONST_2: return 2f; case Opcodes.DCONST_0: return 0d; case Opcodes.DCONST_1: return 1d; case Opcodes.ICONST_M1: return -1; case Opcodes.ACONST_NULL: return null; } } else if (n instanceof IntInsnNode) { IntInsnNode intinsn = (IntInsnNode) n; return intinsn.operand; } else if (n instanceof FieldInsnNode) { // toEnum FieldInsnNode finsn = (FieldInsnNode) n; if (finsn.getOpcode() == GETSTATIC) { java.lang.reflect.Type possibleEnum = loadType(loader, finsn.owner); if (MoreTypes.getRawType(possibleEnum).isEnum()) { return finsn.name; } } } return n; }
From source file:org.lambdamatic.analyzer.ast.LambdaExpressionReader.java
License:Open Source License
/** * Reads the current {@link InsnNode} instruction and returns a {@link Statement} or {@code null} * if the instruction is not a full statement (in that case, the instruction is stored in the * given Expression {@link Stack}).// w ww . j a va 2s . c om * * @param insnNode the instruction to read * @param expressionStack the expression stack to put on or pop from. * @param localVariables the local variables * @return a {@link List} of {@link Statement} or empty list if no {@link Statement} was created * after reading the current instruction. * @see <a href="https://en.wikipedia.org/wiki/Java_bytecode_instruction_listings">Java bytcode * instruction listings on Wikipedia</a> */ private List<Statement> readInstruction(final InsnCursor insnCursor, final Stack<Expression> expressionStack, final List<CapturedArgument> capturedArguments, final LocalVariables localVariables) { final List<Statement> statements = new ArrayList<>(); final AbstractInsnNode insnNode = insnCursor.getCurrent(); switch (insnNode.getOpcode()) { // return a reference from a method case Opcodes.ARETURN: // return an integer from a method case Opcodes.IRETURN: statements.add(new ReturnStatement(expressionStack.pop())); break; // return void from method case Opcodes.RETURN: // wrap all pending expressions into ExpressionStatements while (!expressionStack.isEmpty()) { final Expression pendingExpression = expressionStack.pop(); statements.add(new ExpressionStatement(pendingExpression)); } break; // push a null reference onto the stack case Opcodes.ACONST_NULL: expressionStack.add(new NullLiteral()); break; // load the int value 0 onto the stack case Opcodes.ICONST_0: // applies for byte, short, int and boolean expressionStack.add(new NumberLiteral(0)); break; // load the int value 1 onto the stack case Opcodes.ICONST_1: // applies for byte, short, int and boolean expressionStack.add(new NumberLiteral(1)); break; // load the int value 2 onto the stack case Opcodes.ICONST_2: expressionStack.add(new NumberLiteral(2)); break; // load the int value 3 onto the stack case Opcodes.ICONST_3: expressionStack.add(new NumberLiteral(3)); break; // load the int value 4 onto the stack case Opcodes.ICONST_4: expressionStack.add(new NumberLiteral(4)); break; // load the int value 5 onto the stack case Opcodes.ICONST_5: expressionStack.add(new NumberLiteral(5)); break; // push the long 0 onto the stack case Opcodes.LCONST_0: expressionStack.add(new NumberLiteral(0L)); break; // push the long 1 onto the stack case Opcodes.LCONST_1: expressionStack.add(new NumberLiteral(1L)); break; // push the 0.0f onto the stack case Opcodes.FCONST_0: expressionStack.add(new NumberLiteral(0f)); break; // push the 1.0f onto the stack case Opcodes.FCONST_1: expressionStack.add(new NumberLiteral(1f)); break; // push the 2.0f onto the stack case Opcodes.FCONST_2: expressionStack.add(new NumberLiteral(2f)); break; // push the constant 0.0 onto the stack case Opcodes.DCONST_0: expressionStack.add(new NumberLiteral(0d)); break; // push the constant 1.0 onto the stack case Opcodes.DCONST_1: expressionStack.add(new NumberLiteral(1d)); break; // compare two longs values case Opcodes.LCMP: // compare two doubles case Opcodes.DCMPL: // compare two doubles case Opcodes.DCMPG: // compare two floats case Opcodes.FCMPL: // compare two floats case Opcodes.FCMPG: statements.addAll( readJumpInstruction(insnCursor.next(), expressionStack, capturedArguments, localVariables)); break; // add 2 ints case Opcodes.IADD: expressionStack.add(readOperation(Operator.ADD, expressionStack)); break; // int subtract case Opcodes.ISUB: expressionStack.add(readOperation(Operator.SUBTRACT, expressionStack)); break; // multiply 2 integers case Opcodes.IMUL: expressionStack.add(readOperation(Operator.MULTIPLY, expressionStack)); break; // divide 2 integers case Opcodes.IDIV: expressionStack.add(readOperation(Operator.DIVIDE, expressionStack)); break; // negate int case Opcodes.INEG: expressionStack.add(inverseInteger(expressionStack)); break; // discard the top value on the stack case Opcodes.POP: statements.add(new ExpressionStatement(expressionStack.pop())); break; // duplicate the value on top of the stack case Opcodes.DUP: expressionStack.push(expressionStack.peek()); break; // insert a copy of the top value into the stack two values from the top. case Opcodes.DUP_X1: expressionStack.add(expressionStack.size() - 2, expressionStack.peek()); break; // store into a reference in an array case Opcodes.AASTORE: readArrayStoreInstruction(insnNode, expressionStack); break; // converts Float to Double -> ignored. case Opcodes.F2D: break; default: throw new AnalyzeException( "Bytecode instruction with OpCode '" + insnNode.getOpcode() + "' is not supported."); } return statements; }
From source file:org.openquark.cal.internal.javamodel.AsmJavaBytecodeGenerator.java
License:Open Source License
/** * Encodes instructions to push a double value onto the operand stack. * @param value to be pushed/* w ww. j av a 2 s . c o m*/ * @param context * @return JavaTypeName the type of the result on the operand stack. */ private static JavaTypeName encodePushDoubleValue(Double value, GenerationContext context) { MethodVisitor mv = context.getMethodVisitor(); double v = value.doubleValue(); if (v == 0.0) { mv.visitInsn(Opcodes.DCONST_0); } else if (v == 1.0) { mv.visitInsn(Opcodes.DCONST_1); } else { // Create a Constant pool entry mv.visitLdcInsn(value); } return JavaTypeName.DOUBLE; }
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); }/*from w ww .j av a 2s.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; } }
From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator1.java
License:Apache License
@Override public void visitInsn(final int opcode) { // I F L D + BS switch (opcode) { case Opcodes.IALOAD: if (this.shouldMutate("Incremented (a++) integer array field")) { mv.visitInsn(Opcodes.DUP2); // Array and its index on stack, times two mv.visitInsn(opcode); // IALOAD mv.visitInsn(Opcodes.DUP_X2); // put the result of array[index] under [array ref] [index] [array[index]] mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD);// w ww . ja v a 2s.c o m mv.visitInsn(Opcodes.IASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.FALOAD: if (this.shouldMutate("Incremented (a++) float array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FADD); mv.visitInsn(Opcodes.FASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.LALOAD: if (this.shouldMutate("Incremented (a++) long array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LADD); mv.visitInsn(Opcodes.LASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.DALOAD: if (this.shouldMutate("Incremented (a++) double array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.DCONST_1); mv.visitInsn(Opcodes.DADD); mv.visitInsn(Opcodes.DASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.BALOAD: if (this.shouldMutate("Incremented (a++) byte array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD); mv.visitInsn(Opcodes.I2B); mv.visitInsn(Opcodes.BASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.SALOAD: if (this.shouldMutate("Incremented (a++) short array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD); mv.visitInsn(Opcodes.I2S); mv.visitInsn(Opcodes.SASTORE); } 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 visitFieldInsn(int opcode, String owner, String name, String desc) { // GETFIELD I,F,L,D + B,S if ((opcode == Opcodes.GETFIELD)) { if (desc.equals("I")) { if (this.shouldMutate("Incremented (a++) integer field " + name)) { // Assuming we have the reference to [this] on the stack mv.visitInsn(Opcodes.DUP); // dup [this] mv.visitFieldInsn(opcode, owner, name, desc); // stack = [this] [this.field] mv.visitInsn(Opcodes.DUP_X1); // stack = [this.field] [this] [this.field] mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD); // stack = [this.field] [this] [this.field +1] mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); return; }//from w w w.j a va 2 s. com } if (desc.equals("F")) { if (this.shouldMutate("Incremented (a++) float field " + name)) { mv.visitInsn(Opcodes.DUP); mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP_X1); mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FADD); mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); return; } } if (desc.equals("J")) { if (this.shouldMutate("Incremented (a++) long field " + name)) { mv.visitInsn(Opcodes.DUP); mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP2_X1); mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LADD); mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); return; } } if (desc.equals("D")) { if (this.shouldMutate("Incremented (a++) double field " + name)) { mv.visitInsn(Opcodes.DUP); mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP2_X1); mv.visitInsn(Opcodes.DCONST_1); mv.visitInsn(Opcodes.DADD); mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); return; } } if (desc.equals("B")) { if (this.shouldMutate("Incremented (a++) byte field " + name)) { mv.visitInsn(Opcodes.DUP); mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP_X1); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD); mv.visitInsn(Opcodes.I2B); mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); return; } } if (desc.equals("S")) { if (this.shouldMutate("Incremented (a++) short field " + name)) { mv.visitInsn(Opcodes.DUP); mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP_X1); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD); mv.visitInsn(Opcodes.I2S); mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); return; } } } // GETSTATIC I,F,L,D + B,S if (opcode == Opcodes.GETSTATIC) { if (desc.equals("I")) { if (this.shouldMutate("Incremented (a++) static integer field " + name)) { mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD); mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); return; } } if (desc.equals("F")) { if (this.shouldMutate("Incremented (a++) static float field " + name)) { mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FADD); mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); return; } } if (desc.equals("J")) { if (this.shouldMutate("Incremented (a++) static long field " + name)) { mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP2); mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LADD); mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); return; } } if (desc.equals("D")) { if (this.shouldMutate("Incremented (a++) static double field " + name)) { mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP2); mv.visitInsn(Opcodes.DCONST_1); mv.visitInsn(Opcodes.DADD); mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); return; } } if (desc.equals("B")) { if (this.shouldMutate("Incremented (a++) static byte field " + name)) { mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD); mv.visitInsn(Opcodes.I2B); mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); return; } } if (desc.equals("S")) { if (this.shouldMutate("Incremented (a++) static short field " + name)) { mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD); mv.visitInsn(Opcodes.I2S); mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); return; } } } mv.visitFieldInsn(opcode, owner, name, desc); }
From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator2.java
License:Apache License
@Override public void visitVarInsn(int opcode, int var) { mv.visitVarInsn(opcode, var); switch (opcode) { case Opcodes.ILOAD: if (this.shouldMutate("Decremented (a--) integer local variable number " + var)) { mv.visitIincInsn(var, -1); }//from ww w . j a v a 2s . com break; case Opcodes.FLOAD: if (this.shouldMutate("Decremented (a--) float local variable number " + var)) { mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FSUB); mv.visitVarInsn(Opcodes.FSTORE, var); } break; case Opcodes.LLOAD: if (this.shouldMutate("Decremented (a--) long local variable number " + var)) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LSUB); mv.visitVarInsn(Opcodes.LSTORE, var); } break; case Opcodes.DLOAD: if (this.shouldMutate("Decremented (a--) double local variable number " + var)) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(Opcodes.DCONST_1); mv.visitInsn(Opcodes.DSUB); mv.visitVarInsn(Opcodes.DSTORE, var); } break; default: break; } }
From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator2.java
License:Apache License
@Override public void visitInsn(final int opcode) { // I F L D + BS switch (opcode) { case Opcodes.IALOAD: if (this.shouldMutate("Decremented (a--) integer array field")) { // stack = [array] [index] , wanted to perform an IALOAD mv.visitInsn(Opcodes.DUP2); // stack = [array] [index] [array] [index] mv.visitInsn(opcode); // stack = [array] [index] [array(index)] mv.visitInsn(Opcodes.DUP_X2); // stack = [array(index)] [array] [index] [array(index)] mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); // stack = [array(index)] [array] [index] [array(index)-1] mv.visitInsn(Opcodes.IASTORE); } else {/* www .ja va 2 s . com*/ mv.visitInsn(opcode); } break; case Opcodes.FALOAD: if (this.shouldMutate("Decremented (a--) float array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FSUB); mv.visitInsn(Opcodes.FASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.LALOAD: if (this.shouldMutate("Decremented (a--) long array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LSUB); mv.visitInsn(Opcodes.LASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.DALOAD: if (this.shouldMutate("Decremented (a--) double array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.DCONST_1); mv.visitInsn(Opcodes.DSUB); mv.visitInsn(Opcodes.DASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.BALOAD: if (this.shouldMutate("Decremented (a--) byte array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); mv.visitInsn(Opcodes.I2B); mv.visitInsn(Opcodes.BASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.SALOAD: if (this.shouldMutate("Decremented (a--) short array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); mv.visitInsn(Opcodes.I2S); mv.visitInsn(Opcodes.SASTORE); } else { mv.visitInsn(opcode); } break; default: mv.visitInsn(opcode); break; } }
From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator2.java
License:Apache License
@Override public void visitFieldInsn(int opcode, String owner, String name, String desc) { // GETFIELD I,F,L,D + B,S if ((opcode == Opcodes.GETFIELD)) { if (desc.equals("I")) { if (this.shouldMutate("Decremented (a--) integer field " + name)) { // stack = [this] mv.visitInsn(Opcodes.DUP); // stack = [this] [this] mv.visitFieldInsn(opcode, owner, name, desc); // stack = [this] [this.field] mv.visitInsn(Opcodes.DUP_X1); // stack = [this.field] [this] [this.field] mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); return; }//from w w w .jav a 2s .com } if (desc.equals("F")) { if (this.shouldMutate("Decremented (a--) float field " + name)) { mv.visitInsn(Opcodes.DUP); mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP_X1); mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FSUB); mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); return; } } if (desc.equals("J")) { if (this.shouldMutate("Decremented (a--) long field " + name)) { mv.visitInsn(Opcodes.DUP); mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP2_X1); mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LSUB); mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); return; } } if (desc.equals("D")) { if (this.shouldMutate("Decremented (a--) double field " + name)) { mv.visitInsn(Opcodes.DUP); mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP2_X1); mv.visitInsn(Opcodes.DCONST_1); mv.visitInsn(Opcodes.DSUB); mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); return; } } if (desc.equals("B")) { if (this.shouldMutate("Decremented (a--) byte field " + name)) { mv.visitInsn(Opcodes.DUP); mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP_X1); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); mv.visitInsn(Opcodes.I2B); mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); return; } } if (desc.equals("S")) { if (this.shouldMutate("Decremented (a--) short field " + name)) { mv.visitInsn(Opcodes.DUP); mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP_X1); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); mv.visitInsn(Opcodes.I2S); mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); return; } } } // GETSTATIC I,F,L,D + B,S if (opcode == Opcodes.GETSTATIC) { if (desc.equals("I")) { if (this.shouldMutate("Decremented (a--) static integer field " + name)) { mv.visitFieldInsn(opcode, owner, name, desc); // stack = [this.sfield] mv.visitInsn(Opcodes.DUP); // stack = [this.sfield] [this.sfield] mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); // stack = [this.sfield] [this.sfield -1] mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); return; } } if (desc.equals("F")) { if (this.shouldMutate("Decremented (a--) static float field " + name)) { mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FSUB); mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); return; } } if (desc.equals("J")) { if (this.shouldMutate("Decremented (a--) static long field " + name)) { mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP2); mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LSUB); mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); return; } } if (desc.equals("D")) { if (this.shouldMutate("Decremented (a--) static double field " + name)) { mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP2); mv.visitInsn(Opcodes.DCONST_1); mv.visitInsn(Opcodes.DSUB); mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); return; } } if (desc.equals("B")) { if (this.shouldMutate("Decremented (a--) static byte field " + name)) { mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); mv.visitInsn(Opcodes.I2B); mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); return; } } if (desc.equals("S")) { if (this.shouldMutate("Decremented (a--) static short field " + name)) { mv.visitFieldInsn(opcode, owner, name, desc); mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); mv.visitInsn(Opcodes.I2S); mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); return; } } } mv.visitFieldInsn(opcode, owner, name, desc); }
From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator3.java
License:Apache License
@Override public void visitVarInsn(int opcode, int var) { switch (opcode) { case Opcodes.ILOAD: if (this.shouldMutate("Incremented (++a) integer local variable number " + var)) { mv.visitIincInsn(var, 1); }//from w ww . j a va 2 s .c o m mv.visitVarInsn(opcode, var); break; case Opcodes.FLOAD: if (this.shouldMutate("Incremented (++a) float local variable number " + var)) { mv.visitVarInsn(opcode, var); mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FADD); mv.visitVarInsn(Opcodes.FSTORE, var); } mv.visitVarInsn(opcode, var); break; case Opcodes.LLOAD: if (this.shouldMutate("Incremented (++a) long local variable number " + var)) { mv.visitVarInsn(opcode, var); mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LADD); mv.visitVarInsn(Opcodes.LSTORE, var); } mv.visitVarInsn(opcode, var); break; case Opcodes.DLOAD: if (this.shouldMutate("Incremented (++a) double local variable number " + var)) { mv.visitVarInsn(opcode, var); mv.visitInsn(Opcodes.DCONST_1); mv.visitInsn(Opcodes.DADD); mv.visitVarInsn(Opcodes.DSTORE, var); } mv.visitVarInsn(opcode, var); break; default: mv.visitVarInsn(opcode, var); break; } }