opcode_10.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.0 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_11 as opcode_11
  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. update_pj2,
  30. )
  31. from xdis.opcodes.opcode_11 import opcode_arg_fmt11, opcode_extended_fmt11
  32. version_tuple = (1, 0)
  33. python_implementation = "CPython"
  34. loc = locals()
  35. init_opdata(loc, opcode_11, version_tuple)
  36. # fmt: off
  37. # 1.0 - 1.1 bytecodes differences
  38. rm_op(loc, "LOAD_GLOBALS", 84)
  39. rm_op(loc, "LOAD_FAST", 124)
  40. name_op(loc, "LOAD_FAST", 124, 0, 1) # Local variable number
  41. loc["nullaryloadop"].add(124)
  42. # fmt: on
  43. findlinestarts = opcode_11.findlinestarts
  44. opcode_arg_fmt = opcode_arg_fmt11.copy()
  45. opcode_extended_fmt = opcode_extended_fmt11.copy()
  46. update_pj2(globals(), loc)
  47. finalize_opcodes(loc)