Пример #1
0
l = locals()
init_opdata(l, opcode_37, version_tuple, is_pypy=True)


# FIXME: DRY common PYPY opcode additions

# fmt: off
rm_op(l, "BUILD_TUPLE_UNPACK_WITH_CALL", 158)
rm_op(l, "LOAD_METHOD",                  160)

nargs_op(l, "CALL_FUNCTION_KW",          141, 9, 1)  # #args + (#kwargs << 8)
nargs_op(l, "CALL_FUNCTION_EX",          142, -2, 1)

# The following were removed from 3.7 but still in Pypy 3.7

store_op(l,   'STORE_ANNOTATION',        127, 1, 0, is_type="name")

# PyPy only
# ----------

name_op(l, "LOOKUP_METHOD",              201, 1, 2)
l["hasvargs"].append(202)
nargs_op(l, "CALL_METHOD_KW",            204, -1, 1)


# Used only in single-mode compilation list-comprehension generators
varargs_op(l, "BUILD_LIST_FROM_ARG",     203)

# PyPy 3.6.1 (and 2.7.13) start to introduce LOAD_REVDB_VAR
import sys
Пример #2
0
def_op(l, "BINARY_DIVIDE",        21,  2,  1)
def_op(l, "BINARY_MODULO",        22,  2,  1)
def_op(l, "BINARY_ADD",           23,  2,  1)
def_op(l, "BINARY_SUBTRACT",      24,  2,  1)
def_op(l, "BINARY_SUBSCR",        25,  2,  1)
def_op(l, "BINARY_FLOOR_DIVIDE",  26,  2,  1)
def_op(l, "BINARY_TRUE_DIVIDE",   27,  2,  1)
def_op(l, "INPLACE_FLOOR_DIVIDE", 28,  2,  1)
def_op(l, "INPLACE_TRUE_DIVIDE",  29,  2,  1)

def_op(l, "SLICE+0",              30,  2,  2)
def_op(l, "SLICE+1",              31,  2,  2)
def_op(l, "SLICE+2",              32,  2,  2)
def_op(l, "SLICE+3",              33,  3,  2)

store_op(l, "STORE_SLICE+0",        40,  2,  0)
store_op(l, "STORE_SLICE+1",        41,  3,  0)
store_op(l, "STORE_SLICE+2",        42,  3,  0)
store_op(l, "STORE_SLICE+3",        43,  4,  0)

def_op(l, "DELETE_SLICE+0",       50,  1,  0)
def_op(l, "DELETE_SLICE+1",       51,  2,  0)
def_op(l, "DELETE_SLICE+2",       52,  2,  0)
def_op(l, "DELETE_SLICE+3",       53,  3,  0)

def_op(l, "INPLACE_ADD",          55,  2,  1)
def_op(l, "INPLACE_SUBTRACT",     56,  2,  1)
def_op(l, "INPLACE_MULTIPLY",     57,  2,  1)
def_op(l, "INPLACE_DIVIDE",       58,  2,  1)
def_op(l, "INPLACE_MODULO",       59,  2,  1)
store_op(l, "STORE_SUBSCR",       60,  3,  0) # Implements TOS1[TOS] = TOS2.
Пример #3
0
import xdis.opcodes.opcode_25 as opcode_25

python_implementation = "CPython"

version = 2.6
version_tuple = (2, 6)

l = locals()
init_opdata(l, opcode_25, version_tuple)

# Below are opcode changes since Python 2.5

# fmt: off
#          OP NAME            OPCODE POP PUSH
#--------------------------------------------
store_op(l, "STORE_MAP",          54,  3,  1)
rm_op(l,    "IMPORT_NAME",       107)
name_op(l,  "IMPORT_NAME",       107,  2,  1)  # Imports namei; TOS and TOS1 provide fromlist and level. Module pushed.
# fmt: on

# FIXME remove (fix uncompyle6)
update_pj2(globals(), l)

opcode_arg_fmt = {
    "CALL_FUNCTION": format_CALL_FUNCTION_pos_name_encoded,
    "CALL_FUNCTION_KW": format_CALL_FUNCTION_pos_name_encoded,
    "CALL_FUNCTION_VAR_KW": format_CALL_FUNCTION_pos_name_encoded,
    "EXTENDED_ARG": format_extended_arg,
    "MAKE_FUNCTION": format_MAKE_FUNCTION_default_argc,
    "RAISE_VARARGS": format_RAISE_VARARGS_older,
}
Пример #4
0
def_op(l, 'BINARY_MODULO', 22, 2, 1)
def_op(l, 'BINARY_ADD', 23, 2, 1)
def_op(l, 'BINARY_SUBTRACT', 24, 2, 1)
def_op(l, 'BINARY_SUBSCR', 25, 2, 1)
def_op(l, 'BINARY_FLOOR_DIVIDE', 26, 2, 1)
def_op(l, 'BINARY_TRUE_DIVIDE', 27, 2, 1)
def_op(l, 'INPLACE_FLOOR_DIVIDE', 28, 2, 1)
def_op(l, 'INPLACE_TRUE_DIVIDE', 29, 2, 1)

# Gone from Python 3 are Python2's
# SLICE+0 .. SLICE+3
# STORE_SLICE+0 .. STORE_SLICE+3
# DELETE_SLICE+0 .. DELETE_SLICE+3

store_op(l, 'STORE_MAP', 54, 3, 1)
def_op(l, 'INPLACE_ADD', 55, 2, 1)
def_op(l, 'INPLACE_SUBTRACT', 56, 2, 1)
def_op(l, 'INPLACE_MULTIPLY', 57, 2, 1)

def_op(l, 'INPLACE_MODULO', 59, 2, 1)
store_op(l, 'STORE_SUBSCR', 60, 3, 0)  # Implements TOS1[TOS] = TOS2.
def_op(l, 'DELETE_SUBSCR', 61, 2, 0)  # Implements del TOS1[TOS].
def_op(l, 'BINARY_LSHIFT', 62, 2, 1)
def_op(l, 'BINARY_RSHIFT', 63, 2, 1)
def_op(l, 'BINARY_AND', 64, 2, 1)
def_op(l, 'BINARY_XOR', 65, 2, 1)
def_op(l, 'BINARY_OR', 66, 2, 1)
def_op(l, 'INPLACE_POWER', 67, 2, 1)
def_op(l, 'GET_ITER', 68, 1, 1)
store_op(l, 'STORE_LOCALS', 69, 1, 0)
# MAKE_FUNCTION oparg

# This is a different opcode from before.

# The tuple of default values for positional-or-keyword parameters,
# the dict of default values for keyword-only parameters, the dict of
# annotations and the closure are pushed on the stack if corresponding
# bit (0-3) is set. They are followed by the code object and the
# qualified name of the function.


# These are new since Python 3.6
#          OP NAME                OPCODE POP PUSH
#---------------------------------------------------
store_op(l,   'STORE_ANNOTATION', 127, 1, 0, is_type="name") # Stores TOS index in name list;
jrel_op(l,    'SETUP_ASYNC_WITH', 154, 2, 8)  # pops __aenter__ and __aexit__; pushed results on stack
def_op(l,     'FORMAT_VALUE',     155, 1, 1)
varargs_op(l, 'BUILD_CONST_KEY_MAP', 156, -2, 1) # TOS is count of kwargs
nargs_op(l,   'CALL_FUNCTION_EX', 142, -2, 1)
def_op(l,     'SETUP_ANNOTATIONS', 85, 1, 1)
varargs_op(l,  'BUILD_STRING',     157, -2, 2)
varargs_op(l,  'BUILD_TUPLE_UNPACK_WITH_CALL', 158)

MAKE_FUNCTION_FLAGS = tuple("default keyword-only annotation closure".split())

def format_MAKE_FUNCTION_arg(flags):
    if flags == 0:
        return "Neither defaults, keyword-only args, annotations, nor closures"
    pattr = ''
    for flag in MAKE_FUNCTION_FLAGS:
Пример #6
0
# CALL_FUNCTION_EX** takes 2 to 3 arguments on the stack: the
# function, the tuple of positional arguments, and optionally the dict
# of keyword arguments if bit 0 of *oparg* is 1.

# MAKE_FUNCTION oparg

# This is a different opcode from before.

# The tuple of default values for positional-or-keyword parameters,
# the dict of default values for keyword-only parameters, the dict of
# annotations and the closure are pushed on the stack if corresponding
# bit (0-3) is set. They are followed by the code object and the
# qualified name of the function.

# These are new since Python 3.6
store_op(l, 'STORE_ANNOTATION', 127, is_type="name")  # Index in name list
jrel_op(l, 'SETUP_ASYNC_WITH', 154)
def_op(l, 'FORMAT_VALUE', 155)
varargs_op(l, 'BUILD_CONST_KEY_MAP', 156, -1, 1)  # TOS is count of kwargs
nargs_op(l, 'CALL_FUNCTION_EX', 142, -1, 1)
def_op(l, 'SETUP_ANNOTATIONS', 85)
def_op(l, 'BUILD_STRING', 157)
varargs_op(l, 'BUILD_TUPLE_UNPACK_WITH_CALL', 158)

MAKE_FUNCTION_FLAGS = tuple("default keyword-only annotation closure".split())


def format_MAKE_FUNCTION_arg(flags):
    pattr = ''
    for flag in MAKE_FUNCTION_FLAGS:
        bit = flags & 1