opcode_20.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # (C) Copyright 2017, 2019-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.0 bytecode opcodes
  18. This is similar to (but better than) the opcode portion in Python 2.0's dis.py library.
  19. """
  20. import xdis.opcodes.opcode_21 as opcode_21
  21. from xdis.opcodes.base import (
  22. finalize_opcodes,
  23. init_opdata,
  24. rm_op,
  25. update_pj2,
  26. )
  27. from xdis.opcodes.opcode_2x import update_arg_fmt_base2x, opcode_extended_fmt_base2x
  28. version_tuple = (2, 0)
  29. python_implementation = "CPython"
  30. loc = locals()
  31. init_opdata(loc, opcode_21, version_tuple)
  32. # fmt: off
  33. # 2.1 Bytecodes not in 2.0
  34. rm_op(loc, "CONTINUE_LOOP", 119)
  35. rm_op(loc, "MAKE_CLOSURE", 134)
  36. rm_op(loc, "LOAD_CLOSURE", 135)
  37. rm_op(loc, "LOAD_DEREF", 136)
  38. rm_op(loc, "STORE_DEREF", 137)
  39. opcode_arg_fmt = update_arg_fmt_base2x.copy()
  40. opcode_extended_fmt = opcode_extended_fmt12 = opcode_extended_fmt_base2x.copy()
  41. update_pj2(globals(), loc)
  42. finalize_opcodes(loc)
  43. # fmt: on