(self)
| 550 | return lines |
| 551 | |
| 552 | def disassemble(self): |
| 553 | show_lines = False |
| 554 | line_to_contents = self.build_line_to_contents() |
| 555 | stream = StringIO() |
| 556 | last_line = 0 |
| 557 | indent = "" |
| 558 | previous_line_tokens = set() |
| 559 | for i_line, contents in sorted(line_to_contents.items()): |
| 560 | while last_line < i_line - 1: |
| 561 | if show_lines: |
| 562 | stream.write("%s.\n" % (last_line + 1,)) |
| 563 | else: |
| 564 | stream.write("\n") |
| 565 | last_line += 1 |
| 566 | |
| 567 | line_contents = [] |
| 568 | dedents_found = 0 |
| 569 | for part in contents: |
| 570 | if part is INDENT_MARKER: |
| 571 | if DEBUG: |
| 572 | print("found indent", i_line) |
| 573 | indent += " " |
| 574 | continue |
| 575 | if part is DEDENT_MARKER: |
| 576 | if DEBUG: |
| 577 | print("found dedent", i_line) |
| 578 | dedents_found += 1 |
| 579 | continue |
| 580 | line_contents.append(part) |
| 581 | |
| 582 | s = indent + _compose_line_contents(line_contents, previous_line_tokens) |
| 583 | if show_lines: |
| 584 | stream.write("%s. %s\n" % (i_line, s)) |
| 585 | else: |
| 586 | stream.write("%s\n" % s) |
| 587 | |
| 588 | if dedents_found: |
| 589 | indent = indent[: -(4 * dedents_found)] |
| 590 | last_line = i_line |
| 591 | |
| 592 | return stream.getvalue() |
| 593 | |
| 594 | |
| 595 | def code_obj_to_source(co): |
no test coverage detected