aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 7ae687f1bfa..b30fa089910 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -16,6 +16,7 @@
#include "pycore_emscripten_signal.h" // _Py_CHECK_EMSCRIPTEN_SIGNALS
#include "pycore_function.h"
#include "pycore_instruments.h"
+#include "pycore_interpolation.h" // _PyInterpolation_Build()
#include "pycore_intrinsics.h"
#include "pycore_long.h" // _PyLong_GetZero()
#include "pycore_moduleobject.h" // PyModuleObject
@@ -30,6 +31,7 @@
#include "pycore_setobject.h" // _PySet_NextEntry()
#include "pycore_sliceobject.h" // _PyBuildSlice_ConsumeRefs
#include "pycore_stackref.h"
+#include "pycore_template.h" // _PyTemplate_Build()
#include "pycore_tuple.h" // _PyTuple_ITEMS()
#include "pycore_typeobject.h" // _PySuper_Lookup()
@@ -1903,6 +1905,40 @@ dummy_func(
str = PyStackRef_FromPyObjectSteal(str_o);
}
+ inst(BUILD_INTERPOLATION, (value, str, format[oparg & 1] -- interpolation)) {
+ 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);
+ }
+ PyObject *interpolation_o = _PyInterpolation_Build(value_o, str_o, conversion, format_o);
+ if (oparg & 1) {
+ PyStackRef_CLOSE(format[0]);
+ }
+ else {
+ DEAD(format);
+ }
+ PyStackRef_CLOSE(str);
+ PyStackRef_CLOSE(value);
+ ERROR_IF(interpolation_o == NULL);
+ interpolation = PyStackRef_FromPyObjectSteal(interpolation_o);
+ }
+
+ inst(BUILD_TEMPLATE, (strings, interpolations -- template)) {
+ PyObject *strings_o = PyStackRef_AsPyObjectBorrow(strings);
+ PyObject *interpolations_o = PyStackRef_AsPyObjectBorrow(interpolations);
+ PyObject *template_o = _PyTemplate_Build(strings_o, interpolations_o);
+ PyStackRef_CLOSE(interpolations);
+ PyStackRef_CLOSE(strings);
+ ERROR_IF(template_o == NULL);
+ template = PyStackRef_FromPyObjectSteal(template_o);
+ }
+
inst(BUILD_TUPLE, (values[oparg] -- tup)) {
PyObject *tup_o = _PyTuple_FromStackRefStealOnSuccess(values, oparg);
if (tup_o == NULL) {