File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/asm/matcher/group Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 1414/**
1515 * Matches instructions in sequence
1616 */
17- // TODO: backwards match?
1817public 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
You can’t perform that action at this time.
0 commit comments