How to use the xdis.opcodes.base.finalize_opcodes function in xdis

To help you get started, we’ve selected a few xdis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rocky / python-xdis / xdis / opcodes / opcode_15.py View on Github external
# Number of raise arguments (1, 2, or 3)
nargs_op(l, "CALL_FUNCTION", 131, -1, 1)  # #args + (#kwargs << 8)

def_op(l, "MAKE_FUNCTION", 132, -1, 1)  # Number of args with default values
varargs_op(l, "BUILD_SLICE", 133, -1, 1)  # Number of items

def_op(l, "EXTENDED_ARG", 143)
EXTENDED_ARG = 143

fields2copy = """cmp_op hasjabs""".split()

update_pj2(globals(), l)

opcode_arg_fmt = {"EXTENDED_ARG": format_extended_arg}

finalize_opcodes(l)

opcode_extended_fmt = {
    "CALL_FUNCTION": extended_format_CALL_FUNCTION,
    "MAKE_FUNCTION": extended_format_MAKE_FUNCTION_older,
    "RETURN_VALUE": extended_format_RETURN_VALUE,
}
github rocky / python-xdis / xdis / opcodes / opcode_16.py View on Github external
nargs_op(l, "CALL_FUNCTION_KW", 141, -1, 1)  # #args + (#kwargs << 8)
nargs_op(l, "CALL_FUNCTION_VAR_KW", 142, -1, 1)  # #args + (#kwargs << 8)

update_pj2(globals(), l)

opcode_arg_fmt = {"EXTENDED_ARG": format_extended_arg}

opcode_arg_fmt = {
    "EXTENDED_ARG": format_extended_arg,
    "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,
    "MAKE_FUNCTION": format_MAKE_FUNCTION_default_argc,
}

finalize_opcodes(l)
github rocky / python-xdis / xdis / opcodes / opcode_21.py View on Github external
init_opdata(l, opcode_22, version)

# 2.1 bytecodes changes from 2.2
rm_op(l, "BINARY_FLOOR_DIVIDE", 26)
rm_op(l, "BINARY_TRUE_DIVIDE", 27)
rm_op(l, "INPLACE_FLOOR_DIVIDE", 28)
rm_op(l, "INPLACE_TRUE_DIVIDE", 29)
rm_op(l, "GET_ITER", 68)
rm_op(l, "YIELD_VALUE", 86)
rm_op(l, "FOR_ITER", 93)

update_pj2(globals(), l)

opcode_arg_fmt = {"EXTENDED_ARG": format_extended_arg}

finalize_opcodes(l)
github rocky / python-xdis / xdis / opcodes / opcode_36pypy.py View on Github external
def_op(l, "LOAD_REVDB_VAR", 205)

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

opcode_arg_fmt = {
    "MAKE_FUNCTION": format_MAKE_FUNCTION_flags,
    'CALL_FUNCTION': format_CALL_FUNCTION_pos_name_encoded,
    "EXTENDED_ARG": format_extended_arg,
}

opcode_extended_fmt = {
    "RETURN_VALUE": extended_format_RETURN_VALUE,
}

finalize_opcodes(l)
github rocky / python-xdis / xdis / opcodes / opcode_10.py View on Github external
version = 1.0
python_implementation = "CPython"

l = locals()
init_opdata(l, opcode_11, version)

# 1.0 - 1.1 bytecodes differences
rm_op(l, "LOAD_GLOBALS", 84)
rm_op(l, "EXEC_STMT", 85)

update_pj2(globals(), l)

opcode_arg_fmt = {"EXTENDED_ARG": format_extended_arg}

finalize_opcodes(l)

opcode_extended_fmt = {
    "CALL_FUNCTION": extended_format_CALL_FUNCTION,
    "RETURN_VALUE": extended_format_RETURN_VALUE,
}

findlinestarts = opcode_11.findlinestarts
github rocky / python-xdis / xdis / opcodes / opcode_27.py View on Github external
def_op(l, "EXTENDED_ARG", 145)
def_op(l, "SET_ADD", 146, 1, 0)  # Calls set.add(TOS1[-i], TOS).
# Used to implement set comprehensions.
def_op(l, "MAP_ADD",               147, 3, 1)  # Calls dict.setitem(TOS1[-i], TOS, TOS1)
# Used to implement dict comprehensions.

update_pj3(globals(), l)

opcode_arg_fmt = {
    "MAKE_FUNCTION": format_MAKE_FUNCTION_default_argc,
    "EXTENDED_ARG": format_extended_arg,
    "CALL_FUNCTION": format_CALL_FUNCTION_pos_name_encoded,
}

finalize_opcodes(l)

opcode_extended_fmt = {
    "CALL_FUNCTION": extended_format_CALL_FUNCTION,
    "RETURN_VALUE": extended_format_RETURN_VALUE,
    "MAKE_FUNCTION": extended_format_MAKE_FUNCTION_older,
}
github rocky / python-xdis / xdis / opcodes / opcode_32pypy.py View on Github external
nargs_op(l, "CALL_METHOD", 202, -1, 1)
l["hasvargs"].append(202)

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

# Used only in assert statements
jrel_op(l, "JUMP_IF_NOT_DEBUG", 204, conditional=True)

# There are no opcodes to remove or change.
# If there were, they'd be listed below.

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

finalize_opcodes(l)
github rocky / python-xdis / xdis / opcodes / opcode_37.py View on Github external
"CALL_METHOD": opcode_36.format_CALL_FUNCTION,
    "MAKE_FUNCTION": format_MAKE_FUNCTION_flags,
    "FORMAT_VALUE": format_value_flags,
    "EXTENDED_ARG": opcode_36.format_extended_arg36
}

opcode_extended_fmt = {
    "CALL_FUNCTION": opcode_36.extended_format_CALL_FUNCTION,
    "CALL_METHOD": opcode_36.extended_format_CALL_METHOD,
    "MAKE_FUNCTION": extended_format_MAKE_FUNCTION,
    "RETURN_VALUE": extended_format_RETURN_VALUE,
}

update_pj3(globals(), l)

finalize_opcodes(l)
github rocky / python-xdis / xdis / opcodes / opcode_14.py View on Github external
# 1.4 Bytecodes not in 1.5
def_op(l, "UNARY_CALL", 14)
def_op(l, "BINARY_CALL", 26)
def_op(l, "RAISE_EXCEPTION", 81)
def_op(l, "BUILD_FUNCTION", 86)
varargs_op(l, "UNPACK_ARG", 94)  # Number of arguments expected
varargs_op(l, "UNPACK_VARARG", 99)  # Minimal number of arguments
name_op(l, "LOAD_LOCAL", 115)
varargs_op(l, "SET_FUNC_ARGS", 117)  # Argcount
varargs_op(l, "RESERVE_FAST", 123)  # Number of local variables

update_pj2(globals(), l)

opcode_arg_fmt = {"EXTENDED_ARG": format_extended_arg}

finalize_opcodes(l)

def findlinestarts(co, dup_lines=False):
    code = co.co_code
    n = len(code)
    offset = 0
    while offset < n:
        op = code[offset]
        offset += 1
        if op == l["opmap"]["SET_LINENO"] and offset > 0:
            lineno = code[offset] + code[offset + 1] * 256
            yield (offset - 1, lineno)
            pass
        if op >= l["HAVE_ARGUMENT"]:
            offset += 2
            pass
        pass
github rocky / python-xdis / xdis / opcodes / opcode_26pypy.py View on Github external
# PyPy only
# ----------
name_op(l,   'LOOKUP_METHOD',   201,  1, 2)
nargs_op(l,  'CALL_METHOD',     202, -1, 1)
l['hasnargs'].append(202)

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

# Used only in assert statements
jrel_op(l, 'JUMP_IF_NOT_DEBUG',      204, conditional=True)

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

finalize_opcodes(l)