cpython/Include/internal/pycore_symtable.h

#ifndef Py_INTERNAL_SYMTABLE_H
#define Py_INTERNAL_SYMTABLE_H
#ifdef __cplusplus
extern "C" {
#endif

#ifndef Py_BUILD_CORE
#  error "this header requires Py_BUILD_CORE define"
#endif

struct _mod;   // Type defined in pycore_ast.h

_Py_block_ty;

_Py_comprehension_ty;

/* source location information */
_Py_SourceLocation;

#define SRC_LOCATION_FROM_AST(n)

static const _Py_SourceLocation NO_LOCATION =;

/* __future__ information */
_PyFutureFeatures;

struct _symtable_entry;

struct symtable {};

PySTEntryObject;

extern PyTypeObject PySTEntry_Type;

#define PySTEntry_Check(op)

extern long _PyST_GetSymbol(PySTEntryObject *, PyObject *);
extern int _PyST_GetScope(PySTEntryObject *, PyObject *);
extern int _PyST_IsFunctionLike(PySTEntryObject *);

extern struct symtable* _PySymtable_Build(
    struct _mod *mod,
    PyObject *filename,
    _PyFutureFeatures *future);
extern PySTEntryObject* _PySymtable_Lookup(struct symtable *, void *);
extern int _PySymtable_LookupOptional(struct symtable *, void *, PySTEntryObject **);

extern void _PySymtable_Free(struct symtable *);

extern PyObject *_Py_MaybeMangle(PyObject *privateobj, PySTEntryObject *ste, PyObject *name);
extern PyObject* _Py_Mangle(PyObject *p, PyObject *name);

/* Flags for def-use information */

#define DEF_GLOBAL
#define DEF_LOCAL
#define DEF_PARAM
#define DEF_NONLOCAL
#define USE
#define DEF_FREE_CLASS
#define DEF_IMPORT
#define DEF_ANNOT
#define DEF_COMP_ITER
#define DEF_TYPE_PARAM
#define DEF_COMP_CELL

#define DEF_BOUND

/* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol
   table.  GLOBAL is returned from _PyST_GetScope() for either of them.
   It is stored in ste_symbols at bits 13-16.
*/
#define SCOPE_OFFSET
#define SCOPE_MASK
#define SYMBOL_TO_SCOPE(S)

#define LOCAL
#define GLOBAL_EXPLICIT
#define GLOBAL_IMPLICIT
#define FREE
#define CELL

// Used by symtablemodule.c
extern struct symtable* _Py_SymtableStringObjectFlags(
    const char *str,
    PyObject *filename,
    int start,
    PyCompilerFlags *flags);

int _PyFuture_FromAST(
    struct _mod * mod,
    PyObject *filename,
    _PyFutureFeatures* futures);

#ifdef __cplusplus
}
#endif
#endif /* !Py_INTERNAL_SYMTABLE_H */