Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 1 | #ifndef Py_FRAMEOBJECT_H |
| 2 | #define Py_FRAMEOBJECT_H |
| 3 | #ifdef __cplusplus |
| 4 | extern "C" { |
| 5 | #endif |
| 6 | |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 7 | /*********************************************************** |
Guido van Rossum | 5799b52 | 1995-01-04 19:06:22 +0000 | [diff] [blame] | 8 | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 9 | The Netherlands. |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 10 | |
| 11 | All Rights Reserved |
| 12 | |
| 13 | Permission to use, copy, modify, and distribute this software and its |
| 14 | documentation for any purpose and without fee is hereby granted, |
| 15 | provided that the above copyright notice appear in all copies and that |
| 16 | both that copyright notice and this permission notice appear in |
| 17 | supporting documentation, and that the names of Stichting Mathematisch |
| 18 | Centrum or CWI not be used in advertising or publicity pertaining to |
| 19 | distribution of the software without specific, written prior permission. |
| 20 | |
| 21 | STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
| 22 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 23 | FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
| 24 | FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 25 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 26 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 27 | OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 28 | |
| 29 | ******************************************************************/ |
| 30 | |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 31 | /* Frame object interface */ |
| 32 | |
| 33 | typedef struct { |
| 34 | int b_type; /* what kind of block this is */ |
| 35 | int b_handler; /* where to jump to find handler */ |
| 36 | int b_level; /* value stack level to pop to */ |
| 37 | } block; |
| 38 | |
| 39 | typedef struct _frame { |
| 40 | OB_HEAD |
| 41 | struct _frame *f_back; /* previous frame, or NULL */ |
| 42 | codeobject *f_code; /* code segment */ |
Guido van Rossum | 6135a87 | 1995-01-09 17:53:26 +0000 | [diff] [blame] | 43 | object *f_builtins; /* builtin symbol table (dictobject) */ |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 44 | object *f_globals; /* global symbol table (dictobject) */ |
| 45 | object *f_locals; /* local symbol table (dictobject) */ |
Guido van Rossum | eb6b33a | 1993-05-25 09:38:27 +0000 | [diff] [blame] | 46 | object *f_owner; /* owner (e.g. class or module) or NULL */ |
Guido van Rossum | 8b17d6b | 1993-03-30 13:18:41 +0000 | [diff] [blame] | 47 | object *f_fastlocals; /* fast local variables (listobject) */ |
| 48 | object *f_localmap; /* local variable names (dictobject) */ |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 49 | object **f_valuestack; /* malloc'ed array */ |
| 50 | block *f_blockstack; /* malloc'ed array */ |
| 51 | int f_nvalues; /* size of f_valuestack */ |
| 52 | int f_nblocks; /* size of f_blockstack */ |
| 53 | int f_iblock; /* index in f_blockstack */ |
Guido van Rossum | 088bc2a | 1992-01-14 18:32:11 +0000 | [diff] [blame] | 54 | int f_lasti; /* Last instruction if called */ |
| 55 | int f_lineno; /* Current line number */ |
Guido van Rossum | 6135a87 | 1995-01-09 17:53:26 +0000 | [diff] [blame] | 56 | int f_restricted; /* Flag set if restricted operations in this scope */ |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 57 | object *f_trace; /* Trace function */ |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 58 | } frameobject; |
| 59 | |
| 60 | |
| 61 | /* Standard object interface */ |
| 62 | |
Guido van Rossum | e89bc75 | 1994-08-18 16:18:13 +0000 | [diff] [blame] | 63 | extern DL_IMPORT typeobject Frametype; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 64 | |
| 65 | #define is_frameobject(op) ((op)->ob_type == &Frametype) |
| 66 | |
| 67 | frameobject * newframeobject PROTO( |
Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 68 | (frameobject *, codeobject *, object *, object *, object *, int, int)); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 69 | |
| 70 | |
| 71 | /* The rest of the interface is specific for frame objects */ |
| 72 | |
| 73 | /* List access macros */ |
| 74 | |
| 75 | #ifdef NDEBUG |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 76 | #define GETITEM(v, i) GETTUPLEITEM((tupleobject *)(v), (i)) |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 77 | #define GETITEMNAME(v, i) GETSTRINGVALUE((stringobject *)GETITEM((v), (i))) |
| 78 | #else |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 79 | #define GETITEM(v, i) gettupleitem((v), (i)) |
| 80 | #define GETITEMNAME(v, i) getstringvalue(GETITEM(v, i)) |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 81 | #endif |
| 82 | |
| 83 | #define GETUSTRINGVALUE(s) ((unsigned char *)GETSTRINGVALUE(s)) |
| 84 | |
| 85 | /* Code access macros */ |
| 86 | |
| 87 | #define Getconst(f, i) (GETITEM((f)->f_code->co_consts, (i))) |
| 88 | #define Getname(f, i) (GETITEMNAME((f)->f_code->co_names, (i))) |
Guido van Rossum | d594c91 | 1991-04-03 19:03:22 +0000 | [diff] [blame] | 89 | #define Getnamev(f, i) (GETITEM((f)->f_code->co_names, (i))) |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 90 | |
| 91 | |
| 92 | /* Block management functions */ |
| 93 | |
| 94 | void setup_block PROTO((frameobject *, int, int, int)); |
| 95 | block *pop_block PROTO((frameobject *)); |
Guido van Rossum | a9e7dc1 | 1992-10-18 18:53:57 +0000 | [diff] [blame] | 96 | |
| 97 | /* Extend the value stack */ |
| 98 | |
| 99 | object **extend_stack PROTO((frameobject *, int, int)); |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 100 | |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 101 | /* Conversions between "fast locals" and locals in dictionary */ |
| 102 | |
| 103 | void locals_2_fast PROTO((frameobject *, int)); |
| 104 | void fast_2_locals PROTO((frameobject *)); |
| 105 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 106 | #ifdef __cplusplus |
| 107 | } |
| 108 | #endif |
| 109 | #endif /* !Py_FRAMEOBJECT_H */ |