From 2d0876e7d671a0a1d414e80df5a16239946b2936 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Thu, 15 Dec 2022 12:41:13 -0700 Subject: [PATCH] Move it to _PyRuntime.parser. --- Include/internal/pycore_global_objects.h | 3 --- Include/internal/pycore_parser.h | 23 ++++++++++++----------- Include/internal/pycore_runtime_init.h | 2 +- Parser/action_helpers.c | 3 +-- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Include/internal/pycore_global_objects.h b/Include/internal/pycore_global_objects.h index 218b1e49d7defe..d0461fa7e82e8b 100644 --- a/Include/internal/pycore_global_objects.h +++ b/Include/internal/pycore_global_objects.h @@ -8,7 +8,6 @@ extern "C" { # error "this header requires Py_BUILD_CORE define" #endif -#include "pycore_ast.h" // struct _expr #include "pycore_gc.h" // PyGC_Head #include "pycore_global_strings.h" // struct _Py_global_strings #include "pycore_hamt.h" // PyHamtNode_Bitmap @@ -61,8 +60,6 @@ struct _Py_static_objects { _PyGC_Head_UNUSED _hamt_bitmap_node_empty_gc_not_used; PyHamtNode_Bitmap hamt_bitmap_node_empty; _PyContextTokenMissing context_token_missing; - - struct _expr parser_dummy_name; } singletons; }; diff --git a/Include/internal/pycore_parser.h b/Include/internal/pycore_parser.h index 1624f38d28bb0f..dd51b92801aebf 100644 --- a/Include/internal/pycore_parser.h +++ b/Include/internal/pycore_parser.h @@ -9,7 +9,7 @@ extern "C" { #endif -#include "pycore_ast.h" // Name_kind +#include "pycore_ast.h" // struct _expr #include "pycore_global_strings.h" // _Py_DECLARE_STR() #include "pycore_pyarena.h" // PyArena @@ -24,20 +24,21 @@ struct _parser_runtime_state { #else int _not_used; #endif + struct _expr dummy_name; }; - _Py_DECLARE_STR(empty, "") - -#define _Py_parser_dummy_name_INIT \ +#define _parser_runtime_state_INIT \ { \ - .kind = Name_kind, \ - .v.Name.id = &_Py_STR(empty), \ - .v.Name.ctx = Load, \ - .lineno = 1, \ - .col_offset = 0, \ - .end_lineno = 1, \ - .end_col_offset = 0, \ + .dummy_name = { \ + .kind = Name_kind, \ + .v.Name.id = &_Py_STR(empty), \ + .v.Name.ctx = Load, \ + .lineno = 1, \ + .col_offset = 0, \ + .end_lineno = 1, \ + .end_col_offset = 0, \ + }, \ } extern struct _mod* _PyParser_ASTFromString( diff --git a/Include/internal/pycore_runtime_init.h b/Include/internal/pycore_runtime_init.h index 52a5a80f8920e2..cb3fce3732c79b 100644 --- a/Include/internal/pycore_runtime_init.h +++ b/Include/internal/pycore_runtime_init.h @@ -33,6 +33,7 @@ extern "C" { until _PyInterpreterState_Enable() is called. */ \ .next_id = -1, \ }, \ + .parser = _parser_runtime_state_INIT, \ .imports = { \ .lock = { \ .mutex = NULL, \ @@ -91,7 +92,6 @@ extern "C" { .context_token_missing = { \ .ob_base = _PyObject_IMMORTAL_INIT(&_PyContextTokenMissing_Type), \ }, \ - .parser_dummy_name = _Py_parser_dummy_name_INIT, \ }, \ }, \ ._main_interpreter = _PyInterpreterState_INIT, \ diff --git a/Parser/action_helpers.c b/Parser/action_helpers.c index 16572703876751..46390966892d16 100644 --- a/Parser/action_helpers.c +++ b/Parser/action_helpers.c @@ -3,12 +3,11 @@ #include "pegen.h" #include "string_parser.h" #include "pycore_runtime.h" // _PyRuntime -#include "pycore_global_objects.h" // _Py_SINGLETON() void * _PyPegen_dummy_name(Parser *p, ...) { - return &_Py_SINGLETON(parser_dummy_name); + return &_PyRuntime.parser.dummy_name; } /* Creates a single-element asdl_seq* that contains a */