fix: fixed ignore flags in PatternMatcher

This commit is contained in:
zaaarf 2023-04-13 18:30:35 +02:00
parent 752c7ae6ab
commit dd09c4f8e1
No known key found for this signature in database
GPG key ID: 82240E075E31FA4C

View file

@ -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++;
}
}
}