blob: 5eeb2ada52305a2c3b50e9132057662268c5a3db [file] [log] [blame]
Guido van Rossuma3309961993-07-28 09:05:47 +00001#ifndef Py_FRAMEOBJECT_H
2#define Py_FRAMEOBJECT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
Guido van Rossumf70e43a1991-02-19 12:39:46 +00007/***********************************************************
Guido van Rossum9bfef441993-03-29 10:43:31 +00008Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
9Amsterdam, The Netherlands.
Guido van Rossumf70e43a1991-02-19 12:39:46 +000010
11 All Rights Reserved
12
13Permission to use, copy, modify, and distribute this software and its
14documentation for any purpose and without fee is hereby granted,
15provided that the above copyright notice appear in all copies and that
16both that copyright notice and this permission notice appear in
17supporting documentation, and that the names of Stichting Mathematisch
18Centrum or CWI not be used in advertising or publicity pertaining to
19distribution of the software without specific, written prior permission.
20
21STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
22THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
23FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
24FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
25WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
26ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
27OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28
29******************************************************************/
30
Guido van Rossum3f5da241990-12-20 15:06:42 +000031/* Frame object interface */
32
33typedef 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
39typedef struct _frame {
40 OB_HEAD
41 struct _frame *f_back; /* previous frame, or NULL */
42 codeobject *f_code; /* code segment */
43 object *f_globals; /* global symbol table (dictobject) */
44 object *f_locals; /* local symbol table (dictobject) */
Guido van Rossumeb6b33a1993-05-25 09:38:27 +000045 object *f_owner; /* owner (e.g. class or module) or NULL */
Guido van Rossum8b17d6b1993-03-30 13:18:41 +000046 object *f_fastlocals; /* fast local variables (listobject) */
47 object *f_localmap; /* local variable names (dictobject) */
Guido van Rossum3f5da241990-12-20 15:06:42 +000048 object **f_valuestack; /* malloc'ed array */
49 block *f_blockstack; /* malloc'ed array */
50 int f_nvalues; /* size of f_valuestack */
51 int f_nblocks; /* size of f_blockstack */
52 int f_iblock; /* index in f_blockstack */
Guido van Rossum088bc2a1992-01-14 18:32:11 +000053 int f_lasti; /* Last instruction if called */
54 int f_lineno; /* Current line number */
Guido van Rossum3f5da241990-12-20 15:06:42 +000055} frameobject;
56
57
58/* Standard object interface */
59
60extern typeobject Frametype;
61
62#define is_frameobject(op) ((op)->ob_type == &Frametype)
63
64frameobject * newframeobject PROTO(
Guido van Rossum81daa321993-05-20 14:24:46 +000065 (frameobject *, codeobject *, object *, object *, object *, int, int));
Guido van Rossum3f5da241990-12-20 15:06:42 +000066
67
68/* The rest of the interface is specific for frame objects */
69
70/* List access macros */
71
72#ifdef NDEBUG
73#define GETITEM(v, i) GETLISTITEM((listobject *)(v), (i))
74#define GETITEMNAME(v, i) GETSTRINGVALUE((stringobject *)GETITEM((v), (i)))
75#else
76#define GETITEM(v, i) getlistitem((v), (i))
77#define GETITEMNAME(v, i) getstringvalue(getlistitem((v), (i)))
78#endif
79
80#define GETUSTRINGVALUE(s) ((unsigned char *)GETSTRINGVALUE(s))
81
82/* Code access macros */
83
84#define Getconst(f, i) (GETITEM((f)->f_code->co_consts, (i)))
85#define Getname(f, i) (GETITEMNAME((f)->f_code->co_names, (i)))
Guido van Rossumd594c911991-04-03 19:03:22 +000086#define Getnamev(f, i) (GETITEM((f)->f_code->co_names, (i)))
Guido van Rossum3f5da241990-12-20 15:06:42 +000087
88
89/* Block management functions */
90
91void setup_block PROTO((frameobject *, int, int, int));
92block *pop_block PROTO((frameobject *));
Guido van Rossuma9e7dc11992-10-18 18:53:57 +000093
94/* Extend the value stack */
95
96object **extend_stack PROTO((frameobject *, int, int));
Guido van Rossuma3309961993-07-28 09:05:47 +000097
98#ifdef __cplusplus
99}
100#endif
101#endif /* !Py_FRAMEOBJECT_H */