| Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 1 |  | 
| Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 2 | /* Frame object interface */ | 
 | 3 |  | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 4 | #ifndef Py_FRAMEOBJECT_H | 
 | 5 | #define Py_FRAMEOBJECT_H | 
 | 6 | #ifdef __cplusplus | 
 | 7 | extern "C" { | 
 | 8 | #endif | 
 | 9 |  | 
| Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 10 | typedef struct { | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 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 */ | 
| Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 14 | } PyTryBlock; | 
| Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 15 |  | 
 | 16 | typedef struct _frame { | 
| Neil Schemenauer | 251ead8 | 2001-08-29 23:45:25 +0000 | [diff] [blame] | 17 |     PyObject_VAR_HEAD | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 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) */ | 
| Raymond Hettinger | 214b1c3 | 2004-07-02 06:41:07 +0000 | [diff] [blame] | 22 |     PyObject *f_locals;		/* local symbol table (any mapping) */ | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 23 |     PyObject **f_valuestack;	/* points after the last local */ | 
| Tim Peters | 8c96369 | 2001-06-23 05:26:56 +0000 | [diff] [blame] | 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; | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 28 |     PyObject *f_trace;		/* Trace function */ | 
| Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 29 |  | 
 | 30 |     /* If an exception is raised in this frame, the next three are used to | 
 | 31 |      * record the exception info (if any) originally in the thread state.  See | 
 | 32 |      * comments before set_exc_info() -- it's not obvious. | 
 | 33 |      * Invariant:  if _type is NULL, then so are _value and _traceback. | 
 | 34 |      * Desired invariant:  all three are NULL, or all three are non-NULL.  That | 
 | 35 |      * one isn't currently true, but "should be". | 
 | 36 |      */ | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 37 |     PyObject *f_exc_type, *f_exc_value, *f_exc_traceback; | 
| Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 38 |  | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 39 |     PyThreadState *f_tstate; | 
 | 40 |     int f_lasti;		/* Last instruction if called */ | 
| Michael W. Hudson | 02ff6a9 | 2002-09-11 15:36:32 +0000 | [diff] [blame] | 41 |     /* As of 2.3 f_lineno is only valid when tracing is active (i.e. when | 
 | 42 |        f_trace is set) -- at other times use PyCode_Addr2Line instead. */ | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 43 |     int f_lineno;		/* Current line number */ | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 44 |     int f_iblock;		/* index in f_blockstack */ | 
 | 45 |     PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 46 |     PyObject *f_localsplus[1];	/* locals+stack, dynamically sized */ | 
| Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 47 | } PyFrameObject; | 
| Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 48 |  | 
 | 49 |  | 
 | 50 | /* Standard object interface */ | 
 | 51 |  | 
| Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 52 | PyAPI_DATA(PyTypeObject) PyFrame_Type; | 
| Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 53 |  | 
| Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 54 | #define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type) | 
| Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 55 | #define PyFrame_IsRestricted(f) \ | 
 | 56 | 	((f)->f_builtins != (f)->f_tstate->interp->builtins) | 
| Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 57 |  | 
| Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 58 | PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, | 
| Jeremy Hylton | 30c9f39 | 2001-03-13 01:58:22 +0000 | [diff] [blame] | 59 |                                        PyObject *, PyObject *); | 
| Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 60 |  | 
 | 61 |  | 
 | 62 | /* The rest of the interface is specific for frame objects */ | 
 | 63 |  | 
| Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 64 | /* Block management functions */ | 
 | 65 |  | 
| Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 66 | PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int); | 
 | 67 | PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *); | 
| Guido van Rossum | a9e7dc1 | 1992-10-18 18:53:57 +0000 | [diff] [blame] | 68 |  | 
 | 69 | /* Extend the value stack */ | 
 | 70 |  | 
| Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 71 | PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int); | 
| Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 72 |  | 
| Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 73 | /* Conversions between "fast locals" and locals in dictionary */ | 
 | 74 |  | 
| Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 75 | PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int); | 
 | 76 | PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *); | 
| Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 77 |  | 
| Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 78 | #ifdef __cplusplus | 
 | 79 | } | 
 | 80 | #endif | 
 | 81 | #endif /* !Py_FRAMEOBJECT_H */ |