forked from openrs2/openrs2
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).master
parent
a91bf3562b
commit
c6921fba9d
@ -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…
Reference in new issue