File indexing completed on 2025-01-18 10:06:47
0001 #ifndef Py_INTERNAL_SYMTABLE_H
0002 #define Py_INTERNAL_SYMTABLE_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006
0007 #ifndef Py_BUILD_CORE
0008 # error "this header requires Py_BUILD_CORE define"
0009 #endif
0010
0011 struct _mod;
0012
0013 typedef enum _block_type {
0014 FunctionBlock, ClassBlock, ModuleBlock,
0015
0016
0017 AnnotationBlock,
0018
0019
0020
0021
0022 TypeVarBoundBlock, TypeAliasBlock, TypeParamBlock
0023 } _Py_block_ty;
0024
0025 typedef enum _comprehension_type {
0026 NoComprehension = 0,
0027 ListComprehension = 1,
0028 DictComprehension = 2,
0029 SetComprehension = 3,
0030 GeneratorExpression = 4 } _Py_comprehension_ty;
0031
0032 struct _symtable_entry;
0033
0034 struct symtable {
0035 PyObject *st_filename;
0036
0037 struct _symtable_entry *st_cur;
0038 struct _symtable_entry *st_top;
0039 PyObject *st_blocks;
0040
0041 PyObject *st_stack;
0042 PyObject *st_global;
0043 int st_nblocks;
0044
0045
0046 PyObject *st_private;
0047 PyFutureFeatures *st_future;
0048
0049 int recursion_depth;
0050 int recursion_limit;
0051 };
0052
0053 typedef struct _symtable_entry {
0054 PyObject_HEAD
0055 PyObject *ste_id;
0056 PyObject *ste_symbols;
0057 PyObject *ste_name;
0058 PyObject *ste_varnames;
0059 PyObject *ste_children;
0060 PyObject *ste_directives;
0061 _Py_block_ty ste_type;
0062 int ste_nested;
0063 unsigned ste_free : 1;
0064 unsigned ste_child_free : 1;
0065
0066 unsigned ste_generator : 1;
0067 unsigned ste_coroutine : 1;
0068 _Py_comprehension_ty ste_comprehension;
0069 unsigned ste_varargs : 1;
0070 unsigned ste_varkeywords : 1;
0071 unsigned ste_returns_value : 1;
0072
0073 unsigned ste_needs_class_closure : 1;
0074
0075
0076 unsigned ste_needs_classdict : 1;
0077
0078 unsigned ste_comp_inlined : 1;
0079 unsigned ste_comp_iter_target : 1;
0080 unsigned ste_can_see_class_scope : 1;
0081
0082 int ste_comp_iter_expr;
0083 int ste_lineno;
0084 int ste_col_offset;
0085 int ste_end_lineno;
0086 int ste_end_col_offset;
0087 int ste_opt_lineno;
0088 int ste_opt_col_offset;
0089 struct symtable *ste_table;
0090 PyObject *ste_mangled_names;
0091 } PySTEntryObject;
0092
0093 extern PyTypeObject PySTEntry_Type;
0094
0095 #define PySTEntry_Check(op) Py_IS_TYPE((op), &PySTEntry_Type)
0096
0097 extern long _PyST_GetSymbol(PySTEntryObject *, PyObject *);
0098 extern int _PyST_GetScope(PySTEntryObject *, PyObject *);
0099 extern int _PyST_IsFunctionLike(PySTEntryObject *);
0100
0101 extern struct symtable* _PySymtable_Build(
0102 struct _mod *mod,
0103 PyObject *filename,
0104 PyFutureFeatures *future);
0105 PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *);
0106
0107 extern void _PySymtable_Free(struct symtable *);
0108
0109 extern PyObject *_Py_MaybeMangle(PyObject *privateobj, PySTEntryObject *ste, PyObject *name);
0110 extern PyObject* _Py_Mangle(PyObject *p, PyObject *name);
0111
0112
0113
0114 #define DEF_GLOBAL 1
0115 #define DEF_LOCAL 2
0116 #define DEF_PARAM (2<<1)
0117 #define DEF_NONLOCAL (2<<2)
0118 #define USE (2<<3)
0119 #define DEF_FREE (2<<4)
0120 #define DEF_FREE_CLASS (2<<5)
0121 #define DEF_IMPORT (2<<6)
0122 #define DEF_ANNOT (2<<7)
0123 #define DEF_COMP_ITER (2<<8)
0124 #define DEF_TYPE_PARAM (2<<9)
0125 #define DEF_COMP_CELL (2<<10)
0126
0127 #define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT)
0128
0129
0130
0131
0132
0133 #define SCOPE_OFFSET 12
0134 #define SCOPE_MASK (DEF_GLOBAL | DEF_LOCAL | DEF_PARAM | DEF_NONLOCAL)
0135
0136 #define LOCAL 1
0137 #define GLOBAL_EXPLICIT 2
0138 #define GLOBAL_IMPLICIT 3
0139 #define FREE 4
0140 #define CELL 5
0141
0142 #define GENERATOR 1
0143 #define GENERATOR_EXPRESSION 2
0144
0145
0146 extern struct symtable* _Py_SymtableStringObjectFlags(
0147 const char *str,
0148 PyObject *filename,
0149 int start,
0150 PyCompilerFlags *flags);
0151
0152 int _PyFuture_FromAST(
0153 struct _mod * mod,
0154 PyObject *filename,
0155 PyFutureFeatures* futures);
0156
0157 #ifdef __cplusplus
0158 }
0159 #endif
0160 #endif