Add InsnNodeUtils

This commit introduces four methods: two for finding the next/previous
AbstractInsnNode that contains a real JVM opcode and two for finding the
next/previous AbstractInsnNode that is virtual (e.g. a label).
bzip2
Graham 5 years ago
parent a91bf3562b
commit c6921fba9d
  1. 29
      asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.java

@ -0,0 +1,29 @@
package dev.openrs2.asm;
import org.objectweb.asm.tree.AbstractInsnNode;
public final class InsnNodeUtils {
public static AbstractInsnNode nextReal(AbstractInsnNode insn) {
while ((insn = insn.getNext()) != null && insn.getOpcode() == -1);
return insn;
}
public static AbstractInsnNode previousReal(AbstractInsnNode insn) {
while ((insn = insn.getPrevious()) != null && insn.getOpcode() == -1);
return insn;
}
public static AbstractInsnNode nextVirtual(AbstractInsnNode insn) {
while ((insn = insn.getNext()) != null && insn.getOpcode() != -1);
return insn;
}
public static AbstractInsnNode previousVirtual(AbstractInsnNode insn) {
while ((insn = insn.getPrevious()) != null && insn.getOpcode() != -1);
return insn;
}
private InsnNodeUtils() {
/* empty */
}
}
Loading…
Cancel
Save