opcode_26pypy.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # (C) Copyright 2017, 2021, 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. PYPY 2.6 opcodes
  18. This is a like Python 2.6's opcode.py with some classification
  19. of stack usage.
  20. """
  21. import xdis.opcodes.opcode_26 as opcode_26
  22. from xdis.opcodes.base import (
  23. finalize_opcodes,
  24. init_opdata,
  25. jrel_op,
  26. name_op,
  27. nargs_op,
  28. update_pj2,
  29. varargs_op,
  30. )
  31. from xdis.opcodes.format.extended import (
  32. extended_format_ATTR,
  33. extended_format_RETURN_VALUE,
  34. )
  35. version_tuple = (2, 6)
  36. python_implementation = "PyPy"
  37. loc = locals()
  38. init_opdata(loc, opcode_26, version_tuple, is_pypy=True)
  39. # FIXME: DRY common PYPY opcode additions
  40. # fmt: off
  41. # PyPy only
  42. # ----------
  43. name_op(loc, 'LOOKUP_METHOD', 201, 1, 2)
  44. nargs_op(loc, 'CALL_METHOD', 202, -1, 1)
  45. # fmt: on
  46. loc["hasnargs"].append(202)
  47. # Used only in single-mode compilation list-comprehension generators
  48. varargs_op(loc, "BUILD_LIST_FROM_ARG", 203)
  49. # Used only in assert statements
  50. jrel_op(loc, "JUMP_IF_NOT_DEBUG", 204, conditional=True)
  51. opcode_extended_fmt = {
  52. "LOAD_ATTR": extended_format_ATTR,
  53. "RETURN_VALUE": extended_format_RETURN_VALUE,
  54. "STORE_ATTR": extended_format_ATTR,
  55. }
  56. # FIXME remove (fix uncompyle6)
  57. update_pj2(globals(), loc)
  58. finalize_opcodes(loc)