opcode_16.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # (C) Copyright 2019-2021, 2023-2024 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 1.6 bytecode opcodes
  18. This is used in bytecode disassembly. This is similar to the
  19. opcodes in Python's dis.py library.
  20. """
  21. import xdis.opcodes.opcode_15 as opcode_15
  22. # This is used from outside this module
  23. from xdis.cross_dis import findlabels, findlinestarts # noqa
  24. from xdis.opcodes.base import call_op, finalize_opcodes, init_opdata, update_pj2
  25. from xdis.opcodes.opcode_2x import opcode_extended_fmt_base2x, update_arg_fmt_base2x
  26. version_tuple = (1, 6)
  27. python_implementation = "CPython"
  28. loc = locals()
  29. # These are just to silence the import above
  30. loc["findlindstarts"] = findlinestarts
  31. loc["findlabels"] = findlabels
  32. init_opdata(loc, opcode_15, version_tuple)
  33. # fmt: off
  34. # 1.6 Bytecodes not in 1.5
  35. call_op(loc, "CALL_FUNCTION_VAR", 140, -1, 1) # #args + (#kwargs << 8)
  36. call_op(loc, "CALL_FUNCTION_KW", 141, -1, 1) # #args + (#kwargs << 8)
  37. call_op(loc, "CALL_FUNCTION_VAR_KW", 142, -1, 1) # #args + (#kwargs << 8)
  38. # fmt: on
  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)