From dd09c4f8e1b7e49482a4366b13ae1f9794d3c221 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Thu, 13 Apr 2023 18:30:35 +0200 Subject: fix: fixed ignore flags in PatternMatcher --- src/main/java/ftbsc/lll/tools/PatternMatcher.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src') 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++; } } } -- cgit v1.2.3-56-ga3b1