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.
pull/554/head
Paul Sokolovsky 2014-05-03 14:10:34 +03:00
rodzic 8f472ad577
commit 418aca976c
4 zmienionych plików z 15 dodań i 10 usunięć

Wyświetl plik

@ -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);

Wyświetl plik

@ -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, "<cell ");
print(env, "<cell %p ", o->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) {

Wyświetl plik

@ -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,
};

Wyświetl plik

@ -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);
}