summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2024-04-17 15:42:04 (GMT)
committerGitHub <noreply@github.com>2024-04-17 15:42:04 (GMT)
commitc179c0e6cbb4d1e981fffd43f207f5b1aa5388e5 (patch)
tree4600115b3e61e7404b550d81a23a235d31c183fb /Include
parentae8dfd2761e4a45afe0adada0f91f371dd121bb8 (diff)
downloadcpython-c179c0e6cbb4d1e981fffd43f207f5b1aa5388e5.zip
cpython-c179c0e6cbb4d1e981fffd43f207f5b1aa5388e5.tar.gz
cpython-c179c0e6cbb4d1e981fffd43f207f5b1aa5388e5.tar.bz2
gh-117680: make _PyInstructionSequence a PyObject and use it in tests (#117629)
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_global_objects_fini_generated.h4
-rw-r--r--Include/internal/pycore_global_strings.h4
-rw-r--r--Include/internal/pycore_instruction_sequence.h16
-rw-r--r--Include/internal/pycore_runtime_init_generated.h4
-rw-r--r--Include/internal/pycore_unicodeobject_generated.h12
5 files changed, 38 insertions, 2 deletions
diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h
index 24f32fc..90a338a 100644
--- a/Include/internal/pycore_global_objects_fini_generated.h
+++ b/Include/internal/pycore_global_objects_fini_generated.h
@@ -864,6 +864,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_stacksize));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_varnames));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(code));
+ _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(col_offset));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(command));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(comment_factory));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(compile_mode));
@@ -913,6 +914,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(encode));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(encoding));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(end));
+ _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(end_col_offset));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(end_lineno));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(end_offset));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(endpos));
@@ -1033,6 +1035,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(kw1));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(kw2));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(kwdefaults));
+ _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(label));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(lambda));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(last));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(last_exc));
@@ -1096,6 +1099,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(namespaces));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(narg));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ndigits));
+ _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(nested));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(new_file_name));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(new_limit));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(newline));
diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h
index 024f817..0899e7e 100644
--- a/Include/internal/pycore_global_strings.h
+++ b/Include/internal/pycore_global_strings.h
@@ -353,6 +353,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(co_stacksize)
STRUCT_FOR_ID(co_varnames)
STRUCT_FOR_ID(code)
+ STRUCT_FOR_ID(col_offset)
STRUCT_FOR_ID(command)
STRUCT_FOR_ID(comment_factory)
STRUCT_FOR_ID(compile_mode)
@@ -402,6 +403,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(encode)
STRUCT_FOR_ID(encoding)
STRUCT_FOR_ID(end)
+ STRUCT_FOR_ID(end_col_offset)
STRUCT_FOR_ID(end_lineno)
STRUCT_FOR_ID(end_offset)
STRUCT_FOR_ID(endpos)
@@ -522,6 +524,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(kw1)
STRUCT_FOR_ID(kw2)
STRUCT_FOR_ID(kwdefaults)
+ STRUCT_FOR_ID(label)
STRUCT_FOR_ID(lambda)
STRUCT_FOR_ID(last)
STRUCT_FOR_ID(last_exc)
@@ -585,6 +588,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(namespaces)
STRUCT_FOR_ID(narg)
STRUCT_FOR_ID(ndigits)
+ STRUCT_FOR_ID(nested)
STRUCT_FOR_ID(new_file_name)
STRUCT_FOR_ID(new_limit)
STRUCT_FOR_ID(newline)
diff --git a/Include/internal/pycore_instruction_sequence.h b/Include/internal/pycore_instruction_sequence.h
index b57484f..ecba0d9 100644
--- a/Include/internal/pycore_instruction_sequence.h
+++ b/Include/internal/pycore_instruction_sequence.h
@@ -5,10 +5,13 @@
# error "this header requires Py_BUILD_CORE define"
#endif
+#include "pycore_symtable.h"
+
#ifdef __cplusplus
extern "C" {
#endif
+
typedef struct {
int h_label;
int h_startdepth;
@@ -26,23 +29,30 @@ typedef struct {
int i_offset;
} _PyInstruction;
-typedef struct {
+typedef struct instruction_sequence {
+ PyObject_HEAD
_PyInstruction *s_instrs;
int s_allocated;
int s_used;
int s_next_free_label; /* next free label id */
+
/* Map of a label id to instruction offset (index into s_instrs).
* If s_labelmap is NULL, then each label id is the offset itself.
*/
- int *s_labelmap; /* label id --> instr offset */
+ int *s_labelmap;
int s_labelmap_size;
+
+ /* PyList of instruction sequences of nested functions */
+ PyObject *s_nested;
} _PyInstructionSequence;
typedef struct {
int id;
} _PyJumpTargetLabel;
+PyAPI_FUNC(PyObject*)_PyInstructionSequence_New(void);
+
int _PyInstructionSequence_UseLabel(_PyInstructionSequence *seq, int lbl);
int _PyInstructionSequence_Addop(_PyInstructionSequence *seq,
int opcode, int oparg,
@@ -53,6 +63,8 @@ int _PyInstructionSequence_InsertInstruction(_PyInstructionSequence *seq, int po
int opcode, int oparg, _Py_SourceLocation loc);
void PyInstructionSequence_Fini(_PyInstructionSequence *seq);
+extern PyTypeObject _PyInstructionSequence_Type;
+#define _PyInstructionSequence_Check(v) Py_IS_TYPE((v), &_PyInstructionSequence_Type)
#ifdef __cplusplus
}
diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h
index 795f95c..d4323e5 100644
--- a/Include/internal/pycore_runtime_init_generated.h
+++ b/Include/internal/pycore_runtime_init_generated.h
@@ -862,6 +862,7 @@ extern "C" {
INIT_ID(co_stacksize), \
INIT_ID(co_varnames), \
INIT_ID(code), \
+ INIT_ID(col_offset), \
INIT_ID(command), \
INIT_ID(comment_factory), \
INIT_ID(compile_mode), \
@@ -911,6 +912,7 @@ extern "C" {
INIT_ID(encode), \
INIT_ID(encoding), \
INIT_ID(end), \
+ INIT_ID(end_col_offset), \
INIT_ID(end_lineno), \
INIT_ID(end_offset), \
INIT_ID(endpos), \
@@ -1031,6 +1033,7 @@ extern "C" {
INIT_ID(kw1), \
INIT_ID(kw2), \
INIT_ID(kwdefaults), \
+ INIT_ID(label), \
INIT_ID(lambda), \
INIT_ID(last), \
INIT_ID(last_exc), \
@@ -1094,6 +1097,7 @@ extern "C" {
INIT_ID(namespaces), \
INIT_ID(narg), \
INIT_ID(ndigits), \
+ INIT_ID(nested), \
INIT_ID(new_file_name), \
INIT_ID(new_limit), \
INIT_ID(newline), \
diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h
index 272462e..9daef26 100644
--- a/Include/internal/pycore_unicodeobject_generated.h
+++ b/Include/internal/pycore_unicodeobject_generated.h
@@ -900,6 +900,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
string = &_Py_ID(code);
assert(_PyUnicode_CheckConsistency(string, 1));
_PyUnicode_InternInPlace(interp, &string);
+ string = &_Py_ID(col_offset);
+ assert(_PyUnicode_CheckConsistency(string, 1));
+ _PyUnicode_InternInPlace(interp, &string);
string = &_Py_ID(command);
assert(_PyUnicode_CheckConsistency(string, 1));
_PyUnicode_InternInPlace(interp, &string);
@@ -1047,6 +1050,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
string = &_Py_ID(end);
assert(_PyUnicode_CheckConsistency(string, 1));
_PyUnicode_InternInPlace(interp, &string);
+ string = &_Py_ID(end_col_offset);
+ assert(_PyUnicode_CheckConsistency(string, 1));
+ _PyUnicode_InternInPlace(interp, &string);
string = &_Py_ID(end_lineno);
assert(_PyUnicode_CheckConsistency(string, 1));
_PyUnicode_InternInPlace(interp, &string);
@@ -1407,6 +1413,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
string = &_Py_ID(kwdefaults);
assert(_PyUnicode_CheckConsistency(string, 1));
_PyUnicode_InternInPlace(interp, &string);
+ string = &_Py_ID(label);
+ assert(_PyUnicode_CheckConsistency(string, 1));
+ _PyUnicode_InternInPlace(interp, &string);
string = &_Py_ID(lambda);
assert(_PyUnicode_CheckConsistency(string, 1));
_PyUnicode_InternInPlace(interp, &string);
@@ -1596,6 +1605,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
string = &_Py_ID(ndigits);
assert(_PyUnicode_CheckConsistency(string, 1));
_PyUnicode_InternInPlace(interp, &string);
+ string = &_Py_ID(nested);
+ assert(_PyUnicode_CheckConsistency(string, 1));
+ _PyUnicode_InternInPlace(interp, &string);
string = &_Py_ID(new_file_name);
assert(_PyUnicode_CheckConsistency(string, 1));
_PyUnicode_InternInPlace(interp, &string);