use of org.objectweb.asm.tree.JumpInsnNode in project jphp by jphp-compiler.
the class WhileCompiler method write.
@Override
public void write(WhileStmtToken token) {
expr.writeDefineVariables(token.getLocal());
LabelNode start = expr.writeLabel(node, token.getMeta().getStartLine());
LabelNode end = new LabelNode();
expr.writeConditional(token.getCondition(), end);
method.pushJump(end, start);
expr.write(BodyStmtToken.class, token.getBody());
method.popJump();
add(new JumpInsnNode(GOTO, start));
add(end);
add(new LineNumberNode(token.getMeta().getEndLine(), end));
expr.writeUndefineVariables(token.getLocal());
}
use of org.objectweb.asm.tree.JumpInsnNode in project evosuite by EvoSuite.
the class BooleanTestabilityTransformation method insertPushNull.
/**
* Insert a call to the isNull helper function
*
* @param opcode
* @param position
* @param list
*/
public void insertPushNull(int opcode, JumpInsnNode position, InsnList list) {
int branchId = getBranchID(currentMethodNode, position);
logger.info("Inserting instrumentation for NULL check at branch " + branchId + " in method " + currentMethodNode.name);
MethodInsnNode nullCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "isNull", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(Object.class), Type.INT_TYPE }), false);
list.insertBefore(position, new InsnNode(Opcodes.DUP));
list.insertBefore(position, new LdcInsnNode(opcode));
list.insertBefore(position, nullCheck);
// list.insertBefore(position,
// new LdcInsnNode(getBranchID(currentMethodNode, position)));
insertBranchIdPlaceholder(currentMethodNode, position, branchId);
MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushPredicate", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE }), false);
list.insertBefore(position, push);
}
use of org.objectweb.asm.tree.JumpInsnNode in project evosuite by EvoSuite.
the class BooleanTestabilityTransformation method insertPush2.
/**
* Insert a call to the distance function for binary comparison
*
* @param opcode
* @param position
* @param list
*/
public void insertPush2(int opcode, JumpInsnNode position, InsnList list) {
list.insertBefore(position, new InsnNode(Opcodes.DUP2));
// list.insertBefore(position, new InsnNode(Opcodes.ISUB));
MethodInsnNode sub = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "intSub", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE }), false);
list.insertBefore(position, sub);
insertBranchIdPlaceholder(currentMethodNode, position);
// list.insertBefore(position,
// new LdcInsnNode(getBranchID(currentMethodNode, position)));
MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushPredicate", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE }), false);
list.insertBefore(position, push);
}
use of org.objectweb.asm.tree.JumpInsnNode in project evosuite by EvoSuite.
the class BranchInstrumentation method addDefaultCaseInstrumentation.
/**
* <p>
* addDefaultCaseInstrumentation
* </p>
*
* @param v
* a {@link org.evosuite.graphs.cfg.BytecodeInstruction} object.
* @param instrumentation
* a {@link org.objectweb.asm.tree.InsnList} object.
* @param mySwitch
* a {@link org.objectweb.asm.tree.AbstractInsnNode} object.
* @param defaultLabel
* a {@link org.objectweb.asm.tree.LabelNode} object.
* @param caseLabel
* a {@link org.objectweb.asm.tree.LabelNode} object.
* @param endLabel
* a {@link org.objectweb.asm.tree.LabelNode} object.
*/
protected void addDefaultCaseInstrumentation(BytecodeInstruction v, InsnList instrumentation, AbstractInsnNode mySwitch, LabelNode defaultLabel, LabelNode caseLabel, LabelNode endLabel) {
int defaultCaseBranchId = BranchPool.getInstance(classLoader).getDefaultBranchForSwitch(v).getActualBranchId();
// add helper switch
instrumentation.add(new InsnNode(Opcodes.DUP));
instrumentation.add(mySwitch);
// add call for default case not covered
instrumentation.add(caseLabel);
addDefaultCaseNotCoveredCall(v, instrumentation, defaultCaseBranchId);
// jump over default (break)
instrumentation.add(new JumpInsnNode(Opcodes.GOTO, endLabel));
// add call for default case covered
instrumentation.add(defaultLabel);
addDefaultCaseCoveredCall(v, instrumentation, defaultCaseBranchId);
instrumentation.add(endLabel);
}
use of org.objectweb.asm.tree.JumpInsnNode in project evosuite by EvoSuite.
the class NegateCondition method apply.
/* (non-Javadoc)
* @see org.evosuite.cfg.instrumentation.MutationOperator#apply(org.objectweb.asm.tree.MethodNode, java.lang.String, java.lang.String, org.evosuite.cfg.BytecodeInstruction)
*/
/**
* {@inheritDoc}
*/
@Override
public List<Mutation> apply(MethodNode mn, String className, String methodName, BytecodeInstruction instruction, Frame frame) {
List<Mutation> mutations = new LinkedList<Mutation>();
JumpInsnNode node = (JumpInsnNode) instruction.getASMNode();
LabelNode target = node.label;
// insert mutation into bytecode with conditional
JumpInsnNode mutation = new JumpInsnNode(getOpposite(node.getOpcode()), target);
// insert mutation into pool
Mutation mutationObject = MutationPool.addMutation(className, methodName, NAME, instruction, mutation, Mutation.getDefaultInfectionDistance());
mutations.add(mutationObject);
return mutations;
}
Aggregations