py: Make native emitter handle multi-compare and not/is not/not in ops.

This commit is contained in:
Damien George
2014-09-23 14:10:03 +00:00
parent 96e20c600f
commit d6230f62c7
5 changed files with 76 additions and 28 deletions

View File

@@ -74,9 +74,16 @@ STATIC mp_obj_t bool_unary_op(mp_uint_t op, mp_obj_t o_in) {
case MP_UNARY_OP_BOOL: return o_in;
case MP_UNARY_OP_POSITIVE: return MP_OBJ_NEW_SMALL_INT(value);
case MP_UNARY_OP_NEGATIVE: return MP_OBJ_NEW_SMALL_INT(-value);
case MP_UNARY_OP_INVERT:
case MP_UNARY_OP_INVERT: return MP_OBJ_NEW_SMALL_INT(~value);
// only bool needs to implement MP_UNARY_OP_NOT
case MP_UNARY_OP_NOT:
default: // no other cases
return MP_OBJ_NEW_SMALL_INT(~value);
if (value) {
return mp_const_false;
} else {
return mp_const_true;
}
}
}