mirror of
https://github.com/zaaarf/lillero.git
synced 2024-11-21 23:14:51 +01:00
fix: fixed several bugs in find function
This commit is contained in:
parent
118fae8fe7
commit
3185d840c4
1 changed files with 15 additions and 8 deletions
|
@ -85,17 +85,24 @@ public class PatternMatcher {
|
|||
if(ignoreLabels && cur.getType() == AbstractInsnNode.LABEL) continue;
|
||||
if(ignoreFrames && cur.getType() == AbstractInsnNode.FRAME) continue;
|
||||
if(ignoreLineNumbers && cur.getType() == AbstractInsnNode.LINE) continue;
|
||||
if(match == predicates.size()) {
|
||||
last = cur.getPrevious(); //it was actually the previous run in this case
|
||||
if(first != null && last != null) {
|
||||
if(reverse) return new InsnSequence(last, first);
|
||||
else return new InsnSequence(first, last);
|
||||
}
|
||||
} else if (predicates.get(match).test(cur)) {
|
||||
if(predicates.get(match).test(cur)) {
|
||||
match++;
|
||||
if(first == null)
|
||||
first = cur;
|
||||
} else match = 0;
|
||||
} else { //reset
|
||||
first = null;
|
||||
match = 0;
|
||||
}
|
||||
//check if we found the last one
|
||||
if(match == predicates.size()) {
|
||||
last = cur;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//only return value if we found both a start and an end
|
||||
if(first != null && last != null) {
|
||||
if(reverse) return new InsnSequence(last, first); //we are matching backwards
|
||||
else return new InsnSequence(first, last);
|
||||
}
|
||||
}
|
||||
throw new PatternNotFoundException("Failed to find pattern!");
|
||||
|
|
Loading…
Reference in a new issue