mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-117411: move PyFutureFeatures to pycore_symtable.h and make it private (#117412)
This commit is contained in:
parent
5fd1897ec5
commit
1d5479b236
11 changed files with 49 additions and 42 deletions
|
|
@ -32,28 +32,8 @@ typedef struct {
|
|||
#define _PyCompilerFlags_INIT \
|
||||
(PyCompilerFlags){.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION}
|
||||
|
||||
/* source location information */
|
||||
typedef struct {
|
||||
int lineno;
|
||||
int end_lineno;
|
||||
int col_offset;
|
||||
int end_col_offset;
|
||||
} _PyCompilerSrcLocation;
|
||||
|
||||
#define SRC_LOCATION_FROM_AST(n) \
|
||||
(_PyCompilerSrcLocation){ \
|
||||
.lineno = (n)->lineno, \
|
||||
.end_lineno = (n)->end_lineno, \
|
||||
.col_offset = (n)->col_offset, \
|
||||
.end_col_offset = (n)->end_col_offset }
|
||||
|
||||
/* Future feature support */
|
||||
|
||||
typedef struct {
|
||||
int ff_features; /* flags set by future statements */
|
||||
_PyCompilerSrcLocation ff_location; /* location of last future statement */
|
||||
} PyFutureFeatures;
|
||||
|
||||
#define FUTURE_NESTED_SCOPES "nested_scopes"
|
||||
#define FUTURE_GENERATORS "generators"
|
||||
#define FUTURE_DIVISION "division"
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ extern "C" {
|
|||
# error "this header requires Py_BUILD_CORE define"
|
||||
#endif
|
||||
|
||||
#include "pycore_symtable.h" // _Py_SourceLocation
|
||||
|
||||
struct _arena; // Type defined in pycore_pyarena.h
|
||||
struct _mod; // Type defined in pycore_ast.h
|
||||
|
||||
|
|
@ -27,7 +29,7 @@ extern int _PyCompile_AstOptimize(
|
|||
int optimize,
|
||||
struct _arena *arena);
|
||||
|
||||
static const _PyCompilerSrcLocation NO_LOCATION = {-1, -1, -1, -1};
|
||||
struct _Py_SourceLocation;
|
||||
|
||||
extern int _PyAST_Optimize(
|
||||
struct _mod *,
|
||||
|
|
@ -44,7 +46,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
int i_opcode;
|
||||
int i_oparg;
|
||||
_PyCompilerSrcLocation i_loc;
|
||||
_Py_SourceLocation i_loc;
|
||||
_PyCompile_ExceptHandlerInfo i_except_handler_info;
|
||||
|
||||
/* Used by the assembler */
|
||||
|
|
@ -65,7 +67,7 @@ typedef struct {
|
|||
int _PyCompile_InstructionSequence_UseLabel(_PyCompile_InstructionSequence *seq, int lbl);
|
||||
int _PyCompile_InstructionSequence_Addop(_PyCompile_InstructionSequence *seq,
|
||||
int opcode, int oparg,
|
||||
_PyCompilerSrcLocation loc);
|
||||
_Py_SourceLocation loc);
|
||||
int _PyCompile_InstructionSequence_ApplyLabelMap(_PyCompile_InstructionSequence *seq);
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ typedef struct {
|
|||
struct _PyCfgBuilder;
|
||||
|
||||
int _PyCfgBuilder_UseLabel(struct _PyCfgBuilder *g, _PyCfgJumpTargetLabel lbl);
|
||||
int _PyCfgBuilder_Addop(struct _PyCfgBuilder *g, int opcode, int oparg, _PyCompilerSrcLocation loc);
|
||||
int _PyCfgBuilder_Addop(struct _PyCfgBuilder *g, int opcode, int oparg, _Py_SourceLocation loc);
|
||||
|
||||
struct _PyCfgBuilder* _PyCfgBuilder_New(void);
|
||||
void _PyCfgBuilder_Free(struct _PyCfgBuilder *g);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,29 @@ typedef enum _comprehension_type {
|
|||
SetComprehension = 3,
|
||||
GeneratorExpression = 4 } _Py_comprehension_ty;
|
||||
|
||||
/* source location information */
|
||||
typedef struct {
|
||||
int lineno;
|
||||
int end_lineno;
|
||||
int col_offset;
|
||||
int end_col_offset;
|
||||
} _Py_SourceLocation;
|
||||
|
||||
#define SRC_LOCATION_FROM_AST(n) \
|
||||
(_Py_SourceLocation){ \
|
||||
.lineno = (n)->lineno, \
|
||||
.end_lineno = (n)->end_lineno, \
|
||||
.col_offset = (n)->col_offset, \
|
||||
.end_col_offset = (n)->end_col_offset }
|
||||
|
||||
static const _Py_SourceLocation NO_LOCATION = {-1, -1, -1, -1};
|
||||
|
||||
/* __future__ information */
|
||||
typedef struct {
|
||||
int ff_features; /* flags set by future statements */
|
||||
_Py_SourceLocation ff_location; /* location of last future statement */
|
||||
} _PyFutureFeatures;
|
||||
|
||||
struct _symtable_entry;
|
||||
|
||||
struct symtable {
|
||||
|
|
@ -44,7 +67,7 @@ struct symtable {
|
|||
consistency with the corresponding
|
||||
compiler structure */
|
||||
PyObject *st_private; /* name of current class or NULL */
|
||||
PyFutureFeatures *st_future; /* module's future features that affect
|
||||
_PyFutureFeatures *st_future; /* module's future features that affect
|
||||
the symbol table */
|
||||
int recursion_depth; /* current recursion depth */
|
||||
int recursion_limit; /* recursion limit */
|
||||
|
|
@ -100,7 +123,7 @@ extern int _PyST_IsFunctionLike(PySTEntryObject *);
|
|||
extern struct symtable* _PySymtable_Build(
|
||||
struct _mod *mod,
|
||||
PyObject *filename,
|
||||
PyFutureFeatures *future);
|
||||
_PyFutureFeatures *future);
|
||||
extern PySTEntryObject* _PySymtable_Lookup(struct symtable *, void *);
|
||||
|
||||
extern void _PySymtable_Free(struct symtable *);
|
||||
|
|
@ -150,7 +173,7 @@ extern struct symtable* _Py_SymtableStringObjectFlags(
|
|||
int _PyFuture_FromAST(
|
||||
struct _mod * mod,
|
||||
PyObject *filename,
|
||||
PyFutureFeatures* futures);
|
||||
_PyFutureFeatures* futures);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue