summaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/lll/tools/PatternMatcher.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/ftbsc/lll/tools/PatternMatcher.java')
-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++;
}
}
}