Skip to content

Commit 2d0876e

Browse files
Move it to _PyRuntime.parser.
1 parent 432fa46 commit 2d0876e

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

Include/internal/pycore_global_objects.h

-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
#include "pycore_ast.h" // struct _expr
1211
#include "pycore_gc.h" // PyGC_Head
1312
#include "pycore_global_strings.h" // struct _Py_global_strings
1413
#include "pycore_hamt.h" // PyHamtNode_Bitmap
@@ -61,8 +60,6 @@ struct _Py_static_objects {
6160
_PyGC_Head_UNUSED _hamt_bitmap_node_empty_gc_not_used;
6261
PyHamtNode_Bitmap hamt_bitmap_node_empty;
6362
_PyContextTokenMissing context_token_missing;
64-
65-
struct _expr parser_dummy_name;
6663
} singletons;
6764
};
6865

Include/internal/pycore_parser.h

+12-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extern "C" {
99
#endif
1010

1111

12-
#include "pycore_ast.h" // Name_kind
12+
#include "pycore_ast.h" // struct _expr
1313
#include "pycore_global_strings.h" // _Py_DECLARE_STR()
1414
#include "pycore_pyarena.h" // PyArena
1515

@@ -24,20 +24,21 @@ struct _parser_runtime_state {
2424
#else
2525
int _not_used;
2626
#endif
27+
struct _expr dummy_name;
2728
};
2829

29-
3030
_Py_DECLARE_STR(empty, "")
31-
32-
#define _Py_parser_dummy_name_INIT \
31+
#define _parser_runtime_state_INIT \
3332
{ \
34-
.kind = Name_kind, \
35-
.v.Name.id = &_Py_STR(empty), \
36-
.v.Name.ctx = Load, \
37-
.lineno = 1, \
38-
.col_offset = 0, \
39-
.end_lineno = 1, \
40-
.end_col_offset = 0, \
33+
.dummy_name = { \
34+
.kind = Name_kind, \
35+
.v.Name.id = &_Py_STR(empty), \
36+
.v.Name.ctx = Load, \
37+
.lineno = 1, \
38+
.col_offset = 0, \
39+
.end_lineno = 1, \
40+
.end_col_offset = 0, \
41+
}, \
4142
}
4243

4344
extern struct _mod* _PyParser_ASTFromString(

Include/internal/pycore_runtime_init.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ extern "C" {
3333
until _PyInterpreterState_Enable() is called. */ \
3434
.next_id = -1, \
3535
}, \
36+
.parser = _parser_runtime_state_INIT, \
3637
.imports = { \
3738
.lock = { \
3839
.mutex = NULL, \
@@ -91,7 +92,6 @@ extern "C" {
9192
.context_token_missing = { \
9293
.ob_base = _PyObject_IMMORTAL_INIT(&_PyContextTokenMissing_Type), \
9394
}, \
94-
.parser_dummy_name = _Py_parser_dummy_name_INIT, \
9595
}, \
9696
}, \
9797
._main_interpreter = _PyInterpreterState_INIT, \

Parser/action_helpers.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
#include "pegen.h"
44
#include "string_parser.h"
55
#include "pycore_runtime.h" // _PyRuntime
6-
#include "pycore_global_objects.h" // _Py_SINGLETON()
76

87
void *
98
_PyPegen_dummy_name(Parser *p, ...)
109
{
11-
return &_Py_SINGLETON(parser_dummy_name);
10+
return &_PyRuntime.parser.dummy_name;
1211
}
1312

1413
/* Creates a single-element asdl_seq* that contains a */

0 commit comments

Comments
 (0)