Skip to content

Commit

Permalink
Merge pull request #812 from Jydett/feature/allow_search_switch_labels
Browse files Browse the repository at this point in the history
feat: detect lookup switch labels in search results
  • Loading branch information
Col-E committed Jun 25, 2024
2 parents 0ad791c + 2e7db3c commit 2db9169
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,26 @@ public void visitLdcInsn(Object value) {
resultSink.accept(memberPath.childInsn(new LdcInsnNode(value), index), value);
}

@Override
public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
super.visitLookupSwitchInsn(dflt, keys, labels);
for (int key : keys) {
if (isMatch(key)) {
resultSink.accept(memberPath.childInsn(new InsnNode(Opcodes.LOOKUPSWITCH), index), key);
}
}
}

@Override
public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) {
super.visitTableSwitchInsn(min, max, dflt, labels);
for (int i = min; i <= max; i++) {
if (isMatch(i)) {
resultSink.accept(memberPath.childInsn(new InsnNode(Opcodes.TABLESWITCH), index), i);
}
}
}

@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
AnnotationVisitor av = super.visitAnnotation(desc, visible);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ else if (wrapped instanceof AllocateInstruction allocateWrapped)
printer.execute(constWrapped);
else if (wrapped instanceof PrimitiveConversionInstruction convWrapped)
printer.execute(convWrapped);
else if (wrapped instanceof SimpleInstruction simpleWrapped)
printer.execute(simpleWrapped);
else
printer.execute(wrapped);
} else if (insn instanceof InvokeDynamicInsnNode indy) {
Expand Down

0 comments on commit 2db9169

Please sign in to comment.