Пример #1
0
This is a like Python 3.5's opcode.py with some classification
of stack usage.
"""

from xdis.opcodes.base import (
    def_op, finalize_opcodes, init_opdata,
    jrel_op, name_op, nargs_op,
    varargs_op, update_pj3)

version = 3.5

import xdis.opcodes.opcode_35 as opcode_35

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

## FIXME: DRY common PYPY opcode additions

# PyPy only
# ----------
def_op(l, 'FORMAT_VALUE',   155)
def_op(l, 'BUILD_STRING',   157)
name_op(l, 'LOOKUP_METHOD',  201,  1, 2)
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
Пример #2
0
    varargs_op,
    update_pj3,
)

version = 3.7
version_tuple = (3, 7)
python_implementation = "PyPy"

from xdis.opcodes.opcode_33 import extended_format_MAKE_FUNCTION
import xdis.opcodes.opcode_37 as opcode_37
from xdis.opcodes.opcode_37 import (
    format_MAKE_FUNCTION_flags,
)

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")
Пример #3
0
    format_RAISE_VARARGS_older,
    format_extended_arg,
    free_op,
    init_opdata,
    rm_op,
    update_pj3,
)

import xdis.opcodes.opcode_33 as opcode_33

version = 3.4
python_implementation = "CPython"

l = locals()

init_opdata(l, opcode_33, version)

# These are removed since Python 3.3
rm_op(l, "STORE_LOCALS", 69)

# These are new since Python 3.3
free_op(l, "LOAD_CLASSDEREF", 148)

update_pj3(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,
    "MAKE_FUNCTION": opcode_33.format_MAKE_FUNCTION_default_pos_arg,
    "EXTENDED_ARG": format_extended_arg,
Пример #4
0
    nargs_op,
    resolved_attrs,
    rm_op,
    update_pj3
    )

from xdis.opcodes.opcode_33 import extended_format_MAKE_FUNCTION, extended_format_ATTR
import xdis.opcodes.opcode_36 as opcode_36

version = 3.7
version_tuple = (3, 7)
python_implementation = "CPython"

l = locals()

init_opdata(l, opcode_36, version_tuple)

### Opcodes that have changed drastically ####


# BUILD_MAP_UNPACK_WITH_CALL oparg

# oparg is the number of unpacked mappings which no longer limited by
# 255. As in BUILD_MAP_UNPACK.The location of the function is `oparg +
# 2`.


# CALL_FUNCTION oparg

# oparg is the number of positional arguments on the stack which no
# longer limited by 255.
Пример #5
0
# This is used from outside this module
from xdis.bytecode import findlabels

import xdis.opcodes.opcode_14 as opcode_14
from xdis.opcodes.base import (
    init_opdata,
    def_op,
    rm_op,
    finalize_opcodes,
    format_extended_arg,
    # Although these aren't used here, they are exported
    update_pj2,
)

version = 1.3

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

# 1.3 - 1.4 bytecodes differences
rm_op(l, "BINARY_POWER", 19)
def_op(l, "LOAD_GLOBALS", 84)

update_pj2(globals(), l)

opcode_arg_fmt = {"EXTENDED_ARG": format_extended_arg}

finalize_opcodes(l)

findlinestarts = opcode_14.findlinestarts
Пример #6
0
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
"""
CPython 2.1 bytecode opcodes

This is similar to the opcode portion in Python 2.1's dis.py library.
"""

import xdis.opcodes.opcode_22 as opcode_22
from xdis.opcodes.base import (
    init_opdata, finalize_opcodes, format_extended_arg, rm_op, update_pj2)

version = 2.1

l = locals()
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,
}
Пример #7
0
of stack usage.
"""

from xdis.opcodes.base import (
    def_op, finalize_opcodes,
    format_extended_arg, init_opdata,
    rm_op, update_pj3)

from xdis.opcodes.opcode_3x import format_MAKE_FUNCTION_arg

import xdis.opcodes.opcode_3x as opcode_3x

version = 3.3

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

# Below are opcode changes since Python 3.2

rm_op(l,  'STOP_CODE',   0)
def_op(l, 'YIELD_FROM', 72)

update_pj3(globals(), l)

opcode_arg_fmt = {
    'MAKE_FUNCTION': format_MAKE_FUNCTION_arg,
    'EXTENDED_ARG': format_extended_arg,
}

finalize_opcodes(l)
Пример #8
0
This is a like Python 3.5's opcode.py with some classification
of stack usage.
"""

from xdis.opcodes.base import (
    def_op, finalize_opcodes, init_opdata,
    jrel_op, name_op, nargs_op,
    varargs_op, update_pj3)

version = 3.5

import xdis.opcodes.opcode_35 as opcode_35

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

## FIXME: DRY common PYPY opcode additions

# PyPy only
# ----------
def_op(l, 'FORMAT_VALUE',   155)
def_op(l, 'BUILD_STRING',   157)
name_op(l, 'LOOKUP_METHOD',  201,  1, 2)
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
Пример #9
0
from xdis.opcodes.base import def_op, finalize_opcodes, init_opdata, update_pj3
import xdis.opcodes.opcode_27 as opcode_27

version = 2.7
python_implementation = "CPython"

l = locals()
init_opdata(l, opcode_27, 2.7)

def_op(l, "LOAD_VAR_ZERO_LOAD_CONST", 173, 0, 2)

update_pj3(globals(), l)

finalize_opcodes(l)
Пример #10
0
# This is used from outside this module
from xdis.bytecode import findlabels

import xdis.opcodes.opcode_15 as opcode_15
from xdis.opcodes.base import (
    init_opdata,
    def_op, name_op, rm_op, varargs_op,
    finalize_opcodes, format_extended_arg,
    # Although these aren't used here, they are exported
    update_pj2
    )

version = 1.4

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

# 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 = {