scanner12.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (c) 2019, 2021 by Rocky Bernstein
  2. """
  3. Python 1.2 bytecode decompiler massaging.
  4. This massages tokenized 1.2 bytecode to make it more amenable for
  5. grammar parsing.
  6. """
  7. import uncompyle6.scanners.scanner13 as scan
  8. # bytecode verification, verify(), uses JUMP_OPs from here
  9. from xdis.opcodes import opcode_11
  10. JUMP_OPS = opcode_11.JUMP_OPS
  11. # We base this off of 1.3 instead of the other way around
  12. # because we cleaned things up this way.
  13. # The history is that 2.7 support is the cleanest,
  14. # then from that we got 2.6 and so on.
  15. class Scanner12(scan.Scanner13):
  16. def __init__(self, show_asm=False):
  17. scan.Scanner14.__init__(self, show_asm)
  18. self.opc = opcode_11
  19. self.opname = opcode_11.opname
  20. self.version = (1, 2) # Note: is the same as 1.1 bytecode
  21. return
  22. # def ingest(self, co, classname=None, code_objects={}, show_asm=None):
  23. # tokens, customize = self.parent_ingest(co, classname, code_objects, show_asm)
  24. # tokens = [t for t in tokens if t.kind != 'SET_LINENO']
  25. # # for t in tokens:
  26. # # print(t)
  27. #
  28. # return tokens, customize