2 /* Frame object interface */
4 #ifndef Py_FRAMEOBJECT_H
5 #define Py_FRAMEOBJECT_H
11 int b_type
; /* what kind of block this is */
12 int b_handler
; /* where to jump to find handler */
13 int b_level
; /* value stack level to pop to */
16 typedef struct _frame
{
18 struct _frame
*f_back
; /* previous frame, or NULL */
19 PyCodeObject
*f_code
; /* code segment */
20 PyObject
*f_builtins
; /* builtin symbol table (PyDictObject) */
21 PyObject
*f_globals
; /* global symbol table (PyDictObject) */
22 PyObject
*f_locals
; /* local symbol table (PyDictObject) */
23 PyObject
**f_valuestack
; /* points after the last local */
24 /* Next free slot in f_valuestack. Frame creation sets to f_valuestack.
25 Frame evaluation usually NULLs it, but a frame that yields sets it
26 to the current stack top. */
27 PyObject
**f_stacktop
;
28 PyObject
*f_trace
; /* Trace function */
29 PyObject
*f_exc_type
, *f_exc_value
, *f_exc_traceback
;
30 PyThreadState
*f_tstate
;
31 int f_lasti
; /* Last instruction if called */
32 /* As of 2.3 f_lineno is only valid when tracing is active (i.e. when
33 f_trace is set) -- at other times use PyCode_Addr2Line instead. */
34 int f_lineno
; /* Current line number */
35 int f_restricted
; /* Flag set if restricted operations
37 int f_iblock
; /* index in f_blockstack */
38 PyTryBlock f_blockstack
[CO_MAXBLOCKS
]; /* for try and loop blocks */
39 int f_nlocals
; /* number of locals */
42 int f_stacksize
; /* size of value stack */
43 PyObject
*f_localsplus
[1]; /* locals+stack, dynamically sized */
47 /* Standard object interface */
49 PyAPI_DATA(PyTypeObject
) PyFrame_Type
;
51 #define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type)
53 PyAPI_FUNC(PyFrameObject
*) PyFrame_New(PyThreadState
*, PyCodeObject
*,
54 PyObject
*, PyObject
*);
57 /* The rest of the interface is specific for frame objects */
59 /* Block management functions */
61 PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject
*, int, int, int);
62 PyAPI_FUNC(PyTryBlock
*) PyFrame_BlockPop(PyFrameObject
*);
64 /* Extend the value stack */
66 PyAPI_FUNC(PyObject
**) PyFrame_ExtendStack(PyFrameObject
*, int, int);
68 /* Conversions between "fast locals" and locals in dictionary */
70 PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject
*, int);
71 PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject
*);
76 #endif /* !Py_FRAMEOBJECT_H */