Chris@87: Chris@87: /* Frame object interface */ Chris@87: Chris@87: #ifndef Py_FRAMEOBJECT_H Chris@87: #define Py_FRAMEOBJECT_H Chris@87: #ifdef __cplusplus Chris@87: extern "C" { Chris@87: #endif Chris@87: Chris@87: typedef struct { Chris@87: int b_type; /* what kind of block this is */ Chris@87: int b_handler; /* where to jump to find handler */ Chris@87: int b_level; /* value stack level to pop to */ Chris@87: } PyTryBlock; Chris@87: Chris@87: typedef struct _frame { Chris@87: PyObject_VAR_HEAD Chris@87: struct _frame *f_back; /* previous frame, or NULL */ Chris@87: PyCodeObject *f_code; /* code segment */ Chris@87: PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ Chris@87: PyObject *f_globals; /* global symbol table (PyDictObject) */ Chris@87: PyObject *f_locals; /* local symbol table (any mapping) */ Chris@87: PyObject **f_valuestack; /* points after the last local */ Chris@87: /* Next free slot in f_valuestack. Frame creation sets to f_valuestack. Chris@87: Frame evaluation usually NULLs it, but a frame that yields sets it Chris@87: to the current stack top. */ Chris@87: PyObject **f_stacktop; Chris@87: PyObject *f_trace; /* Trace function */ Chris@87: Chris@87: /* If an exception is raised in this frame, the next three are used to Chris@87: * record the exception info (if any) originally in the thread state. See Chris@87: * comments before set_exc_info() -- it's not obvious. Chris@87: * Invariant: if _type is NULL, then so are _value and _traceback. Chris@87: * Desired invariant: all three are NULL, or all three are non-NULL. That Chris@87: * one isn't currently true, but "should be". Chris@87: */ Chris@87: PyObject *f_exc_type, *f_exc_value, *f_exc_traceback; Chris@87: Chris@87: PyThreadState *f_tstate; Chris@87: int f_lasti; /* Last instruction if called */ Chris@87: /* Call PyFrame_GetLineNumber() instead of reading this field Chris@87: directly. As of 2.3 f_lineno is only valid when tracing is Chris@87: active (i.e. when f_trace is set). At other times we use Chris@87: PyCode_Addr2Line to calculate the line from the current Chris@87: bytecode index. */ Chris@87: int f_lineno; /* Current line number */ Chris@87: int f_iblock; /* index in f_blockstack */ Chris@87: PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ Chris@87: PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ Chris@87: } PyFrameObject; Chris@87: Chris@87: Chris@87: /* Standard object interface */ Chris@87: Chris@87: PyAPI_DATA(PyTypeObject) PyFrame_Type; Chris@87: Chris@87: #define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type) Chris@87: #define PyFrame_IsRestricted(f) \ Chris@87: ((f)->f_builtins != (f)->f_tstate->interp->builtins) Chris@87: Chris@87: PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, Chris@87: PyObject *, PyObject *); Chris@87: Chris@87: Chris@87: /* The rest of the interface is specific for frame objects */ Chris@87: Chris@87: /* Block management functions */ Chris@87: Chris@87: PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int); Chris@87: PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *); Chris@87: Chris@87: /* Extend the value stack */ Chris@87: Chris@87: PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int); Chris@87: Chris@87: /* Conversions between "fast locals" and locals in dictionary */ Chris@87: Chris@87: PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int); Chris@87: PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *); Chris@87: Chris@87: PyAPI_FUNC(int) PyFrame_ClearFreeList(void); Chris@87: Chris@87: /* Return the line of code the frame is currently executing. */ Chris@87: PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *); Chris@87: Chris@87: #ifdef __cplusplus Chris@87: } Chris@87: #endif Chris@87: #endif /* !Py_FRAMEOBJECT_H */