How to use the xdis.opcodes.base.name_op 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
def_op(l, "BREAK_LOOP", 80, 0, 0, fallthrough=False)

def_op(l, "LOAD_LOCALS", 82, 0, 1)
def_op(l, "RETURN_VALUE", 83, 1, 0, fallthrough=False)

def_op(l, "EXEC_STMT", 85, 3, 0)

def_op(l, "POP_BLOCK", 87, 0, 0)
def_op(l, "END_FINALLY", 88, 1, 0)
def_op(l, "BUILD_CLASS", 89, 3, 0)

# HAVE_ARGUMENT = 90               # Opcodes from here have an argument:

store_op(l, "STORE_NAME", 90, 1, 0, is_type="name")  # Operand is in name list
name_op(l, "DELETE_NAME", 91, 0, 0)  # ""
varargs_op(l, "UNPACK_TUPLE", 92)  # Number of tuple items
def_op(l, "UNPACK_LIST", 93)  # Number of list items
store_op(l, "STORE_ATTR", 95, 2, 0, is_type="name")  # Operand is in name list
name_op(l, "DELETE_ATTR", 96, 1, 0)  # ""
store_op(l, "STORE_GLOBAL", 97, 1, 0, is_type="name")  # ""
name_op(l, "DELETE_GLOBAL", 98, 0, 0)  # ""

const_op(l, "LOAD_CONST", 100, 0, 1)  # Operand is in const list
name_op(l, "LOAD_NAME", 101, 0, 1)  # Operand is in name list
varargs_op(l, "BUILD_TUPLE", 102, -1, 1)  # Number of tuple items
varargs_op(l, "BUILD_LIST", 103, -1, 1)  # Number of list items
varargs_op(l, "BUILD_MAP", 104, -1, 1)  # Always zero for now
name_op(l, "LOAD_ATTR", 105, 1, 1)  # Operand is in name list
compare_op(l, "COMPARE_OP", 106, 2, 1)  # Comparison operator

name_op(l, "IMPORT_NAME", 107, 2, 1)  # Operand is in name list
github rocky / python-xdis / xdis / opcodes / opcode_15.py View on Github external
def_op(l, "UNPACK_LIST", 93)  # Number of list items
store_op(l, "STORE_ATTR", 95, 2, 0, is_type="name")  # Operand is in name list
name_op(l, "DELETE_ATTR", 96, 1, 0)  # ""
store_op(l, "STORE_GLOBAL", 97, 1, 0, is_type="name")  # ""
name_op(l, "DELETE_GLOBAL", 98, 0, 0)  # ""

const_op(l, "LOAD_CONST", 100, 0, 1)  # Operand is in const list
name_op(l, "LOAD_NAME", 101, 0, 1)  # Operand is in name list
varargs_op(l, "BUILD_TUPLE", 102, -1, 1)  # Number of tuple items
varargs_op(l, "BUILD_LIST", 103, -1, 1)  # Number of list items
varargs_op(l, "BUILD_MAP", 104, -1, 1)  # Always zero for now
name_op(l, "LOAD_ATTR", 105, 1, 1)  # Operand is in name list
compare_op(l, "COMPARE_OP", 106, 2, 1)  # Comparison operator

name_op(l, "IMPORT_NAME", 107, 2, 1)  # Operand is in name list
name_op(l, "IMPORT_FROM", 108, 0, 1)  # Operand is in name list

jrel_op(l, "JUMP_FORWARD", 110, 0, 0, fallthrough=False)  # Number of bytes to skip
jrel_op(l, "JUMP_IF_FALSE", 111, 1, 1, True)  # ""
jrel_op(l, "JUMP_IF_TRUE", 112, 1, 1, True)  # ""
jabs_op(l, "JUMP_ABSOLUTE", 113, 0, 0, fallthrough=False)  # Target byte offset from beginning of code
def_op(l, "FOR_LOOP", 114)  # Number of bytes to skip

name_op(l, "LOAD_GLOBAL", 116, 0, 1)  # Operand is in name list

jrel_op(l, "SETUP_LOOP", 120, 0, 0, conditional=True)  # Distance to target address
jrel_op(l, "SETUP_EXCEPT", 121, 0, 0)  # ""
jrel_op(l, "SETUP_FINALLY", 122, 0, 0)  # ""

local_op(l, "LOAD_FAST", 124, 0, 1)  # Local variable number
store_op(l, "STORE_FAST", 125, 1, 0, is_type="local")  # Local variable number
local_op(l, "DELETE_FAST", 126)  # Local variable number
github rocky / python-xdis / xdis / opcodes / opcode_3x.py View on Github external
store_op(l, 'STORE_NAME',           90,  1,  0, is_type="name")   # Operand is in name list
name_op(l, 'DELETE_NAME',           91,  0,  0)   # ""
varargs_op(l, 'UNPACK_SEQUENCE',    92,  0, -1)  # unpacks TOS, arg is the count
jrel_op(l,    'FOR_ITER',           93,  0,  1)

varargs_op(l, 'UNPACK_EX',          94,  0,  0)  # assignment with a starred target; arg is count
store_op(l, 'STORE_ATTR',           95,  2,  0, is_type="name")   # Operand is in name list
name_op(l, 'DELETE_ATTR',           96,  1,  0)   # ""
store_op(l, 'STORE_GLOBAL',         97,  1,  0, is_type="name")   # ""
name_op(l, 'DELETE_GLOBAL',         98,  0,  0)   # ""

# Python 2's DUP_TOPX is gone starting in Python 3.2

const_op(l,   'LOAD_CONST',        100,  0,  1)  # Operand is in const list
name_op(l,    'LOAD_NAME',         101,  0,  1)  # Operand is in name list
varargs_op(l, 'BUILD_TUPLE',       102, -1,  1)  # TOS is count of tuple items
varargs_op(l, 'BUILD_LIST',        103, -1,  1)  # TOS is count of list items
varargs_op(l, 'BUILD_SET',         104, -1,  1)  # TOS is count of set items
def_op(l, 'BUILD_MAP',             105,  0,  1)  # argument is dictionary count to be pushed
name_op(l, 'LOAD_ATTR',            106,  1,  1)  # Operand is in name list
compare_op(l, 'COMPARE_OP',        107,  2,  1)  # Comparison operator
name_op(l, 'IMPORT_NAME',          108,  2,  1)  # Imports TOS and TOS1; module pushed
name_op(l, 'IMPORT_FROM',          109,  0,  1)  # Operand is in name list

jrel_op(l, 'JUMP_FORWARD',         110,  0,  0, fallthrough=False)  # Number of bytes to skip
jabs_op(l, 'JUMP_IF_FALSE_OR_POP', 111, conditional=True)  # Target byte offset from beginning of code
jabs_op(l, 'JUMP_IF_TRUE_OR_POP',  112, conditional=True) # ""
jabs_op(l, 'JUMP_ABSOLUTE',        113,  0,  0, fallthrough=False)  # Target byte offset from beginning of code
jabs_op(l, 'POP_JUMP_IF_FALSE',    114,  2,  1, conditional=True) # ""
jabs_op(l, 'POP_JUMP_IF_TRUE',     115,  2,  1, conditional=True) # ""
github rocky / python-xdis / xdis / opcodes / opcode_15.py View on Github external
def_op(l, "END_FINALLY", 88, 1, 0)
def_op(l, "BUILD_CLASS", 89, 3, 0)

# HAVE_ARGUMENT = 90               # Opcodes from here have an argument:

store_op(l, "STORE_NAME", 90, 1, 0, is_type="name")  # Operand is in name list
name_op(l, "DELETE_NAME", 91, 0, 0)  # ""
varargs_op(l, "UNPACK_TUPLE", 92)  # Number of tuple items
def_op(l, "UNPACK_LIST", 93)  # Number of list items
store_op(l, "STORE_ATTR", 95, 2, 0, is_type="name")  # Operand is in name list
name_op(l, "DELETE_ATTR", 96, 1, 0)  # ""
store_op(l, "STORE_GLOBAL", 97, 1, 0, is_type="name")  # ""
name_op(l, "DELETE_GLOBAL", 98, 0, 0)  # ""

const_op(l, "LOAD_CONST", 100, 0, 1)  # Operand is in const list
name_op(l, "LOAD_NAME", 101, 0, 1)  # Operand is in name list
varargs_op(l, "BUILD_TUPLE", 102, -1, 1)  # Number of tuple items
varargs_op(l, "BUILD_LIST", 103, -1, 1)  # Number of list items
varargs_op(l, "BUILD_MAP", 104, -1, 1)  # Always zero for now
name_op(l, "LOAD_ATTR", 105, 1, 1)  # Operand is in name list
compare_op(l, "COMPARE_OP", 106, 2, 1)  # Comparison operator

name_op(l, "IMPORT_NAME", 107, 2, 1)  # Operand is in name list
name_op(l, "IMPORT_FROM", 108, 0, 1)  # Operand is in name list

jrel_op(l, "JUMP_FORWARD", 110, 0, 0, fallthrough=False)  # Number of bytes to skip
jrel_op(l, "JUMP_IF_FALSE", 111, 1, 1, True)  # ""
jrel_op(l, "JUMP_IF_TRUE", 112, 1, 1, True)  # ""
jabs_op(l, "JUMP_ABSOLUTE", 113, 0, 0, fallthrough=False)  # Target byte offset from beginning of code
def_op(l, "FOR_LOOP", 114)  # Number of bytes to skip

name_op(l, "LOAD_GLOBAL", 116, 0, 1)  # Operand is in name list
github rocky / python-xdis / xdis / opcodes / opcode_2x.py View on Github external
varargs_op(l, "BUILD_MAP",        104,  0,  1)  # TOS is number of kwarg items. Always zero for now
name_op(l, "LOAD_ATTR",           105,  1,  1)  # Operand is in name list
compare_op(l, "COMPARE_OP",       106,  2,  1)  # Comparison operator

name_op(l, "IMPORT_NAME",         107,  2,  2)  # Imports TOS and TOS1; module pushed
name_op(l, "IMPORT_FROM",         108,  0,  1)  # Operand is in name list

jrel_op(l, "JUMP_FORWARD",        110,  0,  0, fallthrough=False)
                                                # Number of bytes to skip
jrel_op(l, "JUMP_IF_FALSE",       111,  1,  1, True)  # ""

jrel_op(l, "JUMP_IF_TRUE",        112,  1,  1, True)  # ""
jabs_op(l, "JUMP_ABSOLUTE",       113,  0,  0, fallthrough=False)
                                                # Target byte offset from beginning of code

name_op(l, "LOAD_GLOBAL",         116,  0,  1)  # Operand is in name list

jabs_op(l, "CONTINUE_LOOP",       119,  0,  0, fallthrough=False)  # Target address
jrel_op(l, "SETUP_LOOP",          120,  0,  0, conditional=True)  # Distance to target address
jrel_op(l, "SETUP_EXCEPT",        121,  0,  3, conditional=True)  # ""
jrel_op(l, "SETUP_FINALLY",       122,  0,  3, conditional=True)  # ""

local_op(l, "LOAD_FAST",          124,  0,  1)  # Local variable number
store_op(l, "STORE_FAST",         125,  1,  0, is_type="local")  # Local variable number
local_op(l, "DELETE_FAST",        126,  0,  0) # Local variable number is in operand

nargs_op(l, "RAISE_VARARGS",      130, -1,  2, fallthrough=False)
                                                # Number of raise arguments (1, 2, or 3)
nargs_op(l, "CALL_FUNCTION",      131, -1,  2)  # TOS is #args + (#kwargs << 8)

nargs_op(l, "MAKE_FUNCTION",      132, -1,  2)  # TOS is number of args with default values
varargs_op(l, "BUILD_SLICE",      133,  2,  1)  # TOS is number of items
github rocky / python-xdis / xdis / opcodes / opcode_26pypy.py View on Github external
finalize_opcodes, init_opdata,
    jrel_op, name_op, nargs_op, varargs_op,
    update_pj2
    )

version = 2.6
python_implementation = "PyPy"

l = locals()
init_opdata(l, opcode_26, version, is_pypy=True)

# FIXME: DRY common PYPY opcode additions

# 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)
github rocky / python-xdis / xdis / opcodes / opcode_2x.py View on Github external
store_op(l, "STORE_ATTR",          95,  2,  0, is_type="name")  # Operand is in name list
name_op(l, "DELETE_ATTR",          96,  1,  0)  # ""
store_op(l, "STORE_GLOBAL",        97,  1,  0, is_type="name")  # ""
name_op(l, "DELETE_GLOBAL",        98,  0,  0)  # ""
nargs_op(l, "DUP_TOPX",            99, -1,  2)  # number of items to duplicate
const_op(l, "LOAD_CONST",         100,  0,  1)  # Operand is in const list
name_op(l, "LOAD_NAME",           101,  0,  1)  # Operand is in name list
varargs_op(l, "BUILD_TUPLE",      102, -1,  1)  # TOS is number of tuple items
varargs_op(l, "BUILD_LIST",       103, -1,  1)  # TOS is number of list items
varargs_op(l, "BUILD_MAP",        104,  0,  1)  # TOS is number of kwarg items. Always zero for now
name_op(l, "LOAD_ATTR",           105,  1,  1)  # Operand is in name list
compare_op(l, "COMPARE_OP",       106,  2,  1)  # Comparison operator

name_op(l, "IMPORT_NAME",         107,  2,  2)  # Imports TOS and TOS1; module pushed
name_op(l, "IMPORT_FROM",         108,  0,  1)  # Operand is in name list

jrel_op(l, "JUMP_FORWARD",        110,  0,  0, fallthrough=False)
                                                # Number of bytes to skip
jrel_op(l, "JUMP_IF_FALSE",       111,  1,  1, True)  # ""

jrel_op(l, "JUMP_IF_TRUE",        112,  1,  1, True)  # ""
jabs_op(l, "JUMP_ABSOLUTE",       113,  0,  0, fallthrough=False)
                                                # Target byte offset from beginning of code

name_op(l, "LOAD_GLOBAL",         116,  0,  1)  # Operand is in name list

jabs_op(l, "CONTINUE_LOOP",       119,  0,  0, fallthrough=False)  # Target address
jrel_op(l, "SETUP_LOOP",          120,  0,  0, conditional=True)  # Distance to target address
jrel_op(l, "SETUP_EXCEPT",        121,  0,  3, conditional=True)  # ""
jrel_op(l, "SETUP_FINALLY",       122,  0,  3, conditional=True)  # ""
github rocky / python-xdis / xdis / opcodes / opcode_2x.py View on Github external
def_op(l, "EXEC_STMT",            85,  3,  0)
def_op(l, "YIELD_VALUE",          86,  1,  1)

def_op(l, "POP_BLOCK",            87,  0,  0)
def_op(l, "END_FINALLY",          88,  1,  0)
def_op(l, "BUILD_CLASS",          89,  2,  0)

HAVE_ARGUMENT = 90              # Opcodes from here have an argument:

store_op(l, "STORE_NAME",          90,  1,  0, is_type="name")  # Operand is in name list
name_op(l, "DELETE_NAME",          91,  0,  0)  # ""
varargs_op(l, "UNPACK_SEQUENCE",   92, -1,  1)  # TOS is number of tuple items
jrel_op(l, "FOR_ITER",             93,  0,  1)  # TOS is read

store_op(l, "STORE_ATTR",          95,  2,  0, is_type="name")  # Operand is in name list
name_op(l, "DELETE_ATTR",          96,  1,  0)  # ""
store_op(l, "STORE_GLOBAL",        97,  1,  0, is_type="name")  # ""
name_op(l, "DELETE_GLOBAL",        98,  0,  0)  # ""
nargs_op(l, "DUP_TOPX",            99, -1,  2)  # number of items to duplicate
const_op(l, "LOAD_CONST",         100,  0,  1)  # Operand is in const list
name_op(l, "LOAD_NAME",           101,  0,  1)  # Operand is in name list
varargs_op(l, "BUILD_TUPLE",      102, -1,  1)  # TOS is number of tuple items
varargs_op(l, "BUILD_LIST",       103, -1,  1)  # TOS is number of list items
varargs_op(l, "BUILD_MAP",        104,  0,  1)  # TOS is number of kwarg items. Always zero for now
name_op(l, "LOAD_ATTR",           105,  1,  1)  # Operand is in name list
compare_op(l, "COMPARE_OP",       106,  2,  1)  # Comparison operator

name_op(l, "IMPORT_NAME",         107,  2,  2)  # Imports TOS and TOS1; module pushed
name_op(l, "IMPORT_FROM",         108,  0,  1)  # Operand is in name list

jrel_op(l, "JUMP_FORWARD",        110,  0,  0, fallthrough=False)
                                                # Number of bytes to skip
github rocky / python-xdis / xdis / opcodes / opcode_3x.py View on Github external
name_op(l, 'DELETE_ATTR',           96,  1,  0)   # ""
store_op(l, 'STORE_GLOBAL',         97,  1,  0, is_type="name")   # ""
name_op(l, 'DELETE_GLOBAL',         98,  0,  0)   # ""

# Python 2's DUP_TOPX is gone starting in Python 3.2

const_op(l,   'LOAD_CONST',        100,  0,  1)  # Operand is in const list
name_op(l,    'LOAD_NAME',         101,  0,  1)  # Operand is in name list
varargs_op(l, 'BUILD_TUPLE',       102, -1,  1)  # TOS is count of tuple items
varargs_op(l, 'BUILD_LIST',        103, -1,  1)  # TOS is count of list items
varargs_op(l, 'BUILD_SET',         104, -1,  1)  # TOS is count of set items
def_op(l, 'BUILD_MAP',             105,  0,  1)  # argument is dictionary count to be pushed
name_op(l, 'LOAD_ATTR',            106,  1,  1)  # Operand is in name list
compare_op(l, 'COMPARE_OP',        107,  2,  1)  # Comparison operator
name_op(l, 'IMPORT_NAME',          108,  2,  1)  # Imports TOS and TOS1; module pushed
name_op(l, 'IMPORT_FROM',          109,  0,  1)  # Operand is in name list

jrel_op(l, 'JUMP_FORWARD',         110,  0,  0, fallthrough=False)  # Number of bytes to skip
jabs_op(l, 'JUMP_IF_FALSE_OR_POP', 111, conditional=True)  # Target byte offset from beginning of code
jabs_op(l, 'JUMP_IF_TRUE_OR_POP',  112, conditional=True) # ""
jabs_op(l, 'JUMP_ABSOLUTE',        113,  0,  0, fallthrough=False)  # Target byte offset from beginning of code
jabs_op(l, 'POP_JUMP_IF_FALSE',    114,  2,  1, conditional=True) # ""
jabs_op(l, 'POP_JUMP_IF_TRUE',     115,  2,  1, conditional=True) # ""

name_op(l, 'LOAD_GLOBAL',          116,  0,  1)  # Operand is in name list

jabs_op(l, 'CONTINUE_LOOP',        119,  0,  0, fallthrough=False)  # Target address
jrel_op(l, 'SETUP_LOOP',           120,  0,  0, conditional=True) # Distance to target address
jrel_op(l, 'SETUP_EXCEPT',         121,  0,  6, conditional=True)  # ""
jrel_op(l, 'SETUP_FINALLY',        122,  0,  6, conditional=True)  # ""

local_op(l, 'LOAD_FAST',           124,  0,  1)  # Local variable number
github rocky / python-xdis / xdis / opcodes / opcode_3x.py View on Github external
varargs_op(l, 'UNPACK_EX',          94,  0,  0)  # assignment with a starred target; arg is count
store_op(l, 'STORE_ATTR',           95,  2,  0, is_type="name")   # Operand is in name list
name_op(l, 'DELETE_ATTR',           96,  1,  0)   # ""
store_op(l, 'STORE_GLOBAL',         97,  1,  0, is_type="name")   # ""
name_op(l, 'DELETE_GLOBAL',         98,  0,  0)   # ""

# Python 2's DUP_TOPX is gone starting in Python 3.2

const_op(l,   'LOAD_CONST',        100,  0,  1)  # Operand is in const list
name_op(l,    'LOAD_NAME',         101,  0,  1)  # Operand is in name list
varargs_op(l, 'BUILD_TUPLE',       102, -1,  1)  # TOS is count of tuple items
varargs_op(l, 'BUILD_LIST',        103, -1,  1)  # TOS is count of list items
varargs_op(l, 'BUILD_SET',         104, -1,  1)  # TOS is count of set items
def_op(l, 'BUILD_MAP',             105,  0,  1)  # argument is dictionary count to be pushed
name_op(l, 'LOAD_ATTR',            106,  1,  1)  # Operand is in name list
compare_op(l, 'COMPARE_OP',        107,  2,  1)  # Comparison operator
name_op(l, 'IMPORT_NAME',          108,  2,  1)  # Imports TOS and TOS1; module pushed
name_op(l, 'IMPORT_FROM',          109,  0,  1)  # Operand is in name list

jrel_op(l, 'JUMP_FORWARD',         110,  0,  0, fallthrough=False)  # Number of bytes to skip
jabs_op(l, 'JUMP_IF_FALSE_OR_POP', 111, conditional=True)  # Target byte offset from beginning of code
jabs_op(l, 'JUMP_IF_TRUE_OR_POP',  112, conditional=True) # ""
jabs_op(l, 'JUMP_ABSOLUTE',        113,  0,  0, fallthrough=False)  # Target byte offset from beginning of code
jabs_op(l, 'POP_JUMP_IF_FALSE',    114,  2,  1, conditional=True) # ""
jabs_op(l, 'POP_JUMP_IF_TRUE',     115,  2,  1, conditional=True) # ""

name_op(l, 'LOAD_GLOBAL',          116,  0,  1)  # Operand is in name list

jabs_op(l, 'CONTINUE_LOOP',        119,  0,  0, fallthrough=False)  # Target address
jrel_op(l, 'SETUP_LOOP',           120,  0,  0, conditional=True) # Distance to target address
jrel_op(l, 'SETUP_EXCEPT',         121,  0,  6, conditional=True)  # ""