List of usage examples for org.objectweb.asm.tree AbstractInsnNode opcode
int opcode
To view the source code for org.objectweb.asm.tree AbstractInsnNode opcode.
Click Source Link
From source file:com.dank.analysis.impl.client.visitor.DestinationVisitor2.java
License:GNU General Public License
private boolean follow(BasicBlock block) { if (block == null) return false; for (AbstractInsnNode ain : block.instructions) { if (ain.opcode() == PUTSTATIC) { FieldInsnNode fin = (FieldInsnNode) ain; if (!fin.desc.equals("I")) continue; if (Hook.CLIENT.get("destinationX") == null) { Hook.CLIENT.put(new RSField(fin, "destinationX")); return follow(block.next); } else if (Hook.CLIENT.get("destinationY") == null) { Hook.CLIENT.put(new RSField(fin, "destinationY")); return true; }/*www. j av a 2s.c om*/ } } return follow(block.next); }
From source file:com.dank.analysis.impl.landscape.DynamicObject.java
License:GNU General Public License
private FieldInsnNode load(final MethodNode mn, final int opcode, final int index, final Hook owner) { for (final AbstractInsnNode ain : mn.instructions.toArray()) { if (ain instanceof VarInsnNode) { final VarInsnNode vin = (VarInsnNode) ain; if (vin.var == index && vin.opcode() == opcode) { AbstractInsnNode dog = vin; for (int i = 0; i < 7; i++) { if (dog == null) break; if (dog.opcode() == Opcodes.PUTFIELD && ((FieldInsnNode) dog).owner.equals(owner.getInternalName())) { return (FieldInsnNode) dog; }/*from w ww . j a va 2 s . com*/ dog = dog.next(); } } } } return null; }
From source file:com.dank.analysis.visitor.DummyParameterVisitor.java
License:GNU General Public License
private int numberFor(AbstractInsnNode ain) { if (ain instanceof IntInsnNode) { return ((IntInsnNode) ain).operand; } else if (ain instanceof LdcInsnNode) { if (((LdcInsnNode) ain).cst instanceof Integer) return (int) ((LdcInsnNode) ain).cst; } else if (ain instanceof InsnNode) { if (ain.opcode() >= ICONST_0 && ain.opcode() <= DCONST_1) { String opname = Assembly.OPCODES[ain.opcode()]; return Integer.parseInt(opname.substring(opname.length() - 1)); } else if (ain.opcode() == NOP) { return 0; } else if (ain.opcode() == ICONST_M1) { return -1; }/*from ww w .j a va2 s . com*/ } return Integer.MAX_VALUE; }
From source file:com.dank.analysis.visitor.DummyParameterVisitor.java
License:GNU General Public License
public void accept(MethodNode mn) { Type[] types = Type.getArgumentTypes(mn.desc); if (types.length != 0) { this.mn = mn; for (final AbstractInsnNode ain0 : mn.instructions.toArray()) { if (ain0.type() != AbstractInsnNode.JUMP_INSN || ain0.next() == null) continue; final JumpInsnNode jn = (JumpInsnNode) ain0; AbstractInsnNode ain = ain0.next(); if (ain != null && (ain.opcode() == RETURN || (ain.opcode() == NEW && ((TypeInsnNode) ain).desc.equals("java/lang/IllegalStateException")))) { boolean flip = false; AbstractInsnNode arg = jn.previous(); if (arg != null) { AbstractInsnNode load = arg.previous(); if (load != null) { int predicate = numberFor(arg); if (predicate == Integer.MAX_VALUE) { predicate = numberFor(load); flip = true; }/*from w w w .j a va 2s .c o m*/ if (predicate != Integer.MAX_VALUE) { predicate = validPredicateFor(jn, predicate, flip); VALUES.put(mn.owner.name + '.' + mn.name + mn.desc, predicate); } } } } } } }
From source file:com.dank.asm.InsnNodeUtils.java
License:Open Source License
/** * Reads the value of a numeric push instruction (which can be an * {@code ICONST_*} instruction, an {@code BIPUSH} instruction, an * {@code SIPUSH} instruction or a {@code LDC_*} instruction. * /*from w w w . j ava 2 s. c o m*/ * @param push * The instruction node. * @return The numeric value. */ public static long getNumericPushValue(AbstractInsnNode push) { if (push instanceof InsnNode) { switch (push.opcode()) { case Opcodes.ICONST_M1: return -1; 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; default: throw new AssertionError(); } } else if (push instanceof IntInsnNode) { return ((IntInsnNode) push).operand; } else { return ((Number) ((LdcInsnNode) push).cst).longValue(); } }
From source file:com.dank.asm.InsnNodeUtils.java
License:Open Source License
/** * Finds the next non-psuedo node following the specified node. * //from www.ja v a 2s . c om * @param node * The node. * @return The next non-psuedo node, or {@code null} if the end of the * instruction list is reached. */ public static AbstractInsnNode nextNonPsuedoNode(AbstractInsnNode node) { while ((node = node.next()) != null && node.opcode() == -1) ; return node; }
From source file:com.dank.asm.InsnNodeUtils.java
License:Open Source License
/** * Finds the previous non-psuedo node following the specified node. * //from ww w .j a va 2s . c om * @param node * The node. * @return The previous non-psuedo node, or {@code null} if the start of the * instruction list is reached. */ public static AbstractInsnNode previousNonPsuedoNode(AbstractInsnNode node) { while ((node = node.previous()) != null && node.opcode() == -1) ; return node; }
From source file:com.dank.asm.InsnNodeUtils.java
License:Open Source License
/** * Finds the next psuedo node following the specified node. * //from www . j a v a2 s . com * @param node * The node. * @return The next psuedo node, or {@code null} if the end of the * instruction list is reached. */ public static AbstractInsnNode nextPsuedoNode(AbstractInsnNode node) { while ((node = node.next()) != null && node.opcode() != -1) ; return node; }
From source file:com.dank.asm.InsnNodeUtils.java
License:Open Source License
/** * Finds the previous psuedo node following the specified node. * /* w ww. j a v a 2 s . c om*/ * @param node * The node. * @return The previous psuedo node, or {@code null} if the start of the * instruction list is reached. */ public static AbstractInsnNode previousPsuedoNode(AbstractInsnNode node) { while ((node = node.previous()) != null && node.opcode() != -1) ; return node; }
From source file:me.themallard.bitmmo.api.analysis.util.pattern.element.FieldElement.java
License:Open Source License
@Override public boolean matches(AbstractInsnNode ain) { if (!(ain instanceof FieldInsnNode)) return false; if (insn.opcode() == ain.opcode() && insn.name == null && insn.owner == null && insn.desc == null) return true; if (insn.opcode() != ain.opcode()) return false; FieldInsnNode fin = (FieldInsnNode) ain; if (insn.name != null && !fin.name.equals(insn.name)) return false; if (insn.owner != null && !fin.name.equals(insn.owner)) return false; if (insn.desc != null && !fin.name.equals(insn.desc)) return false; return true;//from www.j av a2s . c om }