jpayne@69: /* Frame object interface */ jpayne@69: jpayne@69: #ifndef Py_LIMITED_API jpayne@69: #ifndef Py_FRAMEOBJECT_H jpayne@69: #define Py_FRAMEOBJECT_H jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: typedef struct { jpayne@69: int b_type; /* what kind of block this is */ jpayne@69: int b_handler; /* where to jump to find handler */ jpayne@69: int b_level; /* value stack level to pop to */ jpayne@69: } PyTryBlock; jpayne@69: jpayne@69: typedef struct _frame { jpayne@69: PyObject_VAR_HEAD jpayne@69: struct _frame *f_back; /* previous frame, or NULL */ jpayne@69: PyCodeObject *f_code; /* code segment */ jpayne@69: PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ jpayne@69: PyObject *f_globals; /* global symbol table (PyDictObject) */ jpayne@69: PyObject *f_locals; /* local symbol table (any mapping) */ jpayne@69: PyObject **f_valuestack; /* points after the last local */ jpayne@69: /* Next free slot in f_valuestack. Frame creation sets to f_valuestack. jpayne@69: Frame evaluation usually NULLs it, but a frame that yields sets it jpayne@69: to the current stack top. */ jpayne@69: PyObject **f_stacktop; jpayne@69: PyObject *f_trace; /* Trace function */ jpayne@69: char f_trace_lines; /* Emit per-line trace events? */ jpayne@69: char f_trace_opcodes; /* Emit per-opcode trace events? */ jpayne@69: jpayne@69: /* Borrowed reference to a generator, or NULL */ jpayne@69: PyObject *f_gen; jpayne@69: jpayne@69: int f_lasti; /* Last instruction if called */ jpayne@69: /* Call PyFrame_GetLineNumber() instead of reading this field jpayne@69: directly. As of 2.3 f_lineno is only valid when tracing is jpayne@69: active (i.e. when f_trace is set). At other times we use jpayne@69: PyCode_Addr2Line to calculate the line from the current jpayne@69: bytecode index. */ jpayne@69: int f_lineno; /* Current line number */ jpayne@69: int f_iblock; /* index in f_blockstack */ jpayne@69: char f_executing; /* whether the frame is still executing */ jpayne@69: PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ jpayne@69: PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ jpayne@69: } PyFrameObject; jpayne@69: jpayne@69: jpayne@69: /* Standard object interface */ jpayne@69: jpayne@69: PyAPI_DATA(PyTypeObject) PyFrame_Type; jpayne@69: jpayne@69: #define PyFrame_Check(op) (Py_TYPE(op) == &PyFrame_Type) jpayne@69: jpayne@69: PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, jpayne@69: PyObject *, PyObject *); jpayne@69: jpayne@69: /* only internal use */ jpayne@69: PyFrameObject* _PyFrame_New_NoTrack(PyThreadState *, PyCodeObject *, jpayne@69: PyObject *, PyObject *); jpayne@69: jpayne@69: jpayne@69: /* The rest of the interface is specific for frame objects */ jpayne@69: jpayne@69: /* Block management functions */ jpayne@69: jpayne@69: PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int); jpayne@69: PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *); jpayne@69: jpayne@69: /* Extend the value stack */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int); jpayne@69: jpayne@69: /* Conversions between "fast locals" and locals in dictionary */ jpayne@69: jpayne@69: PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int); jpayne@69: jpayne@69: PyAPI_FUNC(int) PyFrame_FastToLocalsWithError(PyFrameObject *f); jpayne@69: PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *); jpayne@69: jpayne@69: PyAPI_FUNC(int) PyFrame_ClearFreeList(void); jpayne@69: jpayne@69: PyAPI_FUNC(void) _PyFrame_DebugMallocStats(FILE *out); jpayne@69: jpayne@69: /* Return the line of code the frame is currently executing. */ jpayne@69: PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *); jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: #endif /* !Py_FRAMEOBJECT_H */ jpayne@69: #endif /* Py_LIMITED_API */