diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2024-04-02 10:34:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-02 10:34:49 (GMT) |
commit | 1d5479b236e9a66dd32a24eff6fb83e3242b999d (patch) | |
tree | 58952ccbc1825b1b7a3004a5971bd4a9a23b2dca /Include/internal | |
parent | 5fd1897ec51cb64ef7990ada538fcd8d9ca1f74b (diff) | |
download | cpython-1d5479b236e9a66dd32a24eff6fb83e3242b999d.zip cpython-1d5479b236e9a66dd32a24eff6fb83e3242b999d.tar.gz cpython-1d5479b236e9a66dd32a24eff6fb83e3242b999d.tar.bz2 |
gh-117411: move PyFutureFeatures to pycore_symtable.h and make it private (#117412)
Diffstat (limited to 'Include/internal')
-rw-r--r-- | Include/internal/pycore_compile.h | 8 | ||||
-rw-r--r-- | Include/internal/pycore_flowgraph.h | 2 | ||||
-rw-r--r-- | Include/internal/pycore_symtable.h | 29 |
3 files changed, 32 insertions, 7 deletions
diff --git a/Include/internal/pycore_compile.h b/Include/internal/pycore_compile.h index f54f4f7..eb6e5ca 100644 --- a/Include/internal/pycore_compile.h +++ b/Include/internal/pycore_compile.h @@ -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 { diff --git a/Include/internal/pycore_flowgraph.h b/Include/internal/pycore_flowgraph.h index 58fed46..121302a 100644 --- a/Include/internal/pycore_flowgraph.h +++ b/Include/internal/pycore_flowgraph.h @@ -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); diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index b44393b..16e89f8 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -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 } |