Skip to content

Commit

Permalink
(WIP) reuse method skipNonOpcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Godin committed Nov 27, 2018
1 parent ce2ab85 commit 081c49e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ final void next() {
skipNonOpcodes();
}

private void skipNonOpcodes() {
/**
* Moves {@link #cursor} through {@link AbstractInsnNode#FRAME},
* {@link AbstractInsnNode#LABEL}, {@link AbstractInsnNode#LINE}.
*/
final void skipNonOpcodes() {
while (cursor != null && (cursor.getType() == AbstractInsnNode.FRAME
|| cursor.getType() == AbstractInsnNode.LABEL
|| cursor.getType() == AbstractInsnNode.LINE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;

Expand Down Expand Up @@ -85,24 +84,14 @@ public void match(final MethodNode methodNode,
return;
}
ignore.add(cursor);
cursor = instructionAfterLabel(((JumpInsnNode) cursor).label);
cursor = ((JumpInsnNode) cursor).label;
skipNonOpcodes();
}

for (AbstractInsnNode i : ignore) {
output.ignore(i, i);
}
}

private static AbstractInsnNode instructionAfterLabel(
final LabelNode label) {
AbstractInsnNode i = label.getNext();
while (i.getType() == AbstractInsnNode.FRAME
|| i.getType() == AbstractInsnNode.LABEL
|| i.getType() == AbstractInsnNode.LINE) {
i = i.getNext();
}
return i;
}
}

}

0 comments on commit 081c49e

Please sign in to comment.