| 1 |
#ifndef Py_SYMTABLE_H |
| 2 |
#define Py_SYMTABLE_H |
| 3 |
|
| 4 |
#ifdef __cplusplus |
| 5 |
extern "C" { |
| 6 |
#endif |
| 7 |
|
| 8 |
typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock } |
| 9 |
_Py_block_ty; |
| 10 |
|
| 11 |
struct _symtable_entry; |
| 12 |
|
| 13 |
struct symtable { |
| 14 |
const char *st_filename; |
| 15 |
struct _symtable_entry *st_cur; |
| 16 |
struct _symtable_entry *st_top; |
| 17 |
PyObject *st_symbols; |
| 18 |
PyObject *st_stack; |
| 19 |
PyObject *st_global; |
| 20 |
int st_nblocks; |
| 21 |
PyObject *st_private; |
| 22 |
PyFutureFeatures *st_future; |
| 23 |
}; |
| 24 |
|
| 25 |
typedef struct _symtable_entry { |
| 26 |
PyObject_HEAD |
| 27 |
PyObject *ste_id; |
| 28 |
PyObject *ste_symbols; |
| 29 |
PyObject *ste_name; |
| 30 |
PyObject *ste_varnames; |
| 31 |
PyObject *ste_children; |
| 32 |
_Py_block_ty ste_type; |
| 33 |
int ste_unoptimized; |
| 34 |
int ste_nested; |
| 35 |
unsigned ste_free : 1; |
| 36 |
unsigned ste_child_free : 1; |
| 37 |
|
| 38 |
unsigned ste_generator : 1; |
| 39 |
unsigned ste_varargs : 1; |
| 40 |
unsigned ste_varkeywords : 1; |
| 41 |
unsigned ste_returns_value : 1; |
| 42 |
|
| 43 |
int ste_lineno; |
| 44 |
int ste_opt_lineno; |
| 45 |
int ste_tmpname; |
| 46 |
struct symtable *ste_table; |
| 47 |
} PySTEntryObject; |
| 48 |
|
| 49 |
PyAPI_DATA(PyTypeObject) PySTEntry_Type; |
| 50 |
|
| 51 |
#define PySTEntry_Check(op) (Py_TYPE(op) == &PySTEntry_Type) |
| 52 |
|
| 53 |
PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *); |
| 54 |
|
| 55 |
PyAPI_FUNC(struct symtable *) PySymtable_Build(mod_ty, const char *, |
| 56 |
PyFutureFeatures *); |
| 57 |
PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *); |
| 58 |
|
| 59 |
PyAPI_FUNC(void) PySymtable_Free(struct symtable *); |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
#define DEF_GLOBAL 1 |
| 64 |
#define DEF_LOCAL 2 |
| 65 |
#define DEF_PARAM 2<<1 |
| 66 |
#define USE 2<<2 |
| 67 |
#define DEF_FREE 2<<3 |
| 68 |
#define DEF_FREE_CLASS 2<<4 |
| 69 |
#define DEF_IMPORT 2<<5 |
| 70 |
|
| 71 |
#define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT) |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
#define SCOPE_OFF 11 |
| 78 |
#define SCOPE_MASK 7 |
| 79 |
|
| 80 |
#define LOCAL 1 |
| 81 |
#define GLOBAL_EXPLICIT 2 |
| 82 |
#define GLOBAL_IMPLICIT 3 |
| 83 |
#define FREE 4 |
| 84 |
#define CELL 5 |
| 85 |
|
| 86 |
|
| 87 |
#define OPT_IMPORT_STAR 1 |
| 88 |
#define OPT_EXEC 2 |
| 89 |
#define OPT_BARE_EXEC 4 |
| 90 |
#define OPT_TOPLEVEL 8 |
| 91 |
|
| 92 |
#define GENERATOR 1 |
| 93 |
#define GENERATOR_EXPRESSION 2 |
| 94 |
|
| 95 |
#ifdef __cplusplus |
| 96 |
} |
| 97 |
#endif |
| 98 |
#endif |