objclosure, objcell: Print detailed representation if was requested.

Well, it is bound to "detailed error reporting", but that's closest what we
have now without creating new entities.
This commit is contained in:
Paul Sokolovsky
2014-05-03 14:10:34 +03:00
parent 8f472ad577
commit 418aca976c
4 changed files with 15 additions and 10 deletions

View File

@@ -38,10 +38,10 @@ mp_obj_t closure_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *
}
}
#if 0
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
STATIC void closure_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
mp_obj_closure_t *o = o_in;
print(env, "<closure %p, n_closed=%u ", o, o->n_closed);
print(env, "<closure %s at %p, n_closed=%u ", mp_obj_fun_get_name(o->fun), o, o->n_closed);
for (int i = 0; i < o->n_closed; i++) {
if (o->closed[i] == MP_OBJ_NULL) {
print(env, "(nil)");
@@ -57,7 +57,9 @@ STATIC void closure_print(void (*print)(void *env, const char *fmt, ...), void *
const mp_obj_type_t closure_type = {
{ &mp_type_type },
.name = MP_QSTR_closure,
//.print = closure_print,
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
.print = closure_print,
#endif
.call = closure_call,
};