opcode_26.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # (C) Copyright 2017, 2020-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. CPython 2.6 bytecode opcodes
  18. This is a like Python 2.6's opcode.py with some additional classification
  19. of stack usage, and opererand formatting functions.
  20. """
  21. import xdis.opcodes.opcode_25 as opcode_25
  22. from xdis.opcodes.base import (
  23. finalize_opcodes,
  24. init_opdata,
  25. name_op,
  26. rm_op,
  27. store_op,
  28. update_pj2,
  29. )
  30. from xdis.opcodes.opcode_2x import opcode_extended_fmt_base2x, update_arg_fmt_base2x
  31. python_implementation = "CPython"
  32. version_tuple = (2, 6)
  33. loc = locals()
  34. init_opdata(loc, opcode_25, version_tuple)
  35. # Below are opcode changes since Python 2.5
  36. # fmt: off
  37. # OP NAME OPCODE POP PUSH
  38. #--------------------------------------------
  39. store_op(loc, "STORE_MAP", 54, 3, 1)
  40. rm_op(loc, "IMPORT_NAME", 107)
  41. name_op(loc, "IMPORT_NAME", 107, 2, 1) # Imports namei; TOS and TOS1 provide
  42. # fromlist and level. Module pushed.
  43. loc["nullaryloadop"].add(107)
  44. # fmt: on
  45. opcode_arg_fmt = update_arg_fmt_base2x.copy()
  46. opcode_extended_fmt = opcode_extended_fmt12 = opcode_extended_fmt_base2x.copy()
  47. # FIXME remove (fix uncompyle6)
  48. update_pj2(globals(), loc)
  49. finalize_opcodes(loc)