Add "if_not_and" rule similar to "if_not_or" rule.

This commit is contained in:
rocky
2019-12-13 05:13:51 -05:00
parent 668141662e
commit 805ec7dbfc
7 changed files with 58 additions and 31 deletions

View File

@@ -888,32 +888,6 @@ class Scanner37Base(Scanner):
elif op in self.setup_opts_no_loop:
count_SETUP_ += 1
def rem_or(self, start, end, instr, target=None, include_beyond_target=False):
"""
Find offsets of all requested <instr> between <start> and <end>,
optionally <target>ing specified offset, and return list found
<instr> offsets which are not within any POP_JUMP_IF_TRUE jumps.
"""
assert start >= 0 and end <= len(self.code) and start <= end
# Find all offsets of requested instructions
instr_offsets = self.inst_matches(
start, end, instr, target, include_beyond_target
)
# Get all POP_JUMP_IF_TRUE (or) offsets
jump_true_op = self.opc.POP_JUMP_IF_TRUE
pjit_offsets = self.inst_matches(start, end, jump_true_op)
filtered = []
for pjit_offset in pjit_offsets:
pjit_tgt = self.get_target(pjit_offset) - 3
for instr_offset in instr_offsets:
if instr_offset <= pjit_offset or instr_offset >= pjit_tgt:
filtered.append(instr_offset)
instr_offsets = filtered
filtered = []
return instr_offsets
if __name__ == "__main__":
from uncompyle6 import PYTHON_VERSION