opcode_27pypy.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # (C) Copyright 2017, 2020, 2023 by Rocky Bernstein
  2. """
  3. PYPY 2.7 opcodes
  4. This is a like Python 2.7's opcode.py with some classification
  5. of stack usage.
  6. """
  7. import sys
  8. import xdis.opcodes.opcode_27 as opcode_27
  9. from xdis.opcodes.base import (
  10. def_op,
  11. finalize_opcodes,
  12. init_opdata,
  13. jrel_op,
  14. name_op,
  15. nargs_op,
  16. update_pj3,
  17. )
  18. from xdis.opcodes.opcode_2x import update_arg_fmt_base2x, opcode_extended_fmt_base2x
  19. version_tuple = (2, 7)
  20. python_implementation = "PyPy"
  21. loc = locals()
  22. init_opdata(loc, opcode_27, version_tuple, is_pypy=True)
  23. # FIXME: DRY common PYPY opcode additions
  24. # PyPy only
  25. # ----------
  26. name_op(loc, "LOOKUP_METHOD", 201, 1, 2)
  27. nargs_op(loc, "CALL_METHOD", 202, -1, 1)
  28. loc["hasnargs"].append(202)
  29. # Used only in single-mode compilation list-comprehension generators
  30. def_op(loc, "BUILD_LIST_FROM_ARG", 203)
  31. # Used only in assert statements
  32. jrel_op(loc, "JUMP_IF_NOT_DEBUG", 204, conditional=True)
  33. # PyPy 2.7.13 (and 3.6.1) start to introduce LOAD_REVDB_VAR
  34. if sys.version_info[:3] >= (2, 7, 13) and sys.version_info[4] >= 42:
  35. def_op(loc, "LOAD_REVDB_VAR", 205)
  36. # There are no opcodes to remove or change.
  37. # If there were, they'd be listed below.
  38. opcode_arg_fmt = update_arg_fmt_base2x.copy()
  39. opcode_extended_fmt = opcode_extended_fmt12 = opcode_extended_fmt_base2x.copy()
  40. # FIXME remove (fix uncompyle6)
  41. update_pj3(globals(), loc)
  42. finalize_opcodes(loc)