File tree Expand file tree Collapse file tree 4 files changed +25
-11
lines changed Expand file tree Collapse file tree 4 files changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,31 @@ extern "C" {
88# error "this header requires Py_BUILD_CORE define"
99#endif
1010
11+
12+ #include "pycore_pyarena.h" // PyArena
13+
14+
15+ #ifdef Py_DEBUG
16+ #define _PYPEGEN_NSTATISTICS 2000
17+ #endif
18+
19+ struct _parser_runtime_state {
20+ #ifdef Py_DEBUG
21+ long memo_statistics [_PYPEGEN_NSTATISTICS ];
22+ #else
23+ int _not_used ;
24+ #endif
25+ };
26+
27+
28+
1129extern struct _mod * _PyParser_ASTFromString (
1230 const char * str ,
1331 PyObject * filename ,
1432 int mode ,
1533 PyCompilerFlags * flags ,
1634 PyArena * arena );
35+
1736extern struct _mod * _PyParser_ASTFromFile (
1837 FILE * fp ,
1938 PyObject * filename_ob ,
@@ -25,6 +44,7 @@ extern struct _mod* _PyParser_ASTFromFile(
2544 int * errcode ,
2645 PyArena * arena );
2746
47+
2848#ifdef __cplusplus
2949}
3050#endif
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ extern "C" {
1717#include "pycore_global_objects.h" // struct _Py_global_objects
1818#include "pycore_import.h" // struct _import_runtime_state
1919#include "pycore_interp.h" // PyInterpreterState
20+ #include "pycore_parser.h" // struct _parser_runtime_state
2021#include "pycore_pymem.h" // struct _pymem_allocators
2122#include "pycore_pyhash.h" // struct pyhash_runtime_state
2223#include "pycore_obmalloc.h" // struct obmalloc_state
@@ -131,6 +132,8 @@ typedef struct pyruntimestate {
131132
132133 PyWideStringList orig_argv ;
133134
135+ struct _parser_runtime_state parser ;
136+
134137#define NEXITFUNCS 32
135138 void (* exitfuncs [NEXITFUNCS ])(void );
136139 int nexitfuncs ;
Original file line number Diff line number Diff line change @@ -246,8 +246,8 @@ _PyPegen_fill_token(Parser *p)
246246// The array counts the number of tokens skipped by memoization,
247247// indexed by type.
248248
249- #define NSTATISTICS 2000
250- static long memo_statistics [ NSTATISTICS ];
249+ #define NSTATISTICS _PYPEGEN_NSTATISTICS
250+ #define memo_statistics _PyRuntime.parser. memo_statistics
251251
252252void
253253_PyPegen_clear_memo_statistics ()
Original file line number Diff line number Diff line change @@ -141,15 +141,6 @@ Python/pylifecycle.c - runtime_initialized -
141141Modules/syslogmodule.c - S_ident_o -
142142Modules/syslogmodule.c - S_log_open -
143143
144- # #-----------------------
145- # # *not* tied to init/fini cycle
146-
147- # These do not ge reset with each init/fini cycle.
148- # XXX These should probably be tied to init/fini. Move to _PyRuntimeState?
149-
150- # special-use diagnistic state
151- Parser/pegen.c - memo_statistics -
152-
153144# #-----------------------
154145# # one-off temporary state
155146
You can’t perform that action at this time.
0 commit comments