List of usage examples for org.objectweb.asm.tree InsnList set
public void set(final AbstractInsnNode oldInsnNode, final AbstractInsnNode newInsnNode)
From source file:org.parboiled.transform.process.GroupClassGenerator.java
License:Apache License
protected static void convertXLoads(final InstructionGroup group) { final String owner = group.getGroupClassType().getInternalName(); InsnList insnList; for (final InstructionGraphNode node : group.getNodes()) { if (!node.isXLoad()) continue; final VarInsnNode insn = (VarInsnNode) node.getInstruction(); final FieldNode field = group.getFields().get(insn.var); final FieldInsnNode fieldNode = new FieldInsnNode(GETFIELD, owner, field.name, field.desc); insnList = group.getInstructions(); // insert the correct GETFIELD after the xLoad insnList.insert(insn, fieldNode); // change the load to ALOAD 0 insnList.set(insn, new VarInsnNode(ALOAD, 0)); }/*from w w w . j a va 2 s .co m*/ }
From source file:the.bytecode.club.bytecodeviewer.plugin.preinstalled.AllatoriStringDecrypter.java
License:Open Source License
private boolean scanDecrypter(MethodNode decryptermethodnode, int newHashCode) { InsnList iList = decryptermethodnode.instructions; AbstractInsnNode insn = null, removeInsn = null; for (AbstractInsnNode i : iList.toArray()) { if (i instanceof MethodInsnNode) { MethodInsnNode methodi = ((MethodInsnNode) i); if ("currentThread".equals(methodi.name)) { // find code form this instruction insn = i;//www. j a v a2 s . c o m break; } } } if (insn == null) { return false; } while (insn != null) { if (insn instanceof MethodInsnNode) { MethodInsnNode methodi = ((MethodInsnNode) insn); if ("hashCode".equals(methodi.name)) { // to this instruction break; } } removeInsn = insn; insn = insn.getNext(); iList.remove(removeInsn); // and remove it } if (insn == null) return false; iList.set(insn, new LdcInsnNode(newHashCode)); // then replace it with pre-computed key LDC return true; }