mirror of
https://github.com/zaaarf/lillero.git
synced 2024-11-24 08:24:49 +01:00
fix: fixed ignore flags in PatternMatcher
This commit is contained in:
parent
752c7ae6ab
commit
dd09c4f8e1
1 changed files with 7 additions and 10 deletions
|
@ -78,24 +78,21 @@ public class PatternMatcher {
|
||||||
*/
|
*/
|
||||||
public InsnSequence find(AbstractInsnNode node) {
|
public InsnSequence find(AbstractInsnNode node) {
|
||||||
if(node != null) {
|
if(node != null) {
|
||||||
AbstractInsnNode first;
|
AbstractInsnNode first, last;
|
||||||
AbstractInsnNode last;
|
|
||||||
for(AbstractInsnNode cur = node; cur != null; cur = reverse ? cur.getPrevious() : cur.getNext()) {
|
for(AbstractInsnNode cur = node; cur != null; cur = reverse ? cur.getPrevious() : cur.getNext()) {
|
||||||
|
if(predicates.size() == 0) return new InsnSequence(cur); //match whatever
|
||||||
|
first = cur;
|
||||||
|
last = cur;
|
||||||
|
for(int match = 0; match < predicates.size(); last = reverse ? last.getPrevious() : last.getNext()) {
|
||||||
if(ignoreLabels && cur.getType() == AbstractInsnNode.LABEL) continue;
|
if(ignoreLabels && cur.getType() == AbstractInsnNode.LABEL) continue;
|
||||||
if(ignoreFrames && cur.getType() == AbstractInsnNode.FRAME) continue;
|
if(ignoreFrames && cur.getType() == AbstractInsnNode.FRAME) continue;
|
||||||
if(ignoreLineNumbers && cur.getType() == AbstractInsnNode.LINE) continue;
|
if(ignoreLineNumbers && cur.getType() == AbstractInsnNode.LINE) continue;
|
||||||
if(predicates.size() == 0)
|
|
||||||
return new InsnSequence(cur); //match whatever
|
|
||||||
first = cur;
|
|
||||||
last = cur;
|
|
||||||
for(int match = 0; match < predicates.size(); match++) {
|
|
||||||
if(last == null) break;
|
if(last == null) break;
|
||||||
if(!predicates.get(match).test(last)) break;
|
if(!predicates.get(match).test(last)) break;
|
||||||
if(match == predicates.size() - 1) {
|
if(match == predicates.size() - 1) {
|
||||||
if(reverse) return new InsnSequence(last, first); //we are matching backwards
|
if(reverse) return new InsnSequence(last, first); //we are matching backwards
|
||||||
else return new InsnSequence(first, last);
|
else return new InsnSequence(first, last);
|
||||||
}
|
} else match++;
|
||||||
last = reverse ? last.getPrevious() : last.getNext();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue