Find all `instr` in the block from start to end. `instr` is any Python opcode or a list of opcodes If `instr` is an opcode with a target (like a jump), a target destination can be specified which must match precisely. Return a list with indexes to them or []
(
self, start: int, end: int, instr, target=None, include_beyond_target=False
)
| 468 | # with inst_matches |
| 469 | |
| 470 | def all_instr( |
| 471 | self, start: int, end: int, instr, target=None, include_beyond_target=False |
| 472 | ): |
| 473 | """ |
| 474 | Find all `instr` in the block from start to end. |
| 475 | `instr` is any Python opcode or a list of opcodes |
| 476 | If `instr` is an opcode with a target (like a jump), a target |
| 477 | destination can be specified which must match precisely. |
| 478 | |
| 479 | Return a list with indexes to them or [] if none found. |
| 480 | """ |
| 481 | |
| 482 | code = self.code |
| 483 | assert start >= 0 and end <= len(code) |
| 484 | |
| 485 | try: |
| 486 | None in instr |
| 487 | except: |
| 488 | instr = [instr] |
| 489 | |
| 490 | result = [] |
| 491 | extended_arg = 0 |
| 492 | for offset in self.op_range(start, end): |
| 493 | op = code[offset] |
| 494 | |
| 495 | if op == self.opc.EXTENDED_ARG: |
| 496 | arg = code2num(code, offset + 1) | extended_arg |
| 497 | extended_arg = extended_arg_val(self.opc, arg) |
| 498 | continue |
| 499 | |
| 500 | if op in instr: |
| 501 | if target is None: |
| 502 | result.append(offset) |
| 503 | else: |
| 504 | t = self.get_target(offset, extended_arg) |
| 505 | if include_beyond_target and t >= target: |
| 506 | result.append(offset) |
| 507 | elif t == target: |
| 508 | result.append(offset) |
| 509 | pass |
| 510 | pass |
| 511 | pass |
| 512 | extended_arg = 0 |
| 513 | pass |
| 514 | |
| 515 | return result |
| 516 | |
| 517 | def opname_for_offset(self, offset): |
| 518 | return self.opc.opname[self.code[offset]] |
no test coverage detected