CoolFace
Apppublic

vidya7732/AI_Doctor_LLM_GenModel

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
symtable.h124 linesDownload Raw Back to include
1#ifndef Py_LIMITED_API2#ifndef Py_SYMTABLE_H3#define Py_SYMTABLE_H4#ifdef __cplusplus5extern "C" {6#endif7 8#include "Python-ast.h"   /* mod_ty */9 10/* XXX(ncoghlan): This is a weird mix of public names and interpreter internal11 *                names.12 */13 14typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock }15    _Py_block_ty;16 17struct _symtable_entry;18 19struct symtable {20    PyObject *st_filename;          /* name of file being compiled,21                                       decoded from the filesystem encoding */22    struct _symtable_entry *st_cur; /* current symbol table entry */23    struct _symtable_entry *st_top; /* symbol table entry for module */24    PyObject *st_blocks;            /* dict: map AST node addresses25                                     *       to symbol table entries */26    PyObject *st_stack;             /* list: stack of namespace info */27    PyObject *st_global;            /* borrowed ref to st_top->ste_symbols */28    int st_nblocks;                 /* number of blocks used. kept for29                                       consistency with the corresponding30                                       compiler structure */31    PyObject *st_private;           /* name of current class or NULL */32    PyFutureFeatures *st_future;    /* module's future features that affect33                                       the symbol table */34    int recursion_depth;            /* current recursion depth */35    int recursion_limit;            /* recursion limit */36};37 38typedef struct _symtable_entry {39    PyObject_HEAD40    PyObject *ste_id;        /* int: key in ste_table->st_blocks */41    PyObject *ste_symbols;   /* dict: variable names to flags */42    PyObject *ste_name;      /* string: name of current block */43    PyObject *ste_varnames;  /* list of function parameters */44    PyObject *ste_children;  /* list of child blocks */45    PyObject *ste_directives;/* locations of global and nonlocal statements */46    _Py_block_ty ste_type;   /* module, class, or function */47    int ste_nested;      /* true if block is nested */48    unsigned ste_free : 1;        /* true if block has free variables */49    unsigned ste_child_free : 1;  /* true if a child block has free vars,50                                     including free refs to globals */51    unsigned ste_generator : 1;   /* true if namespace is a generator */52    unsigned ste_coroutine : 1;   /* true if namespace is a coroutine */53    unsigned ste_comprehension : 1; /* true if namespace is a list comprehension */54    unsigned ste_varargs : 1;     /* true if block has varargs */55    unsigned ste_varkeywords : 1; /* true if block has varkeywords */56    unsigned ste_returns_value : 1;  /* true if namespace uses return with57                                        an argument */58    unsigned ste_needs_class_closure : 1; /* for class scopes, true if a59                                             closure over __class__60                                             should be created */61    unsigned ste_comp_iter_target : 1; /* true if visiting comprehension target */62    int ste_comp_iter_expr; /* non-zero if visiting a comprehension range expression */63    int ste_lineno;          /* first line of block */64    int ste_col_offset;      /* offset of first line of block */65    int ste_opt_lineno;      /* lineno of last exec or import * */66    int ste_opt_col_offset;  /* offset of last exec or import * */67    struct symtable *ste_table;68} PySTEntryObject;69 70PyAPI_DATA(PyTypeObject) PySTEntry_Type;71 72#define PySTEntry_Check(op) Py_IS_TYPE(op, &PySTEntry_Type)73 74PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *);75 76PyAPI_FUNC(struct symtable *) PySymtable_Build(77    mod_ty mod,78    const char *filename,       /* decoded from the filesystem encoding */79    PyFutureFeatures *future);80PyAPI_FUNC(struct symtable *) PySymtable_BuildObject(81    mod_ty mod,82    PyObject *filename,83    PyFutureFeatures *future);84PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *);85 86PyAPI_FUNC(void) PySymtable_Free(struct symtable *);87 88/* Flags for def-use information */89 90#define DEF_GLOBAL 1           /* global stmt */91#define DEF_LOCAL 2            /* assignment in code block */92#define DEF_PARAM 2<<1         /* formal parameter */93#define DEF_NONLOCAL 2<<2      /* nonlocal stmt */94#define USE 2<<3               /* name is used */95#define DEF_FREE 2<<4          /* name used but not defined in nested block */96#define DEF_FREE_CLASS 2<<5    /* free variable from class's method */97#define DEF_IMPORT 2<<6        /* assignment occurred via import */98#define DEF_ANNOT 2<<7         /* this name is annotated */99#define DEF_COMP_ITER 2<<8     /* this name is a comprehension iteration variable */100 101#define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT)102 103/* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol104   table.  GLOBAL is returned from PyST_GetScope() for either of them.105   It is stored in ste_symbols at bits 12-15.106*/107#define SCOPE_OFFSET 11108#define SCOPE_MASK (DEF_GLOBAL | DEF_LOCAL | DEF_PARAM | DEF_NONLOCAL)109 110#define LOCAL 1111#define GLOBAL_EXPLICIT 2112#define GLOBAL_IMPLICIT 3113#define FREE 4114#define CELL 5115 116#define GENERATOR 1117#define GENERATOR_EXPRESSION 2118 119#ifdef __cplusplus120}121#endif122#endif /* !Py_SYMTABLE_H */123#endif /* !Py_LIMITED_API */124