| 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; /* name of file being compiled */
|
|---|
| 15 | struct _symtable_entry *st_cur; /* current symbol table entry */
|
|---|
| 16 | struct _symtable_entry *st_top; /* module entry */
|
|---|
| 17 | PyObject *st_symbols; /* dictionary of symbol table entries */
|
|---|
| 18 | PyObject *st_stack; /* stack of namespace info */
|
|---|
| 19 | PyObject *st_global; /* borrowed ref to MODULE in st_symbols */
|
|---|
| 20 | int st_nblocks; /* number of blocks */
|
|---|
| 21 | PyObject *st_private; /* name of current class or NULL */
|
|---|
| 22 | int st_tmpname; /* temporary name counter */
|
|---|
| 23 | PyFutureFeatures *st_future; /* module's future features */
|
|---|
| 24 | };
|
|---|
| 25 |
|
|---|
| 26 | typedef struct _symtable_entry {
|
|---|
| 27 | PyObject_HEAD
|
|---|
| 28 | PyObject *ste_id; /* int: key in st_symbols */
|
|---|
| 29 | PyObject *ste_symbols; /* dict: name to flags */
|
|---|
| 30 | PyObject *ste_name; /* string: name of block */
|
|---|
| 31 | PyObject *ste_varnames; /* list of variable names */
|
|---|
| 32 | PyObject *ste_children; /* list of child ids */
|
|---|
| 33 | _Py_block_ty ste_type; /* module, class, or function */
|
|---|
| 34 | int ste_unoptimized; /* false if namespace is optimized */
|
|---|
| 35 | unsigned ste_nested : 1; /* true if block is nested */
|
|---|
| 36 | unsigned ste_free : 1; /* true if block has free variables */
|
|---|
| 37 | unsigned ste_child_free : 1; /* true if a child block has free vars,
|
|---|
|
|---|