opcode_12.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # (C) Copyright 2019-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.2 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_13 as opcode_13
  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. finalize_opcodes,
  26. init_opdata,
  27. name_op,
  28. rm_op,
  29. store_op,
  30. update_pj2,
  31. )
  32. from xdis.opcodes.opcode_13 import opcode_arg_fmt13, opcode_extended_fmt13
  33. version_tuple = (1, 2)
  34. python_implementation = "CPython"
  35. loc = locals()
  36. init_opdata(loc, opcode_13, version_tuple)
  37. # fmt: off
  38. # 1.3 - 1.2 bytecodes differences
  39. rm_op(loc, "LOAD_FAST", 124)
  40. rm_op(loc, "STORE_FAST", 125)
  41. name_op(loc, "LOAD_FAST", 124, 0, 1) # Local variable number
  42. loc["nullaryloadop"].add(124)
  43. store_op(loc, "STORE_FAST", 125, 1, 0, is_type="name") # Local variable number
  44. # fmt: on
  45. # These are used outside of this module
  46. findlinestarts = opcode_13.findlinestarts
  47. opcode_arg_fmt = opcode_arg_fmt12 = opcode_arg_fmt13.copy()
  48. opcode_extended_fmt = opcode_extended_fmt12 = opcode_extended_fmt13.copy()
  49. update_pj2(globals(), loc)
  50. finalize_opcodes(loc)