opcode_310.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # (C) Copyright 2021, 2023-2024 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 3.10 bytecode opcodes
  18. This is like Python 3.10's opcode.py with some classification
  19. of stack usage and information for formatting instructions.
  20. """
  21. import xdis.opcodes.opcode_39 as opcode_39
  22. from xdis.cross_dis import findlinestarts # noqa
  23. from xdis.opcodes.base import def_op, finalize_opcodes, init_opdata, rm_op, update_pj3
  24. from xdis.opcodes.opcode_39 import opcode_arg_fmt39, opcode_extended_fmt39
  25. version_tuple = (3, 10)
  26. python_implementation = "CPython"
  27. loc = locals()
  28. init_opdata(loc, opcode_39, version_tuple)
  29. # fmt: off
  30. # These are removed since 3.9...
  31. rm_op(loc, "RERAISE", 48)
  32. # These are added since 3.9...
  33. # OP NAME OPCODE POP PUSH
  34. #------------------------------------------------
  35. def_op(loc, "GET_LEN", 30, 0, 1)
  36. def_op(loc, "MATCH_MAPPING", 31, 0, 1)
  37. def_op(loc, "MATCH_SEQUENCE", 32, 0, 1)
  38. def_op(loc, "MATCH_KEYS", 33, 0, 2)
  39. def_op(loc, "COPY_DICT_WITHOUT_KEYS", 34, 2, 2)
  40. def_op(loc, "ROT_N", 99, 0, 0)
  41. def_op(loc, "RERAISE", 119, 3, 0)
  42. def_op(loc, "GEN_START", 129, 1, 0)
  43. def_op(loc, "MATCH_CLASS", 152, 2, 1)
  44. # fmt: on
  45. opcode_arg_fmt = opcode_arg_fmt310 = opcode_arg_fmt39.copy()
  46. opcode_extended_fmt = opcode_extended_fmt310 = opcode_extended_fmt39.copy()
  47. update_pj3(globals(), loc)
  48. finalize_opcodes(loc)