opcode_32pypy.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # (C) Copyright 2017, 2020, 2023-2024 by Rocky Bernstein
  2. """
  3. PYPY 3.2 opcodes
  4. This is like Python 3.2's opcode.py with some classification
  5. of stack usage.
  6. """
  7. import xdis.opcodes.opcode_32 as opcode_32
  8. from xdis.opcodes.base import (
  9. call_op,
  10. finalize_opcodes,
  11. init_opdata,
  12. jrel_op,
  13. name_op,
  14. update_pj3,
  15. varargs_op,
  16. )
  17. from xdis.opcodes.format.extended import (
  18. extended_format_ATTR,
  19. extended_format_CALL_METHOD,
  20. extended_format_RETURN_VALUE,
  21. )
  22. version_tuple = (3, 2)
  23. python_implementation = "PyPy"
  24. loc = locals()
  25. init_opdata(loc, opcode_32, version_tuple, is_pypy=True)
  26. ## FIXME: DRY common PYPY opcode additions
  27. # PyPy only
  28. # ----------
  29. name_op(loc, "LOOKUP_METHOD", 201, 1, 2)
  30. call_op(loc, "CALL_METHOD", 202, -1, 1)
  31. loc["hasvargs"].append(202)
  32. # Used only in single-mode compilation list-comprehension generators
  33. varargs_op(loc, "BUILD_LIST_FROM_ARG", 203)
  34. # Used only in assert statements
  35. jrel_op(loc, "JUMP_IF_NOT_DEBUG", 204, conditional=True)
  36. # There are no opcodes to remove or change.
  37. # If there were, they'd be listed below.
  38. # FIXME remove (fix uncompyle6)
  39. update_pj3(globals(), loc)
  40. finalize_opcodes(loc)
  41. opcode_extended_fmt = {
  42. "CALL_METHOD": extended_format_CALL_METHOD,
  43. "LOAD_ATTR": extended_format_ATTR,
  44. "RETURN_VALUE": extended_format_RETURN_VALUE,
  45. "STORE_ATTR": extended_format_ATTR,
  46. }