opcode_35pypy.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # (C) Copyright 2017, 2020, 2023-2024 by Rocky Bernstein
  2. """
  3. PYPY 3.5 opcodes
  4. This is a like Python 3.5's opcode.py with some classification
  5. of stack usage.
  6. """
  7. import xdis.opcodes.opcode_35 as opcode_35
  8. from xdis.opcodes.base import (
  9. call_op,
  10. def_op,
  11. finalize_opcodes,
  12. init_opdata,
  13. jrel_op,
  14. name_op,
  15. update_pj3,
  16. varargs_op,
  17. )
  18. from xdis.opcodes.format.extended import (
  19. extended_format_ATTR,
  20. extended_format_CALL_METHOD,
  21. extended_format_RETURN_VALUE,
  22. )
  23. from xdis.opcodes.opcode_36 import extended_format_BUILD_STRING
  24. version_tuple = (3, 5)
  25. python_implementation = "PyPy"
  26. loc = locals()
  27. init_opdata(loc, opcode_35, version_tuple, is_pypy=True)
  28. ## FIXME: DRY common PYPY opcode additions
  29. # PyPy only
  30. # ----------
  31. def_op(loc, "FORMAT_VALUE", 155)
  32. varargs_op(loc, "BUILD_STRING", 157)
  33. name_op(loc, "LOOKUP_METHOD", 201, 1, 2)
  34. call_op(loc, "CALL_METHOD", 202, -1, 1)
  35. loc["hasvargs"].append(202)
  36. # Used only in single-mode compilation list-comprehension generators
  37. varargs_op(loc, "BUILD_LIST_FROM_ARG", 203)
  38. # Used only in assert statements
  39. jrel_op(loc, "JUMP_IF_NOT_DEBUG", 204, conditional=True)
  40. # Python 3.5.3 PyPYy 7.0.0 adds LOAD_REVDB. We can't distinguish
  41. # between the two kinds of bytecode by Python version number, or magic
  42. # number. And we don't have a means of specifying
  43. # platform.python_branch() which would give us the 7.0.0 as opposed to
  44. # 6.0.0.
  45. # Lacking anything better to do, we'll add this opcode since
  46. # the newest PyPy for 3.5 has it.
  47. def_op(loc, "LOAD_REVDB_VAR", 205)
  48. opcode_extended_fmt = {
  49. "BUILD_STRING": extended_format_BUILD_STRING,
  50. "CALL_METHOD": extended_format_CALL_METHOD,
  51. "LOAD_ATTR": extended_format_ATTR,
  52. "RETURN_VALUE": extended_format_RETURN_VALUE,
  53. "STORE_ATTR": extended_format_ATTR,
  54. }
  55. # FIXME remove (fix uncompyle6)
  56. update_pj3(globals(), loc)
  57. finalize_opcodes(loc)