PyFrame
is the context for the execution of code.
Different concrete sub-classes of PyFrame
exist to
execute different compiled representations of Python code. For
example, there is one for CPython 3.11 byte code and (we expect)
another for Java byte code. The type of code object supported is
the parameter C
to the class.
In order that argument processing may be uinform irrespective of
concrete type, a PyFrame
presents an abstraction that has
arguments laid out in an array. For example, the function
definition:
def func(a, b, c=3, d=4, /, e=5, f=6, *aa, g=7, h, i=9, **kk): v, w, x = b, c, d, e return uthe layout of the local variables in a frame would be as below
frame | a | b | c | d | e | f | g | h | i | aa | kk | u | v | w | x | |
code | argcount | kwonlyargcount | * | ** | ||||||||||||
posonlyargcount | ||||||||||||||||
function | defaults | kwdefaults |
In the last row of the table, the properties are supplied by the
function object during each call. defaults
apply in the
position show, in order, while kwdefaults
(in a map)
apply to keywords wherever the name matches. The names in the
frame are those in the PyCode#varnames
field of the
associated code object
The frame presents an abstraction of an array of named local variables, and two more of cell and free variables, while concrete subclasses are free to implement these in whatever manner they choose.
Modifier and Type | Field and Description |
---|---|
pack-priv PyFrame | back
Frames form a stack by chaining through the back pointer. |
pack-priv final C | code
Code this frame is to execute, exposed as immutable
|
pack-priv final PyFunction | func
Function of which this is a frame. |
pack-priv Object | locals
Local context (name space) of execution. |
public static final PyType | TYPE
The Python type |
Access | Constructor and Description |
---|---|
protected | PyFrame(PyFunction<? extends C>
defining the code and globals func)Foundation constructor on which subclass constructors rely. |
Modifier and Type | Method and Description |
---|---|
pack-priv abstract Object | |
pack-priv Interpreter | Returns: Interpreter that defines the import context.Get the interpreter that defines the import context when executing code. |
protected Map | |
public String |
back | back to summary |
---|---|
pack-priv PyFrame<? extends PyCode> back Frames form a stack by chaining through the back pointer. |
code | back to summary |
---|---|
pack-priv final C code Code this frame is to execute, exposed as immutable
|
func | back to summary |
---|---|
pack-priv final PyFunction<? extends C> func Function of which this is a frame. |
locals | back to summary |
---|---|
pack-priv Object locals Local context (name space) of execution. (Assign if needed.) This is allowed to be any type, but if it is ever actually used, the interpreter will expect it to support the mapping protocol. |
TYPE | back to summary |
---|---|
public static final PyType TYPE The Python type |
PyFrame | back to summary |
---|---|
protected PyFrame(PyFunction<? extends C> func) Foundation constructor on which subclass constructors rely. This
provides a "loose" frame that is not yet part of any stack until
explicitly pushed (with
A frame always belongs to an
|
eval | back to summary |
---|---|
pack-priv abstract Object eval() Execute the code in this frame.
|
getInterpreter | back to summary |
---|---|
pack-priv Interpreter getInterpreter() Get the interpreter that defines the import context when executing code.
|
localsMapOrNull | back to summary |
---|---|
protected Map Provide |
toString | back to summary |
---|---|
public String toString() Overrides java. Doc from java. Returns a string representation of the object. |