summaryrefslogtreecommitdiffstatshomepage
path: root/py/runtime.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-23 18:27:51 +0000
committerDamien George <damien.p.george@gmail.com>2014-01-23 18:27:51 +0000
commit1e708fed188e3471cc7bed13635ba69b48bc8cf7 (patch)
treea8322082bbcf08272ae039843de237f0bf427134 /py/runtime.c
parentb051e7d167ac00576e45a6a1de291b8ff6bcd6a3 (diff)
downloadmicropython-1e708fed188e3471cc7bed13635ba69b48bc8cf7.tar.gz
micropython-1e708fed188e3471cc7bed13635ba69b48bc8cf7.zip
py: Implement bool unary op; tidy up unary op dispatch.
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/py/runtime.c b/py/runtime.c
index d6b2bf7826..0d9906ea60 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -479,16 +479,16 @@ mp_obj_t rt_unary_op(int op, mp_obj_t arg) {
return MP_OBJ_NEW_SMALL_INT(val);
}
return mp_obj_new_int(val);
- } else { // will be an object (small ints are caught in previous if)
- mp_obj_base_t *o = arg;
- if (o->type->unary_op != NULL) {
- mp_obj_t result = o->type->unary_op(op, arg);
+ } else {
+ mp_obj_type_t *type = mp_obj_get_type(arg);
+ if (type->unary_op != NULL) {
+ mp_obj_t result = type->unary_op(op, arg);
if (result != NULL) {
return result;
}
}
// TODO specify in error message what the operator is
- nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "bad operand type for unary operator: '%s'", o->type->name));
+ nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "bad operand type for unary operator: '%s'", type->name));
}
}