opcode_13.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # (C) Copyright 2018-2023 by Rocky Bernstein
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. """
  17. CPython 1.3 bytecode opcodes
  18. This is used in bytecode disassembly. This is similar to the
  19. opcodes in Python's dis.py library.
  20. """
  21. import xdis.opcodes.opcode_14 as opcode_14
  22. # This is used from outside this module
  23. from xdis.cross_dis import findlabels # noqa
  24. from xdis.opcodes.base import ( # Although these aren't used here, they are exported
  25. def_op,
  26. finalize_opcodes,
  27. init_opdata,
  28. rm_op,
  29. update_pj2,
  30. )
  31. from xdis.opcodes.opcode_1x import opcode_extended_fmt_base1x, update_arg_fmt_base1x
  32. version_tuple = (1, 3)
  33. python_implementation = "CPython"
  34. loc = locals()
  35. init_opdata(loc, opcode_14, version_tuple)
  36. # 1.3 - 1.4 bytecodes differences
  37. rm_op(loc, "BINARY_POWER", 19)
  38. def_op(loc, "LOAD_GLOBALS", 84)
  39. opcode_arg_fmt = opcode_arg_fmt13 = update_arg_fmt_base1x.copy()
  40. del opcode_arg_fmt["EXTENDED_ARG"]
  41. opcode_extended_fmt = (
  42. opcode_extended_fmt13
  43. ) = opcode_extended_fmt13 = opcode_extended_fmt_base1x.copy()
  44. findlinestarts = opcode_14.findlinestarts
  45. update_pj2(globals(), loc)
  46. finalize_opcodes(loc)