Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Move it to _PyRuntime.parser.
  • Loading branch information
ericsnowcurrently committed Dec 15, 2022
commit 2d0876e7d671a0a1d414e80df5a16239946b2936
3 changes: 0 additions & 3 deletions Include/internal/pycore_global_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
};

Expand Down
23 changes: 12 additions & 11 deletions Include/internal/pycore_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_runtime_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extern "C" {
until _PyInterpreterState_Enable() is called. */ \
.next_id = -1, \
}, \
.parser = _parser_runtime_state_INIT, \
.imports = { \
.lock = { \
.mutex = NULL, \
Expand Down Expand Up @@ -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, \
Expand Down
3 changes: 1 addition & 2 deletions Parser/action_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down