Debian Codegraph @

Include/internal/pycore_frame.h

raw
1 /* See InternalDocs/frames.md for an explanation of the frame stack
2 * including explanation of the PyFrameObject and _PyInterpreterFrame
3 * structs. */
4
5 #ifndef Py_INTERNAL_FRAME_H
6 #define Py_INTERNAL_FRAME_H
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 #ifndef Py_BUILD_CORE
12 # error "this header requires Py_BUILD_CORE define"
13 #endif
14
15 #include "pycore_typedefs.h" // _PyInterpreterFrame
16
17
18 struct _frame {
19 PyObject_HEAD
20 PyFrameObject *f_back; /* previous frame, or NULL */
21 _PyInterpreterFrame *f_frame; /* points to the frame data */
22 PyObject *f_trace; /* Trace function */
23 int f_lineno; /* Current line number. Only valid if non-zero */
24 char f_trace_lines; /* Emit per-line trace events? */
25 char f_trace_opcodes; /* Emit per-opcode trace events? */
26 PyObject *f_extra_locals; /* Dict for locals set by users using f_locals, could be NULL */
27 /* This is purely for backwards compatibility for PyEval_GetLocals.
28 PyEval_GetLocals requires a borrowed reference so the actual reference
29 is stored here */
30 PyObject *f_locals_cache;
31 /* A tuple containing strong references to fast locals that were overwritten
32 * via f_locals. Borrowed references to these locals may exist in frames
33 * closer to the top of the stack. The references in this tuple act as
34 * "support" for the borrowed references, ensuring that they remain valid.
35 */
36 PyObject *f_overwritten_fast_locals;
37 /* The frame data, if this frame object owns the frame */
38 PyObject *_f_frame_data[1];
39 };
40
41 extern PyFrameObject* _PyFrame_New_NoTrack(PyCodeObject *code);
42
43
44 /* other API */
45
46 typedef enum _framestate {
47 FRAME_CREATED = -3,
48 FRAME_SUSPENDED = -2,
49 FRAME_SUSPENDED_YIELD_FROM = -1,
50 FRAME_EXECUTING = 0,
51 FRAME_COMPLETED = 1,
52 FRAME_CLEARED = 4
53 } PyFrameState;
54
55 #define FRAME_STATE_SUSPENDED(S) ((S) == FRAME_SUSPENDED || (S) == FRAME_SUSPENDED_YIELD_FROM)
56 #define FRAME_STATE_FINISHED(S) ((S) >= FRAME_COMPLETED)
57
58 #ifdef __cplusplus
59 }
60 #endif
61 #endif /* !Py_INTERNAL_FRAME_H */