1# (C) Copyright 2021 by Rocky Bernstein 2""" 3PYPY 3.7 opcodes 4 5This is a like Python 3.7's opcode.py with some classification 6of stack usage. 7""" 8 9from xdis.opcodes.base import ( 10 format_CALL_FUNCTION_pos_name_encoded, 11 def_op, 12 extended_format_ATTR, 13 extended_format_RAISE_VARARGS_older, 14 extended_format_RETURN_VALUE, 15 finalize_opcodes, 16 format_RAISE_VARARGS_older, 17 format_extended_arg, 18 init_opdata, 19 name_op, 20 nargs_op, 21 rm_op, 22 store_op, 23 varargs_op, 24 update_pj3, 25) 26 27version = 3.7 28python_implementation = "PyPy" 29 30from xdis.opcodes.opcode_33 import extended_format_MAKE_FUNCTION 31import xdis.opcodes.opcode_37 as opcode_37 32from xdis.opcodes.opcode_37 import ( 33 format_MAKE_FUNCTION_flags, 34) 35 36l = locals() 37init_opdata(l, opcode_37, version, is_pypy=True) 38 39 40# FIXME: DRY common PYPY opcode additions 41 42# fmt: off 43rm_op(l, "BUILD_TUPLE_UNPACK_WITH_CALL", 158) 44rm_op(l, "LOAD_METHOD", 160) 45 46nargs_op(l, "CALL_FUNCTION_KW", 141, 9, 1) # #args + (#kwargs << 8) 47nargs_op(l, "CALL_FUNCTION_EX", 142, -2, 1) 48 49# The following were removed from 3.7 but still in Pypy 3.7 50 51store_op(l, 'STORE_ANNOTATION', 127, 1, 0, is_type="name") 52 53# PyPy only 54# ---------- 55 56name_op(l, "LOOKUP_METHOD", 201, 1, 2) 57l["hasvargs"].append(202) 58nargs_op(l, "CALL_METHOD_KW", 204, -1, 1) 59 60 61# Used only in single-mode compilation list-comprehension generators 62varargs_op(l, "BUILD_LIST_FROM_ARG", 203) 63 64# PyPy 3.6.1 (and 2.7.13) start to introduce LOAD_REVDB_VAR 65import sys 66 67if sys.version_info[:3] >= (3, 6, 1): 68 def_op(l, "LOAD_REVDB_VAR", 205) 69 70# FIXME remove (fix uncompyle6) 71update_pj3(globals(), l) 72 73opcode_arg_fmt = { 74 "EXTENDED_ARG": format_extended_arg, 75 "MAKE_FUNCTION": format_MAKE_FUNCTION_flags, 76 "RAISE_VARARGS": format_RAISE_VARARGS_older, 77 'CALL_FUNCTION': format_CALL_FUNCTION_pos_name_encoded, 78} 79 80opcode_extended_fmt = { 81 "LOAD_ATTR": extended_format_ATTR, 82 "MAKE_FUNCTION": extended_format_MAKE_FUNCTION, 83 "RAISE_VARARGS": extended_format_RAISE_VARARGS_older, 84 "RETURN_VALUE": extended_format_RETURN_VALUE, 85 "STORE_ATTR": extended_format_ATTR, 86} 87# Fmtxblackn: on 88 89finalize_opcodes(l) 90