summaryrefslogtreecommitdiff
path: root/py/objdict.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-08 21:32:29 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-08 21:32:29 +0100
commitf4c9b33abf0ac6ff97cd39331d125a74fd2bb897 (patch)
tree64bdfb7d6d032d826640e1f9a43956b0b3947591 /py/objdict.c
parent4671392d90e98ea4edf6e9ce7023d21cc9957d8c (diff)
py: Remove DELETE_SUBSCR opcode, combine with STORE_SUBSCR.
This makes the runtime and object APIs more consistent. mp_store_subscr functionality now moved into objects (ie list and dict store_item).
Diffstat (limited to 'py/objdict.c')
-rw-r--r--py/objdict.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/py/objdict.c b/py/objdict.c
index 80337198e..85986448c 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -114,6 +114,14 @@ STATIC mp_obj_t dict_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
}
}
+STATIC bool dict_store_item(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
+ if (value == MP_OBJ_NULL) {
+ mp_obj_dict_delete(self_in, index);
+ } else {
+ mp_obj_dict_store(self_in, index, value);
+ }
+ return true;
+}
/******************************************************************************/
/* dict iterator */
@@ -484,6 +492,7 @@ const mp_obj_type_t mp_type_dict = {
.make_new = dict_make_new,
.unary_op = dict_unary_op,
.binary_op = dict_binary_op,
+ .store_item = dict_store_item,
.getiter = dict_getiter,
.locals_dict = (mp_obj_t)&dict_locals_dict,
};