|
| 1 | +/* Frame object interface */ |
| 2 | + |
| 3 | +typedef struct { |
| 4 | + int b_type; /* what kind of block this is */ |
| 5 | + int b_handler; /* where to jump to find handler */ |
| 6 | + int b_level; /* value stack level to pop to */ |
| 7 | +} block; |
| 8 | + |
| 9 | +typedef struct _frame { |
| 10 | + OB_HEAD |
| 11 | + struct _frame *f_back; /* previous frame, or NULL */ |
| 12 | + codeobject *f_code; /* code segment */ |
| 13 | + object *f_globals; /* global symbol table (dictobject) */ |
| 14 | + object *f_locals; /* local symbol table (dictobject) */ |
| 15 | + object **f_valuestack; /* malloc'ed array */ |
| 16 | + block *f_blockstack; /* malloc'ed array */ |
| 17 | + int f_nvalues; /* size of f_valuestack */ |
| 18 | + int f_nblocks; /* size of f_blockstack */ |
| 19 | + int f_iblock; /* index in f_blockstack */ |
| 20 | +} frameobject; |
| 21 | + |
| 22 | + |
| 23 | +/* Standard object interface */ |
| 24 | + |
| 25 | +extern typeobject Frametype; |
| 26 | + |
| 27 | +#define is_frameobject(op) ((op)->ob_type == &Frametype) |
| 28 | + |
| 29 | +frameobject * newframeobject PROTO( |
| 30 | + (frameobject *, codeobject *, object *, object *, int, int)); |
| 31 | + |
| 32 | + |
| 33 | +/* The rest of the interface is specific for frame objects */ |
| 34 | + |
| 35 | +/* List access macros */ |
| 36 | + |
| 37 | +#ifdef NDEBUG |
| 38 | +#define GETITEM(v, i) GETLISTITEM((listobject *)(v), (i)) |
| 39 | +#define GETITEMNAME(v, i) GETSTRINGVALUE((stringobject *)GETITEM((v), (i))) |
| 40 | +#else |
| 41 | +#define GETITEM(v, i) getlistitem((v), (i)) |
| 42 | +#define GETITEMNAME(v, i) getstringvalue(getlistitem((v), (i))) |
| 43 | +#endif |
| 44 | + |
| 45 | +#define GETUSTRINGVALUE(s) ((unsigned char *)GETSTRINGVALUE(s)) |
| 46 | + |
| 47 | +/* Code access macros */ |
| 48 | + |
| 49 | +#define Getconst(f, i) (GETITEM((f)->f_code->co_consts, (i))) |
| 50 | +#define Getname(f, i) (GETITEMNAME((f)->f_code->co_names, (i))) |
| 51 | + |
| 52 | + |
| 53 | +/* Block management functions */ |
| 54 | + |
| 55 | +void setup_block PROTO((frameobject *, int, int, int)); |
| 56 | +block *pop_block PROTO((frameobject *)); |
0 commit comments