diff options
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 47dd100..946e997 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -23,6 +23,7 @@ #include "pycore_pymem.h" // _PyMem_IsPtrFreed() #include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_range.h" // _PyRangeIterObject +#include "pycore_sliceobject.h" // _PyBuildSlice_ConsumeRefs #include "pycore_sysmodule.h" // _PySys_Audit() #include "pycore_tuple.h" // _PyTuple_ITEMS() #include "pycore_emscripten_signal.h" // _Py_CHECK_EMSCRIPTEN_SIGNALS @@ -2139,6 +2140,46 @@ handle_eval_breaker: DISPATCH(); } + TARGET(BINARY_SLICE) { + PyObject *stop = POP(); + PyObject *start = POP(); + PyObject *container = TOP(); + + PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop); + if (slice == NULL) { + goto error; + } + PyObject *res = PyObject_GetItem(container, slice); + Py_DECREF(slice); + if (res == NULL) { + goto error; + } + SET_TOP(res); + Py_DECREF(container); + DISPATCH(); + } + + TARGET(STORE_SLICE) { + PyObject *stop = POP(); + PyObject *start = POP(); + PyObject *container = TOP(); + PyObject *v = SECOND(); + + PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop); + if (slice == NULL) { + goto error; + } + int err = PyObject_SetItem(container, slice, v); + Py_DECREF(slice); + if (err) { + goto error; + } + STACK_SHRINK(2); + Py_DECREF(v); + Py_DECREF(container); + DISPATCH(); + } + TARGET(BINARY_SUBSCR_ADAPTIVE) { _PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache)) { |