List of usage examples for org.objectweb.asm Opcodes IFLE
int IFLE
To view the source code for org.objectweb.asm Opcodes IFLE.
Click Source Link
From source file:org.evosuite.instrumentation.mutation.TestComparisonOperator.java
License:Open Source License
@Test public void testComparisonZeroNE() { // x != 0 vs x == 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFNE, Opcodes.IFEQ), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFNE, Opcodes.IFEQ), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFNE, Opcodes.IFEQ), 0.0); // x != 0 vs x < 0 assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFNE, Opcodes.IFLT), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFNE, Opcodes.IFLT), 0.0); assertEquals(2.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFNE, Opcodes.IFLT), 0.0); // x != 0 vs x <= 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFNE, Opcodes.IFLE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFNE, Opcodes.IFLE), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFNE, Opcodes.IFLE), 0.0); // x != 0 vs x > 0 assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFNE, Opcodes.IFGT), 0.0); assertEquals(2.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFNE, Opcodes.IFGT), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFNE, Opcodes.IFGT), 0.0); // x != 0 vs x >= 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFNE, Opcodes.IFGE), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFNE, Opcodes.IFGE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFNE, Opcodes.IFGE), 0.0); }
From source file:org.evosuite.instrumentation.mutation.TestComparisonOperator.java
License:Open Source License
@Test public void testComparisonZeroLT() { // x < 0 vs x == 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLT, Opcodes.IFEQ), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLT, Opcodes.IFEQ), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLT, Opcodes.IFEQ), 0.0); // x < 0 vs x != 0 assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLT, Opcodes.IFNE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLT, Opcodes.IFNE), 0.0); assertEquals(2.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLT, Opcodes.IFNE), 0.0); // x < 0 vs x <= 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLT, Opcodes.IFLE), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLT, Opcodes.IFLE), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLT, Opcodes.IFLE), 0.0); // x < 0 vs x > 0 assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLT, Opcodes.IFGT), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLT, Opcodes.IFGT), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLT, Opcodes.IFGT), 0.0); // x < 0 vs x >= 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLT, Opcodes.IFGE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLT, Opcodes.IFGE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLT, Opcodes.IFGE), 0.0); }
From source file:org.evosuite.instrumentation.mutation.TestComparisonOperator.java
License:Open Source License
@Test public void testComparisonZeroLE() { // x <= 0 vs x == 0 assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLE, Opcodes.IFEQ), 0.0); assertEquals(2.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLE, Opcodes.IFEQ), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLE, Opcodes.IFEQ), 0.0); // x <= 0 vs x != 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLE, Opcodes.IFNE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLE, Opcodes.IFNE), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLE, Opcodes.IFNE), 0.0); // x <= 0 vs x < 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLE, Opcodes.IFLT), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLE, Opcodes.IFLT), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLE, Opcodes.IFLT), 0.0); // x <= 0 vs x > 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLE, Opcodes.IFGT), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLE, Opcodes.IFGT), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLE, Opcodes.IFGT), 0.0); // x <= 0 vs x >= 0 assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLE, Opcodes.IFGE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLE, Opcodes.IFGE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLE, Opcodes.IFGE), 0.0); }
From source file:org.evosuite.instrumentation.mutation.TestComparisonOperator.java
License:Open Source License
@Test public void testComparisonZeroGT() { // x > 0 vs x == 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGT, Opcodes.IFEQ), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGT, Opcodes.IFEQ), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGT, Opcodes.IFEQ), 0.0); // x > 0 vs x != 0 assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGT, Opcodes.IFNE), 0.0); assertEquals(2.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGT, Opcodes.IFNE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGT, Opcodes.IFNE), 0.0); // x > 0 vs x <= 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGT, Opcodes.IFLE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGT, Opcodes.IFLE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGT, Opcodes.IFLE), 0.0); // x > 0 vs x < 0 assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGT, Opcodes.IFLT), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGT, Opcodes.IFLT), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGT, Opcodes.IFLT), 0.0); // x > 0 vs x >= 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGT, Opcodes.IFGE), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGT, Opcodes.IFGE), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGT, Opcodes.IFGE), 0.0); }
From source file:org.evosuite.instrumentation.mutation.TestComparisonOperator.java
License:Open Source License
@Test public void testComparisonZeroGE() { // x >= 0 vs x == 0 assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGE, Opcodes.IFEQ), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGE, Opcodes.IFEQ), 0.0); assertEquals(2.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGE, Opcodes.IFEQ), 0.0); // x >= 0 vs x != 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGE, Opcodes.IFNE), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGE, Opcodes.IFNE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGE, Opcodes.IFNE), 0.0); // x >= 0 vs x <= 0 assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGE, Opcodes.IFLE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGE, Opcodes.IFLE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGE, Opcodes.IFLE), 0.0); // x >= 0 vs x < 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGE, Opcodes.IFLT), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGE, Opcodes.IFLT), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGE, Opcodes.IFLT), 0.0); // x >= 0 vs x > 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGE, Opcodes.IFGT), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGE, Opcodes.IFGT), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGE, Opcodes.IFGT), 0.0); }
From source file:org.evosuite.instrumentation.StringTransformation.java
License:Open Source License
/** * <p>//from w w w.ja v a 2 s .co m * transformMethod * </p> * * @param mn * a {@link org.objectweb.asm.tree.MethodNode} object. * @return a boolean. */ public boolean transformMethod(MethodNode mn) { boolean changed = transformStrings(mn); if (changed) { try { mn.maxStack++; Analyzer a = new Analyzer(new StringBooleanInterpreter()); a.analyze(cn.name, mn); Frame[] frames = a.getFrames(); AbstractInsnNode node = mn.instructions.getFirst(); boolean done = false; while (!done) { if (node == mn.instructions.getLast()) done = true; AbstractInsnNode next = node.getNext(); int index = mn.instructions.indexOf(node); if (index >= frames.length) break; Frame current = frames[index]; if (current == null) break; int size = current.getStackSize(); if (node.getOpcode() == Opcodes.IFNE) { JumpInsnNode branch = (JumpInsnNode) node; if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious())) { logger.info("IFNE -> IFGT"); branch.setOpcode(Opcodes.IFGT); // branch.setOpcode(Opcodes.IFGE); } } else if (node.getOpcode() == Opcodes.IFEQ) { JumpInsnNode branch = (JumpInsnNode) node; if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious())) { logger.info("IFEQ -> IFLE"); branch.setOpcode(Opcodes.IFLE); // branch.setOpcode(Opcodes.IFNE); } } else if (node.getOpcode() == Opcodes.IF_ICMPEQ) { JumpInsnNode branch = (JumpInsnNode) node; if (current.getStack(size - 2) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious().getPrevious())) { if (node.getPrevious().getOpcode() == Opcodes.ICONST_0) { branch.setOpcode(Opcodes.IFLE); mn.instructions.remove(node.getPrevious()); } else if (node.getPrevious().getOpcode() == Opcodes.ICONST_1) { branch.setOpcode(Opcodes.IFGT); mn.instructions.remove(node.getPrevious()); } } } else if (node.getOpcode() == Opcodes.IF_ICMPNE) { JumpInsnNode branch = (JumpInsnNode) node; if (current.getStack(size - 2) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious().getPrevious())) { if (node.getPrevious().getOpcode() == Opcodes.ICONST_0) { branch.setOpcode(Opcodes.IFGT); mn.instructions.remove(node.getPrevious()); } else if (node.getPrevious().getOpcode() == Opcodes.ICONST_1) { branch.setOpcode(Opcodes.IFLE); mn.instructions.remove(node.getPrevious()); } } } else if (node.getOpcode() == Opcodes.IRETURN) { if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious())) { logger.info("IFEQ -> IFLE"); MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "intToBoolean", Type.getMethodDescriptor(Type.BOOLEAN_TYPE, new Type[] { Type.INT_TYPE })); mn.instructions.insertBefore(node, n); } } node = next; } } catch (Exception e) { logger.warn("EXCEPTION DURING STRING TRANSFORMATION: {}", e); e.printStackTrace(); return changed; } } return changed; }
From source file:org.evosuite.instrumentation.testability.StringTransformation.java
License:Open Source License
/** * <p>//from w w w . j ava 2 s . c o m * transformMethod * </p> * * @param mn * a {@link org.objectweb.asm.tree.MethodNode} object. * @return a boolean. */ public boolean transformMethod(MethodNode mn) { boolean changed = transformStrings(mn); if (changed) { try { mn.maxStack++; Analyzer a = new Analyzer(new StringBooleanInterpreter()); a.analyze(cn.name, mn); Frame[] frames = a.getFrames(); AbstractInsnNode node = mn.instructions.getFirst(); boolean done = false; while (!done) { if (node == mn.instructions.getLast()) done = true; AbstractInsnNode next = node.getNext(); int index = mn.instructions.indexOf(node); if (index >= frames.length) break; Frame current = frames[index]; if (current == null) break; int size = current.getStackSize(); if (node.getOpcode() == Opcodes.IFNE) { JumpInsnNode branch = (JumpInsnNode) node; if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious())) { logger.info("IFNE -> IFGT"); branch.setOpcode(Opcodes.IFGT); } } else if (node.getOpcode() == Opcodes.IFEQ) { JumpInsnNode branch = (JumpInsnNode) node; if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious())) { logger.info("IFEQ -> IFLE"); branch.setOpcode(Opcodes.IFLE); } } else if (node.getOpcode() == Opcodes.IF_ICMPEQ) { JumpInsnNode branch = (JumpInsnNode) node; if (current.getStack(size - 2) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious().getPrevious())) { if (node.getPrevious().getOpcode() == Opcodes.ICONST_0) { branch.setOpcode(Opcodes.IFLE); mn.instructions.remove(node.getPrevious()); } else if (node.getPrevious().getOpcode() == Opcodes.ICONST_1) { branch.setOpcode(Opcodes.IFGT); mn.instructions.remove(node.getPrevious()); } } } else if (node.getOpcode() == Opcodes.IF_ICMPNE) { JumpInsnNode branch = (JumpInsnNode) node; if (current.getStack(size - 2) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious().getPrevious())) { if (node.getPrevious().getOpcode() == Opcodes.ICONST_0) { branch.setOpcode(Opcodes.IFGT); mn.instructions.remove(node.getPrevious()); } else if (node.getPrevious().getOpcode() == Opcodes.ICONST_1) { branch.setOpcode(Opcodes.IFLE); mn.instructions.remove(node.getPrevious()); } } } else if (node.getOpcode() == Opcodes.IRETURN) { if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious())) { logger.info("IFEQ -> IFLE"); MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "intToBoolean", Type.getMethodDescriptor(Type.BOOLEAN_TYPE, new Type[] { Type.INT_TYPE }), false); mn.instructions.insertBefore(node, n); } } node = next; } } catch (Exception e) { logger.warn("EXCEPTION DURING STRING TRANSFORMATION: " + e); return changed; } } return changed; }
From source file:org.evosuite.instrumentation.testability.transformer.BooleanDistanceTransformer.java
License:Open Source License
@Override protected AbstractInsnNode transformJumpInsnNode(MethodNode mn, JumpInsnNode jumpNode) { switch (jumpNode.getOpcode()) { case Opcodes.IFEQ: case Opcodes.IFNE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFLE: TransformationStatistics.insertPush(jumpNode.getOpcode()); this.booleanTestabilityTransformation.insertPush(jumpNode.getOpcode(), jumpNode, mn.instructions); break;// w w w. j a v a 2s. co m case Opcodes.IF_ICMPEQ: case Opcodes.IF_ICMPNE: case Opcodes.IF_ICMPLT: case Opcodes.IF_ICMPGE: case Opcodes.IF_ICMPGT: case Opcodes.IF_ICMPLE: TransformationStatistics.insertPush(jumpNode.getOpcode()); this.booleanTestabilityTransformation.insertPush2(jumpNode.getOpcode(), jumpNode, mn.instructions); break; case Opcodes.IFNULL: case Opcodes.IFNONNULL: TransformationStatistics.insertPush(jumpNode.getOpcode()); this.booleanTestabilityTransformation.insertPushNull(jumpNode.getOpcode(), jumpNode, mn.instructions); break; case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: TransformationStatistics.insertPush(jumpNode.getOpcode()); this.booleanTestabilityTransformation.insertPushEquals(jumpNode.getOpcode(), jumpNode, mn.instructions); break; default: // GOTO, JSR: Do nothing } return jumpNode; }
From source file:org.evosuite.instrumentation.testability.transformer.BooleanIfTransformer.java
License:Open Source License
@Override protected AbstractInsnNode transformJumpInsnNode(MethodNode mn, JumpInsnNode jumpNode) { if (jumpNode.getOpcode() == Opcodes.IFNE) { if (this.booleanTestabilityTransformation.isBooleanOnStack(mn, jumpNode, 0)) { TransformationStatistics.transformedBooleanComparison(); BooleanTestabilityTransformation.logger.info("Changing IFNE"); jumpNode.setOpcode(Opcodes.IFGT); } else {//from www. j av a 2 s . c om BooleanTestabilityTransformation.logger.info("Not changing IFNE"); int insnPosition = mn.instructions.indexOf(jumpNode); Frame frame = this.booleanTestabilityTransformation.currentFrames[insnPosition]; AbstractInsnNode insn = mn.instructions.get(insnPosition - 1); BooleanTestabilityTransformation.logger.info("Current node: " + mn.instructions.get(insnPosition)); BooleanTestabilityTransformation.logger.info("Previous node: " + insn); if (insn instanceof MethodInsnNode) { MethodInsnNode mi = (MethodInsnNode) insn; if (Type.getReturnType(DescriptorMapping.getInstance().getMethodDesc(mi.owner, mi.name, mi.desc)) == Type.BOOLEAN_TYPE) { BooleanTestabilityTransformation.logger.info("Changing IFNE"); jumpNode.setOpcode(Opcodes.IFGT); } BooleanTestabilityTransformation.logger.info("Method: " + mi.name); } BooleanTestabilityTransformation.logger.info("Stack size: " + frame.getStackSize()); //logger.info("Top of stack: " + frame.getStack(0)); for (int i = 0; i < frame.getStackSize(); i++) { BooleanTestabilityTransformation.logger.info(i + " Stack: " + frame.getStack(i)); } } } else if (jumpNode.getOpcode() == Opcodes.IFEQ) { if (this.booleanTestabilityTransformation.isBooleanOnStack(mn, jumpNode, 0)) { TransformationStatistics.transformedBooleanComparison(); BooleanTestabilityTransformation.logger.info("Changing IFEQ"); jumpNode.setOpcode(Opcodes.IFLE); } else { BooleanTestabilityTransformation.logger.info("Not changing IFEQ"); int insnPosition = mn.instructions.indexOf(jumpNode); Frame frame = this.booleanTestabilityTransformation.currentFrames[insnPosition]; AbstractInsnNode insn = mn.instructions.get(insnPosition - 1); BooleanTestabilityTransformation.logger.info("Previous node: " + insn); if (insn instanceof MethodInsnNode) { MethodInsnNode mi = (MethodInsnNode) insn; BooleanTestabilityTransformation.logger.info("Method: " + mi.name); if (Type.getReturnType(BooleanTestabilityTransformation.getOriginalDesc(mi.owner, mi.name, mi.desc)) == Type.BOOLEAN_TYPE) { BooleanTestabilityTransformation.logger.info("Changing IFEQ"); jumpNode.setOpcode(Opcodes.IFLE); } else { BooleanTestabilityTransformation.logger.info("Return type: " + Type.getReturnType( BooleanTestabilityTransformation.getOriginalDesc(mi.owner, mi.name, mi.desc))); } } BooleanTestabilityTransformation.logger.info("Stack size: " + frame.getStackSize()); for (int i = 0; i < frame.getStackSize(); i++) { BooleanTestabilityTransformation.logger.info(i + " Stack: " + frame.getStack(i)); } } } else if (jumpNode.getOpcode() == Opcodes.IF_ICMPEQ) { if (this.booleanTestabilityTransformation.isBooleanOnStack(mn, jumpNode, 0)) { InsnList convert = new InsnList(); convert.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushParameter", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE }))); convert.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushParameter", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE }))); convert.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "popParameterBooleanFromInt", Type.getMethodDescriptor(Type.BOOLEAN_TYPE, new Type[] {}))); convert.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "popParameterBooleanFromInt", Type.getMethodDescriptor(Type.BOOLEAN_TYPE, new Type[] {}))); mn.instructions.insertBefore(jumpNode, convert); TransformationStatistics.transformedBooleanComparison(); } } else if (jumpNode.getOpcode() == Opcodes.IF_ICMPNE) { if (this.booleanTestabilityTransformation.isBooleanOnStack(mn, jumpNode, 0)) { InsnList convert = new InsnList(); convert.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushParameter", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE }))); convert.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushParameter", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE }))); convert.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "popParameterBooleanFromInt", Type.getMethodDescriptor(Type.BOOLEAN_TYPE, new Type[] {}))); convert.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "popParameterBooleanFromInt", Type.getMethodDescriptor(Type.BOOLEAN_TYPE, new Type[] {}))); mn.instructions.insertBefore(jumpNode, convert); TransformationStatistics.transformedBooleanComparison(); } } return jumpNode; }
From source file:org.evosuite.instrumentation.TransformationStatistics.java
License:Open Source License
/** * Insertion of pushDistance/*from w w w.jav a 2s. c o m*/ * * @param opcode a int. */ public static void insertPush(int opcode) { switch (opcode) { case Opcodes.IFEQ: case Opcodes.IFNE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFLE: insertedPushInt0++; break; case Opcodes.IF_ICMPEQ: case Opcodes.IF_ICMPNE: case Opcodes.IF_ICMPLT: case Opcodes.IF_ICMPGE: case Opcodes.IF_ICMPGT: case Opcodes.IF_ICMPLE: insertedPushInt1++; break; case Opcodes.IFNULL: case Opcodes.IFNONNULL: insertedPushIntRef++; break; case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: insertedPushIntNull++; break; default: // GOTO, JSR: Do nothing } }