py: Make native emitter handle multi-compare and not/is not/not in ops.
This commit is contained in:
11
py/objbool.c
11
py/objbool.c
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user