diff options
author | Damien George <damien.p.george@gmail.com> | 2014-02-01 23:04:09 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-02-01 23:04:09 +0000 |
commit | 9aa2a527b532e31c77592cede3b38c018c83ac64 (patch) | |
tree | ea2c5431a7b645f4aba7d573086ada1109cbcdd1 /py/objdict.c | |
parent | 7e5fb24e3bdd8a07e2c7f317ad44b62e85082547 (diff) | |
download | micropython-9aa2a527b532e31c77592cede3b38c018c83ac64.tar.gz micropython-9aa2a527b532e31c77592cede3b38c018c83ac64.zip |
py: Tidy up BINARY_OPs; negation done by special NOT bytecode.
IS_NOT and NOT_IN are now compiled to IS + NOT and IN + NOT, with a new
special NOT bytecode.
Diffstat (limited to 'py/objdict.c')
-rw-r--r-- | py/objdict.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/py/objdict.c b/py/objdict.c index 934eb50650..bb851d1024 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -65,11 +65,10 @@ static mp_obj_t dict_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) { return elem->value; } } - case RT_COMPARE_OP_IN: - case RT_COMPARE_OP_NOT_IN: + case RT_BINARY_OP_IN: { mp_map_elem_t *elem = mp_map_lookup(&o->map, rhs_in, MP_MAP_LOOKUP); - return MP_BOOL((op == RT_COMPARE_OP_IN) ^ (elem == NULL)); + return MP_BOOL(elem != NULL); } default: // op not supported @@ -380,7 +379,7 @@ static mp_obj_t dict_view_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) { /* only supported for the 'keys' kind until sets and dicts are refactored */ mp_obj_dict_view_t *o = lhs_in; if (o->kind != MP_DICT_VIEW_KEYS) return NULL; - if (op != RT_COMPARE_OP_IN && op != RT_COMPARE_OP_NOT_IN) return NULL; + if (op != RT_BINARY_OP_IN) return NULL; return dict_binary_op(op, o->dict, rhs_in); } |