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" {
8
8
# error "this header requires Py_BUILD_CORE define"
9
9
#endif
10
10
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
+
11
29
extern struct _mod * _PyParser_ASTFromString (
12
30
const char * str ,
13
31
PyObject * filename ,
14
32
int mode ,
15
33
PyCompilerFlags * flags ,
16
34
PyArena * arena );
35
+
17
36
extern struct _mod * _PyParser_ASTFromFile (
18
37
FILE * fp ,
19
38
PyObject * filename_ob ,
@@ -25,6 +44,7 @@ extern struct _mod* _PyParser_ASTFromFile(
25
44
int * errcode ,
26
45
PyArena * arena );
27
46
47
+
28
48
#ifdef __cplusplus
29
49
}
30
50
#endif
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ extern "C" {
17
17
#include "pycore_global_objects.h" // struct _Py_global_objects
18
18
#include "pycore_import.h" // struct _import_runtime_state
19
19
#include "pycore_interp.h" // PyInterpreterState
20
+ #include "pycore_parser.h" // struct _parser_runtime_state
20
21
#include "pycore_pymem.h" // struct _pymem_allocators
21
22
#include "pycore_pyhash.h" // struct pyhash_runtime_state
22
23
#include "pycore_obmalloc.h" // struct obmalloc_state
@@ -131,6 +132,8 @@ typedef struct pyruntimestate {
131
132
132
133
PyWideStringList orig_argv ;
133
134
135
+ struct _parser_runtime_state parser ;
136
+
134
137
#define NEXITFUNCS 32
135
138
void (* exitfuncs [NEXITFUNCS ])(void );
136
139
int nexitfuncs ;
Original file line number Diff line number Diff line change @@ -246,8 +246,8 @@ _PyPegen_fill_token(Parser *p)
246
246
// The array counts the number of tokens skipped by memoization,
247
247
// indexed by type.
248
248
249
- #define NSTATISTICS 2000
250
- static long memo_statistics [ NSTATISTICS ];
249
+ #define NSTATISTICS _PYPEGEN_NSTATISTICS
250
+ #define memo_statistics _PyRuntime.parser. memo_statistics
251
251
252
252
void
253
253
_PyPegen_clear_memo_statistics ()
Original file line number Diff line number Diff line change @@ -141,15 +141,6 @@ Python/pylifecycle.c - runtime_initialized -
141
141
Modules/syslogmodule.c - S_ident_o -
142
142
Modules/syslogmodule.c - S_log_open -
143
143
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
-
153
144
# #-----------------------
154
145
# # one-off temporary state
155
146
You can’t perform that action at this time.
0 commit comments