2025-03-19 18:17:44 +01:00
|
|
|
/* See InternalDocs/frames.md for an explanation of the frame stack
|
|
|
|
|
* including explanation of the PyFrameObject and _PyInterpreterFrame
|
|
|
|
|
* structs. */
|
|
|
|
|
|
2021-05-21 10:57:35 +01:00
|
|
|
#ifndef Py_INTERNAL_FRAME_H
|
|
|
|
|
#define Py_INTERNAL_FRAME_H
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-08-21 19:15:52 +02:00
|
|
|
#ifndef Py_BUILD_CORE
|
|
|
|
|
# error "this header requires Py_BUILD_CORE define"
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-03-19 15:23:32 +01:00
|
|
|
#include "pycore_typedefs.h" // _PyInterpreterFrame
|
2022-01-05 03:30:26 -08:00
|
|
|
|
2022-04-11 16:05:20 +01:00
|
|
|
|
2022-02-25 12:53:19 +01:00
|
|
|
struct _frame {
|
|
|
|
|
PyObject_HEAD
|
|
|
|
|
PyFrameObject *f_back; /* previous frame, or NULL */
|
2025-03-19 15:23:32 +01:00
|
|
|
_PyInterpreterFrame *f_frame; /* points to the frame data */
|
2022-02-25 12:53:19 +01:00
|
|
|
PyObject *f_trace; /* Trace function */
|
|
|
|
|
int f_lineno; /* Current line number. Only valid if non-zero */
|
|
|
|
|
char f_trace_lines; /* Emit per-line trace events? */
|
|
|
|
|
char f_trace_opcodes; /* Emit per-opcode trace events? */
|
2024-05-04 04:12:10 -07:00
|
|
|
PyObject *f_extra_locals; /* Dict for locals set by users using f_locals, could be NULL */
|
2024-07-16 12:17:47 -07:00
|
|
|
/* This is purely for backwards compatibility for PyEval_GetLocals.
|
|
|
|
|
PyEval_GetLocals requires a borrowed reference so the actual reference
|
|
|
|
|
is stored here */
|
|
|
|
|
PyObject *f_locals_cache;
|
2022-02-25 12:53:19 +01:00
|
|
|
/* The frame data, if this frame object owns the frame */
|
|
|
|
|
PyObject *_f_frame_data[1];
|
|
|
|
|
};
|
2021-12-09 12:59:26 -07:00
|
|
|
|
2022-02-25 16:07:14 +01:00
|
|
|
extern PyFrameObject* _PyFrame_New_NoTrack(PyCodeObject *code);
|
|
|
|
|
|
2021-12-09 12:59:26 -07:00
|
|
|
|
|
|
|
|
/* other API */
|
|
|
|
|
|
2022-03-22 12:57:19 +00:00
|
|
|
typedef enum _framestate {
|
2023-11-03 10:01:36 +00:00
|
|
|
FRAME_CREATED = -3,
|
|
|
|
|
FRAME_SUSPENDED = -2,
|
|
|
|
|
FRAME_SUSPENDED_YIELD_FROM = -1,
|
2021-07-26 11:22:16 +01:00
|
|
|
FRAME_EXECUTING = 0,
|
2022-03-22 12:57:19 +00:00
|
|
|
FRAME_COMPLETED = 1,
|
2021-07-26 11:22:16 +01:00
|
|
|
FRAME_CLEARED = 4
|
2022-03-22 12:57:19 +00:00
|
|
|
} PyFrameState;
|
2021-05-21 10:57:35 +01:00
|
|
|
|
2023-11-03 10:01:36 +00:00
|
|
|
#define FRAME_STATE_SUSPENDED(S) ((S) == FRAME_SUSPENDED || (S) == FRAME_SUSPENDED_YIELD_FROM)
|
2023-11-09 10:27:20 +00:00
|
|
|
#define FRAME_STATE_FINISHED(S) ((S) >= FRAME_COMPLETED)
|
2023-11-03 10:01:36 +00:00
|
|
|
|
2021-05-21 10:57:35 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#endif /* !Py_INTERNAL_FRAME_H */
|