public void makeVarLoad(LocalVariable variable) { code.add(new VarInsnNode(ALOAD, variable.index)); }
public void makeVarStore(LocalVariable variable) { code.add(new VarInsnNode(ASTORE, variable.index)); }
@Test public void shouldCaptureIStoreVariable() { final Slot<Integer> slot = Slot.create(Integer.class); final VarInsnNode node = new VarInsnNode(Opcodes.ISTORE, 3); assertTrue(anIStore(slot.write()).test(this.context,node)); assertThat(this.context.retrieve(slot.read())).isEqualTo(Optional.ofNullable(3)); }
@Test public void shouldMatchAgainstCapturedILoadVariable() { final Slot<Integer> slot = Slot.create(Integer.class); this.context.store(slot.write(), 3); final VarInsnNode matchingNode = new VarInsnNode(Opcodes.ILOAD, 3); assertTrue(anILoadOf(slot.read()).test(this.context,matchingNode)); final VarInsnNode nonMatchingNode = new VarInsnNode(Opcodes.ILOAD, 4); assertFalse(anILoadOf(slot.read()).test(this.context,nonMatchingNode)); }
@Override public void visitVarInsn(int opcode, int var) { node = new VarInsnNode(opcode, var); super.visitVarInsn(opcode, var); }
@Test public void shouldMatchAgainstCapturedIStoreVariable() { final Slot<Integer> slot = Slot.create(Integer.class); this.context.store(slot.write(), 3); final VarInsnNode matchingNode = new VarInsnNode(Opcodes.ISTORE, 3); assertTrue(anIStoreTo(slot.read()).test(this.context,matchingNode)); final VarInsnNode nonMatchingNode = new VarInsnNode(Opcodes.ISTORE, 4); assertFalse(anIStoreTo(slot.read()).test(this.context,nonMatchingNode)); }
@Override public void visitVarInsn(int opcode, int var) { node = new VarInsnNode(opcode, var); super.visitVarInsn(opcode, var); }
@Override public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) { return new VarInsnNode(opcode, var).cloneAnnotations(this); } }
@Override public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) { return new VarInsnNode(opcode, var).cloneAnnotations(this); } }
@Override public void visitVarInsn(int arg0, int arg1) { super.visitVarInsn(arg0, arg1); appendToBacklog(new VarInsnNode(arg0, arg1)); } }
private void load(int load, int i, Object... comments) { maxv = Math.max(maxv, i+1); // TODO: better than this stack++; addInstruction(new VarInsnNode(load, i), comments); }
private void addCallingObjectInstrumentation(boolean staticContext, InsnList instrumentation) { // the object on which the DU is covered is passed by the // instrumentation. // If we are in a static context, null is passed instead if (staticContext) { instrumentation.add(new InsnNode(Opcodes.ACONST_NULL)); } else { instrumentation.add(new VarInsnNode(Opcodes.ALOAD, 0)); // "this" } }
public static InsnList createArgumentLoaders(String methodDescriptor) { checkArgNotNull(methodDescriptor, "methodDescriptor"); InsnList instructions = new InsnList(); Type[] types = Type.getArgumentTypes(methodDescriptor); for (int i = 0; i < types.length; i++) { instructions.add(new VarInsnNode(getLoadingOpcode(types[i]), i + 1)); } return instructions; }
protected void convertXLoads(InstructionGroup group) { String owner = group.getGroupClassType().getInternalName(); for (InstructionGraphNode node : group.getNodes()) { if (!node.isXLoad()) continue; VarInsnNode insn = (VarInsnNode) node.getInstruction(); FieldNode field = group.getFields().get(insn.var); // insert the correct GETFIELD after the xLoad group.getInstructions().insert(insn, new FieldInsnNode(GETFIELD, owner, field.name, field.desc)); // change the load to ALOAD 0 group.getInstructions().set(insn, new VarInsnNode(ALOAD, 0)); } }
private void initializeFields() { String internalName = group.getGroupClassType().getInternalName(); for (FieldNode field : group.getFields()) { insert(new InsnNode(DUP)); // the FieldNodes access and value members have been reused for the var index / Type respectively! insert(new VarInsnNode(getLoadingOpcode((Type) field.value), field.access)); insert(new FieldInsnNode(PUTFIELD, internalName, field.name, field.desc)); } }
@Override public void visit(TabSet node) { ResumptionPoint rp = newResumptionPoint(); il.add(rp.save()); il.add(loadExecutionContext()); il.add(new VarInsnNode(ALOAD, slot(node.obj()))); il.add(new VarInsnNode(ALOAD, slot(node.key()))); il.add(new VarInsnNode(ALOAD, slot(node.value()))); il.add(DispatchMethods.setindex()); il.add(rp.resume()); }
private InsnList getVoidReturnTraceInsts() { val insnList = new InsnList(); insnList.add(new VarInsnNode(ALOAD, catVarIndex)); insnList.add(new MethodInsnNode(INVOKEVIRTUAL, p(Blackcat.class), "finish", sig(void.class), false)); return insnList; }
@Override public void visit(TabGet node) { ResumptionPoint rp = newResumptionPoint(); il.add(rp.save()); il.add(loadExecutionContext()); il.add(new VarInsnNode(ALOAD, slot(node.obj()))); il.add(new VarInsnNode(ALOAD, slot(node.key()))); il.add(DispatchMethods.index()); il.add(rp.resume()); il.add(retrieve_0()); il.add(new VarInsnNode(ASTORE, slot(node.dest()))); }
public void process(ParserClassNode classNode, RuleMethod method) throws Exception { checkArgNotNull(classNode, "classNode"); checkArgNotNull(method, "method"); // replace all method code with a simple call to the super method method.instructions.clear(); method.instructions.add(new VarInsnNode(ALOAD, 0)); method.instructions.add(createArgumentLoaders(method.desc)); method.instructions.add(new MethodInsnNode(INVOKESPECIAL, classNode.getParentType().getInternalName(), method.name, method.desc, classNode.isInterface())); method.instructions.add(new InsnNode(ARETURN)); }
@Override public void visit(Call node) { ResumptionPoint rp = newResumptionPoint(); il.add(rp.save()); il.add(loadExecutionContext()); il.add(new VarInsnNode(ALOAD, slot(node.fn()))); // call target int kind = loadVList(node.args(), DispatchMethods.MAX_CALL_KIND); // call args il.add(DispatchMethods.call(kind)); il.add(rp.resume()); }