diff --git a/py/runtime.c b/py/runtime.c index 0b76df8a5b60ae3089cccc96aa8976b21638da08..33a4c95e182ec14d5f41494ebab78ae00eb079f0 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1305,6 +1305,11 @@ py_obj_t rt_build_set(int n_args, py_obj_t *items) { return o; } +py_obj_t rt_store_set(py_obj_t set, py_obj_t item) { + py_set_lookup(set, item, true); + return set; +} + py_obj_t rt_build_map(int n_args) { py_obj_base_t *o = m_new(py_obj_base_t, 1); o->kind = O_MAP; diff --git a/py/runtime.h b/py/runtime.h index 7a806eb55a6faa28e11d0217e627da817092a94c..e7ac934bf5b634d47fae5b887b268127323e289e 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -119,9 +119,10 @@ py_obj_t rt_call_method_n(int n_args, const py_obj_t *args); py_obj_t rt_build_tuple(int n_args, py_obj_t *items); py_obj_t rt_build_list(int n_args, py_obj_t *items); py_obj_t rt_list_append(py_obj_t list, py_obj_t arg); +py_obj_t rt_build_set(int n_args, py_obj_t *items); +py_obj_t rt_store_set(py_obj_t set, py_obj_t item); py_obj_t rt_build_map(int n_args); py_obj_t rt_store_map(py_obj_t map, py_obj_t key, py_obj_t value); -py_obj_t rt_build_set(int n_args, py_obj_t *items); py_obj_t rt_load_attr(py_obj_t base, qstr attr); void rt_load_method(py_obj_t base, qstr attr, py_obj_t *dest); void rt_store_attr(py_obj_t base, qstr attr, py_obj_t val); diff --git a/py/vm.c b/py/vm.c index 2f5977d8259133b9d16bf54667d66a4852aac7b4..33970a0f6a6534a26050db188fcc5bef8722e416 100644 --- a/py/vm.c +++ b/py/vm.c @@ -319,6 +319,13 @@ bool py_execute_byte_code_2(const byte *code, const byte **ip_in_out, py_obj_t * *sp = obj1; break; + case PYBC_SET_ADD: + DECODE_UINT; + // I think it's guaranteed by the compiler that sp[unum] is a set + rt_store_set(sp[unum], sp[0]); + sp++; + break; + case PYBC_MAKE_FUNCTION: DECODE_UINT; PUSH(rt_make_function_from_id(unum));