summaryrefslogtreecommitdiffstatshomepage
path: root/py/objset.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-02-01 23:04:09 +0000
committerDamien George <damien.p.george@gmail.com>2014-02-01 23:04:09 +0000
commit9aa2a527b532e31c77592cede3b38c018c83ac64 (patch)
treeea2c5431a7b645f4aba7d573086ada1109cbcdd1 /py/objset.c
parent7e5fb24e3bdd8a07e2c7f317ad44b62e85082547 (diff)
downloadmicropython-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/objset.c')
-rw-r--r--py/objset.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/py/objset.c b/py/objset.c
index cf4545c257..05079cf55b 100644
--- a/py/objset.c
+++ b/py/objset.c
@@ -396,24 +396,23 @@ static mp_obj_t set_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
return set_intersect(lhs, rhs);
case RT_BINARY_OP_INPLACE_SUBTRACT:
return set_diff(2, args);
- case RT_COMPARE_OP_LESS:
+ case RT_BINARY_OP_LESS:
return set_issubset_proper(lhs, rhs);
- case RT_COMPARE_OP_MORE:
+ case RT_BINARY_OP_MORE:
return set_issuperset_proper(lhs, rhs);
- case RT_COMPARE_OP_EQUAL:
+ case RT_BINARY_OP_EQUAL:
return set_equal(lhs, rhs);
- case RT_COMPARE_OP_LESS_EQUAL:
+ case RT_BINARY_OP_LESS_EQUAL:
return set_issubset(lhs, rhs);
- case RT_COMPARE_OP_MORE_EQUAL:
+ case RT_BINARY_OP_MORE_EQUAL:
return set_issuperset(lhs, rhs);
- case RT_COMPARE_OP_NOT_EQUAL:
+ case RT_BINARY_OP_NOT_EQUAL:
return MP_BOOL(set_equal(lhs, rhs) == mp_const_false);
- case RT_COMPARE_OP_IN:
- case RT_COMPARE_OP_NOT_IN:
+ case RT_BINARY_OP_IN:
{
mp_obj_set_t *o = lhs;
mp_obj_t elem = mp_set_lookup(&o->set, rhs, MP_MAP_LOOKUP);
- return MP_BOOL((op == RT_COMPARE_OP_IN) ^ (elem == NULL));
+ return MP_BOOL(elem != NULL);
}
default:
// op not supported