mirror of
https://github.com/python/cpython.git
synced 2025-08-28 04:35:02 +00:00
gh-132661: Implement PEP 750 (#132662)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Wingy <git@wingysam.xyz> Co-authored-by: Koudai Aono <koxudaxi@gmail.com> Co-authored-by: Dave Peck <davepeck@gmail.com> Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: Paul Everitt <pauleveritt@me.com> Co-authored-by: sobolevn <mail@sobolevn.me>
This commit is contained in:
parent
5ea9010e89
commit
60202609a2
81 changed files with 7716 additions and 3761 deletions
96
Python/generated_cases.c.h
generated
96
Python/generated_cases.c.h
generated
|
@ -1088,6 +1088,64 @@
|
|||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(BUILD_INTERPOLATION) {
|
||||
#if Py_TAIL_CALL_INTERP
|
||||
int opcode = BUILD_INTERPOLATION;
|
||||
(void)(opcode);
|
||||
#endif
|
||||
frame->instr_ptr = next_instr;
|
||||
next_instr += 1;
|
||||
INSTRUCTION_STATS(BUILD_INTERPOLATION);
|
||||
_PyStackRef value;
|
||||
_PyStackRef str;
|
||||
_PyStackRef *format;
|
||||
_PyStackRef interpolation;
|
||||
format = &stack_pointer[-(oparg & 1)];
|
||||
str = stack_pointer[-1 - (oparg & 1)];
|
||||
value = stack_pointer[-2 - (oparg & 1)];
|
||||
PyObject *value_o = PyStackRef_AsPyObjectBorrow(value);
|
||||
PyObject *str_o = PyStackRef_AsPyObjectBorrow(str);
|
||||
int conversion = oparg >> 2;
|
||||
PyObject *format_o;
|
||||
if (oparg & 1) {
|
||||
format_o = PyStackRef_AsPyObjectBorrow(format[0]);
|
||||
}
|
||||
else {
|
||||
format_o = &_Py_STR(empty);
|
||||
}
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyObject *interpolation_o = _PyInterpolation_Build(value_o, str_o, conversion, format_o);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
if (oparg & 1) {
|
||||
stack_pointer += -(oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(format[0]);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
}
|
||||
else {
|
||||
stack_pointer += -(oparg & 1);
|
||||
}
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(str);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(value);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
if (interpolation_o == NULL) {
|
||||
JUMP_TO_LABEL(error);
|
||||
}
|
||||
interpolation = PyStackRef_FromPyObjectSteal(interpolation_o);
|
||||
stack_pointer[0] = interpolation;
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(BUILD_LIST) {
|
||||
#if Py_TAIL_CALL_INTERP
|
||||
int opcode = BUILD_LIST;
|
||||
|
@ -1303,6 +1361,44 @@
|
|||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(BUILD_TEMPLATE) {
|
||||
#if Py_TAIL_CALL_INTERP
|
||||
int opcode = BUILD_TEMPLATE;
|
||||
(void)(opcode);
|
||||
#endif
|
||||
frame->instr_ptr = next_instr;
|
||||
next_instr += 1;
|
||||
INSTRUCTION_STATS(BUILD_TEMPLATE);
|
||||
_PyStackRef strings;
|
||||
_PyStackRef interpolations;
|
||||
_PyStackRef template;
|
||||
interpolations = stack_pointer[-1];
|
||||
strings = stack_pointer[-2];
|
||||
PyObject *strings_o = PyStackRef_AsPyObjectBorrow(strings);
|
||||
PyObject *interpolations_o = PyStackRef_AsPyObjectBorrow(interpolations);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyObject *template_o = _PyTemplate_Build(strings_o, interpolations_o);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(interpolations);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(strings);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
if (template_o == NULL) {
|
||||
JUMP_TO_LABEL(error);
|
||||
}
|
||||
template = PyStackRef_FromPyObjectSteal(template_o);
|
||||
stack_pointer[0] = template;
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(BUILD_TUPLE) {
|
||||
#if Py_TAIL_CALL_INTERP
|
||||
int opcode = BUILD_TUPLE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue