Skip to content

Commit be0c1bb

Browse files
committed
skip label and line nodes again
1 parent 2cfbd41 commit be0c1bb

File tree

1 file changed

+22
-2
lines changed
  • deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/asm/matcher/group

1 file changed

+22
-2
lines changed

deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/asm/matcher/group/SequenceMatch.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
/**
1515
* Matches instructions in sequence
1616
*/
17-
// TODO: backwards match?
1817
public class SequenceMatch extends Match {
1918

2019
private static final Match FRAME_MATCH = Match.of(context -> context.insn() instanceof FrameNode);
20+
private static final Match LABEL_MATCH = Match.of(context -> context.insn() instanceof LabelNode);
21+
private static final Match LINE_MATCH = Match.of(context -> context.insn() instanceof LineNumberNode);
2122

2223
private final Match[] matches;
23-
private final List<Match> skipMatches = new ArrayList<>(List.of(FRAME_MATCH));
24+
private final List<Match> skipMatches = new ArrayList<>(List.of(FRAME_MATCH, LABEL_MATCH, LINE_MATCH));
2425

2526
private SequenceMatch(Match[] matches) {
2627
this.matches = matches;
@@ -43,8 +44,27 @@ public SequenceMatch doNotSkipFrames() {
4344
return this;
4445
}
4546

47+
public SequenceMatch doNotSkipLabels() {
48+
this.skipMatches.remove(LABEL_MATCH);
49+
return this;
50+
}
51+
52+
public SequenceMatch doNotSkipLineNumbers() {
53+
this.skipMatches.remove(LINE_MATCH);
54+
return this;
55+
}
56+
57+
public SequenceMatch doNotSkip() {
58+
this.skipMatches.clear();
59+
return this;
60+
}
61+
4662
@Override
4763
protected boolean test(MatchContext context) {
64+
if (this.skipMatches.stream().anyMatch(match -> match.matches(context.insnContext()))) {
65+
return false;
66+
}
67+
4868
AbstractInsnNode currentInsn = context.insn();
4969
int matchIdx = 0;
5070

0 commit comments

Comments
 (0)