PyCodeObject
in
CPython's C API).
Modifier and Type | Class and Description |
---|---|
pack-priv static class | CPython311Code.CPythonLayout
Store information about the variables required by a
|
Modifier and Type | Field and Description |
---|---|
private static final int | |
private static final int | |
private static final int | |
pack-priv final byte[] | exceptiontable
Table of byte code address ranges mapped to handler addresses in
a compact byte encoding (defined by CPython and appearing in the
serialised form of a |
pack-priv final CPython311Code. | layout
Describe the layout of the frame local variables (including arguments), cell and free variables allowing implementation-level access to CPython-specific features. |
private static final String | |
pack-priv final byte[] | linetable
Table of byte code address ranges mapped to source lines, presentable as defined in PEP 626. |
private static final String | |
pack-priv final int | stacksize
Number of entries needed for evaluation stack. |
pack-priv final short[] | wordcode
Instruction opcodes, not |
Access | Constructor and Description |
---|---|
public | CPython311Code(String
co_filename co_name co_qualname co_flags a bitmap of traitsco_code as unsigned 16-bit wordsfirst source line of this code firstlineno, byte[] mapping byte code ranges to source lines linetable, Object[] co_consts co_names variable names and properties, in the order
layout,co_varnames + co_cellvars + co_freevars but without
repetition.co_argcount the number of positional
parameters (including positional-only arguments and arguments
with default values)co_posonlyargcount the number of
positional-only arguments (including arguments with default
values)co_kwonlyargcount the number of
keyword-only arguments (including arguments with default
values)co_stacksize supports exception processing exceptiontable)Full constructor based on CPython's
|
Modifier and Type | Method and Description |
---|---|
pack-priv ArgParser | Returns: parser reflecting the frame layout of this code objectBuild an |
pack-priv PyBytes | |
pack-priv int | |
public static CPython311Code | Returns: a new code object( filename, Object str ) = co_filename ( name, Object str ) = co_name ( qualname, int str ) = co_qualname ( flags, Object int ) = @code co_flags} a bitmap of traits( bytecode, int bytes ) = co_code ( firstlineno, Object int ) = co_firstlineno ( linetable, Object bytes ) = co_linetable ( consts, Object tuple ) = co_consts ( names, Object tuple[str] ) = co_names ( localsplusnames, Object tuple[str] ) variable names( localspluskinds, int bytes ) variable kinds( argcount, int int ) = co_argcount ( posonlyargcount, int int ) = co_posonlyargcount ( kwonlyargcount, int int ) = co_kwonlyargcount ( stacksize, Object int ) = co_stacksize ( exceptiontable)tuple ) supports exception
processingEssentially equivalent to the (strongly-typed) constructor, but
accepting |
pack-priv CPython311Function | Returns: the functionproviding the module context interpreter, PyDict name space to treat as global variables globals)Overrides org. PyFunction that will execute this PyCode
(adequate for module-level code).
|
pack-priv CPython311Function | createFunction(Interpreter
providing the module context interpreter, PyDict name space to treat as global variables globals, Object[] default positional argument values or
defaults, PyDict null default keyword argument values or kwdefaults, Object null type annotations ( annotations, PyCell[] dict , null
or maybe tuple )variables referenced but not defined here, must be
size expected by code or closure)null if empty.Implements abstract org. PyFunction that will execute this
PyCode .
|
pack-priv CPython311Code. | layout()
Implements abstract org. |
private static short[] | Returns: 16-bit word codeas compiled by Python as bytes bytecode)Convert the contents of a Python |
CO_FAST_CELL | back to summary |
---|---|
private static final int CO_FAST_CELL |
CO_FAST_FREE | back to summary |
---|---|
private static final int CO_FAST_FREE |
CO_FAST_LOCAL | back to summary |
---|---|
private static final int CO_FAST_LOCAL |
exceptiontable | back to summary |
---|---|
pack-priv final byte[] exceptiontable Table of byte code address ranges mapped to handler addresses in
a compact byte encoding (defined by CPython and appearing in the
serialised form of a |
layout | back to summary |
---|---|
pack-priv final CPython311Code. Describe the layout of the frame local variables (including arguments), cell and free variables allowing implementation-level access to CPython-specific features. |
LENGTHS_UNEQUAL | back to summary |
---|---|
private static final String LENGTHS_UNEQUAL |
linetable | back to summary |
---|---|
pack-priv final byte[] linetable Table of byte code address ranges mapped to source lines, presentable as defined in PEP 626. |
NAME_TUPLES_STRING | back to summary |
---|---|
private static final String NAME_TUPLES_STRING |
stacksize | back to summary |
---|---|
pack-priv final int stacksize Number of entries needed for evaluation stack. |
wordcode | back to summary |
---|---|
pack-priv final short[] wordcode Instruction opcodes, not |
CPython311Code | back to summary |
---|---|
public CPython311Code(String filename, String name, String qualname, int flags, short[] wordcode, int firstlineno, byte[] linetable, Object[] consts, String[] names, CPython311Code. Full constructor based on CPython's
Where the parameters map directly to an attribute of the code
object, that is the best way to explain them. Note that this
factory method is tuned to the needs of
|
buildParser | back to summary |
---|---|
pack-priv ArgParser buildParser() Build an
|
co_code | back to summary |
---|---|
pack-priv PyBytes co_code() Overrides org.
|
co_stacksize | back to summary |
---|---|
pack-priv int co_stacksize() Overrides org.
|
create | back to summary |
---|---|
public static CPython311Code create(Object filename, Object name, Object qualname, int flags, Object bytecode, int firstlineno, Object linetable, Object consts, Object names, Object localsplusnames, Object localspluskinds, int argcount, int posonlyargcount, int kwonlyargcount, int stacksize, Object exceptiontable) Essentially equivalent to the (strongly-typed) constructor, but
accepting
The
Where the parameters map directly to an attribute of the code
object, that is the best way to explain them. Note that this
factory method is tuned to the needs of
|
createFunction | back to summary |
---|---|
pack-priv CPython311Function createFunction(Interpreter interpreter, PyDict globals) Overrides org. Create a
|
createFunction | back to summary |
---|---|
pack-priv CPython311Function createFunction(Interpreter interpreter, PyDict globals, Object[] defaults, PyDict kwdefaults, Object annotations, PyCell[] closure) Implements abstract org. Doc from org. Create a
|
layout | back to summary |
---|---|
pack-priv CPython311Code. Implements abstract org. Doc from org. Describe the layout of the frame local variables (at least the
arguments), cell and free variables.
|
wordcode | back to summary |
---|---|
private static short[] wordcode(PyBytes bytecode) Convert the contents of a Python
|
CPython311Code
object and where they will be stored in
the frame it creates.
Modifier and Type | Field and Description |
---|---|
private final int | cell0
Index of first cell (which may be a parameter). |
pack-priv final int | free0
Index of first free variable. |
private final byte[] | kinds
Kinds of all the variables in frame order. |
private final String[] | localnames
Names of all the variables in frame order. |
pack-priv final int | ncellvars
Count of |
pack-priv final int | nfreevars
Count of |
pack-priv final int | nvarnames
Count of |
Access | Constructor and Description |
---|---|
pack-priv | CPythonLayout(Object
tuple of all the names localsplusnames, Object bytes of kinds of variables localspluskinds, int the number (leading) that are arguments nargs)Construct a |
Modifier and Type | Method and Description |
---|---|
public Stream | cellvars()
Implements org. co_cellvars .
|
public Stream | freevars()
Implements org. co_freevars .
|
public Stream | localnames()
Implements org. co_cellvars will
repeat names from co_varnames if they are parameters.
|
public String | name(int
of variable index)Implements org. |
public int | Returns: the length ofco_cellvars Overrides default org. |
public int | Returns: the length ofco_freevars Overrides default org. |
public int | |
public int | |
private Spliterator | Returns: a spliterator of the namessingle bit kind mask, final int how many of that kind count, int to start looking start)A |
public EnumSet | traits(int
of variable index)Implements org. VariableTrait s of the variable at a given
index .
|
public Stream | varnames()
Implements org. co_varnames .
|
cell0 | back to summary |
---|---|
private final int cell0 Index of first cell (which may be a parameter). Cell variables do not in general form a contiguous block in the frame. |
free0 | back to summary |
---|---|
pack-priv final int free0 Index of first free variable. Free variables form a contiguous block in the frame from this index. |
kinds | back to summary |
---|---|
private final byte[] kinds Kinds of all the variables in frame order. |
localnames | back to summary |
---|---|
private final String[] localnames Names of all the variables in frame order. |
ncellvars | back to summary |
---|---|
pack-priv final int ncellvars Count of |
nfreevars | back to summary |
---|---|
pack-priv final int nfreevars Count of |
nvarnames | back to summary |
---|---|
pack-priv final int nvarnames Count of |
CPythonLayout | back to summary |
---|---|
pack-priv CPythonLayout(Object localsplusnames, Object localspluskinds, int nargs) Construct a |
cellvars | back to summary |
---|---|
public Stream Implements org. Doc from org. Return a stream of the names of variables to include in
|
freevars | back to summary |
---|---|
public Stream Implements org. Doc from org. Return a stream of the names of variables to include in
|
localnames | back to summary |
---|---|
public Stream Implements org. Doc from org. Return a stream of the names of all the local variables These are
the parameters and then the other plain, cell and free variables,
but occurring only once each (whereas |
name | back to summary |
---|---|
public String name(int index) Implements org. Doc from org. Return name of one local frame variable. |
ncellvars | back to summary |
---|---|
public int ncellvars() Overrides default org.
|
nfreevars | back to summary |
---|---|
public int nfreevars() Overrides default org.
|
nvarnames | back to summary |
---|---|
public int nvarnames() Overrides default org.
|
size | back to summary |
---|---|
public int size() Overrides default org.
|
spliterator | back to summary |
---|---|
private Spliterator A
|
traits | back to summary |
---|---|
public EnumSet Implements org. Doc from org. Return the
|
varnames | back to summary |
---|---|
public Stream Implements org. Doc from org. Return a stream of the names of variables to include in
|