Go through instructions removing extended ARG. get_instruction_bytes previously adjusted the operand values to account for these
(self, instructions)
| 530 | start += instruction_size(self.code[start], self.opc) |
| 531 | |
| 532 | def remove_extended_args(self, instructions): |
| 533 | """Go through instructions removing extended ARG. |
| 534 | get_instruction_bytes previously adjusted the operand values |
| 535 | to account for these""" |
| 536 | new_instructions = [] |
| 537 | last_was_extarg = False |
| 538 | n = len(instructions) |
| 539 | for i, inst in enumerate(instructions): |
| 540 | if ( |
| 541 | inst.opname == "EXTENDED_ARG" |
| 542 | and i + 1 < n |
| 543 | and instructions[i + 1].opname != "MAKE_FUNCTION" |
| 544 | ): |
| 545 | last_was_extarg = True |
| 546 | starts_line = inst.starts_line |
| 547 | is_jump_target = inst.is_jump_target |
| 548 | offset = inst.offset |
| 549 | continue |
| 550 | if last_was_extarg: |
| 551 | # j = self.stmts.index(inst.offset) |
| 552 | # self.lines[j] = offset |
| 553 | |
| 554 | new_inst = inst._replace( |
| 555 | starts_line=starts_line, |
| 556 | is_jump_target=is_jump_target, |
| 557 | offset=offset, |
| 558 | ) |
| 559 | inst = new_inst |
| 560 | if i < n: |
| 561 | new_prev = self.prev_op[instructions[i].offset] |
| 562 | j = instructions[i + 1].offset |
| 563 | old_prev = self.prev_op[j] |
| 564 | while self.prev_op[j] == old_prev and j < n: |
| 565 | self.prev_op[j] = new_prev |
| 566 | j += 1 |
| 567 | |
| 568 | last_was_extarg = False |
| 569 | new_instructions.append(inst) |
| 570 | return new_instructions |
| 571 | |
| 572 | def remove_mid_line_ifs(self, ifs): |
| 573 | """ |
no test coverage detected