diff --git a/py/obj.h b/py/obj.h index 5a3b4a852f..0ecc2fe782 100644 --- a/py/obj.h +++ b/py/obj.h @@ -511,6 +511,7 @@ typedef struct _mp_obj_fun_native_t { // need this so we can define const object bool mp_obj_fun_prepare_simple_args(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args, uint *out_args1_len, const mp_obj_t **out_args1, uint *out_args2_len, const mp_obj_t **out_args2); +const char *mp_obj_fun_get_name(mp_obj_t fun); const char *mp_obj_code_get_name(const byte *code_info); mp_obj_t mp_identity(mp_obj_t self); diff --git a/py/objcell.c b/py/objcell.c index 488a737971..35b44e996d 100644 --- a/py/objcell.c +++ b/py/objcell.c @@ -20,14 +20,13 @@ void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj) { self->obj = obj; } -#if 0 +#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED STATIC void cell_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) { mp_obj_cell_t *o = o_in; - print(env, "obj); if (o->obj == MP_OBJ_NULL) { print(env, "(nil)"); } else { - //print(env, "%p", o->obj); mp_obj_print_helper(print, env, o->obj, PRINT_REPR); } print(env, ">"); @@ -36,8 +35,10 @@ STATIC void cell_print(void (*print)(void *env, const char *fmt, ...), void *env const mp_obj_type_t cell_type = { { &mp_type_type }, - .name = MP_QSTR_, // should never need to print cell type - //.print = cell_print, + .name = MP_QSTR_, // cell representation is just value in < > +#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED + .print = cell_print, +#endif }; mp_obj_t mp_obj_new_cell(mp_obj_t obj) { diff --git a/py/objclosure.c b/py/objclosure.c index ca7c537f09..2b83cab71a 100644 --- a/py/objclosure.c +++ b/py/objclosure.c @@ -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, "n_closed); + print(env, "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, }; diff --git a/py/objfun.c b/py/objfun.c index e0c25771e1..37fe809658 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -131,8 +131,9 @@ const char *mp_obj_code_get_name(const byte *code_info) { return qstr_str(block_name); } -const char *mp_obj_fun_get_name(mp_obj_fun_bc_t *o) { - const byte *code_info = o->bytecode; +const char *mp_obj_fun_get_name(mp_obj_t fun_in) { + mp_obj_fun_bc_t *fun = fun_in; + const byte *code_info = fun->bytecode; return mp_obj_code_get_name(code_info); }