aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-04-13 18:30:35 +0200
committer zaaarf <zaaarf@proton.me>2023-04-13 18:30:35 +0200
commitdd09c4f8e1b7e49482a4366b13ae1f9794d3c221 (patch)
tree59022f3c65d110240c5e7744faa71c05e6f07a0c
parent752c7ae6abc79a511c69fa134b1859a34bcd3c11 (diff)
fix: fixed ignore flags in PatternMatcher
-rw-r--r--src/main/java/ftbsc/lll/tools/PatternMatcher.java17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/main/java/ftbsc/lll/tools/PatternMatcher.java b/src/main/java/ftbsc/lll/tools/PatternMatcher.java
index c2df7d5..c5a53a2 100644
--- a/src/main/java/ftbsc/lll/tools/PatternMatcher.java
+++ b/src/main/java/ftbsc/lll/tools/PatternMatcher.java
@@ -78,24 +78,21 @@ public class PatternMatcher {
*/
public InsnSequence find(AbstractInsnNode node) {
if(node != null) {
- AbstractInsnNode first;
- AbstractInsnNode last;
+ AbstractInsnNode first, last;
for(AbstractInsnNode cur = node; cur != null; cur = reverse ? cur.getPrevious() : cur.getNext()) {
- if(ignoreLabels && cur.getType() == AbstractInsnNode.LABEL) continue;
- if(ignoreFrames && cur.getType() == AbstractInsnNode.FRAME) continue;
- if(ignoreLineNumbers && cur.getType() == AbstractInsnNode.LINE) continue;
- if(predicates.size() == 0)
- return new InsnSequence(cur); //match whatever
+ if(predicates.size() == 0) return new InsnSequence(cur); //match whatever
first = cur;
last = cur;
- for(int match = 0; match < predicates.size(); match++) {
+ for(int match = 0; match < predicates.size(); last = reverse ? last.getPrevious() : last.getNext()) {
+ if(ignoreLabels && cur.getType() == AbstractInsnNode.LABEL) continue;
+ if(ignoreFrames && cur.getType() == AbstractInsnNode.FRAME) continue;
+ if(ignoreLineNumbers && cur.getType() == AbstractInsnNode.LINE) continue;
if(last == null) break;
if(!predicates.get(match).test(last)) break;
if(match == predicates.size() - 1) {
if(reverse) return new InsnSequence(last, first); //we are matching backwards
else return new InsnSequence(first, last);
- }
- last = reverse ? last.getPrevious() : last.getNext();
+ } else match++;
}
}
}