void secd_print_env(secd_t *secd) { cell_t *env = secd->env; int i = 0; secd_printf(secd, ";;Environment:\n"); while (not_nil(env)) { secd_printf(secd, ";; Frame #%d:\n", i++); cell_t *frame = get_car(env); cell_t *symlist = get_car(frame); cell_t *vallist = get_cdr(frame); while (not_nil(symlist)) { if (is_symbol(symlist)) { secd_printf(secd, ";; . %s\t=>\t", symname(symlist)); dbg_print_cell(secd, vallist); break; } cell_t *sym = get_car(symlist); cell_t *val = get_car(vallist); if (!is_symbol(sym)) { errorf("print_env: not a symbol at *%p in symlist\n", sym); dbg_printc(secd, sym); } secd_printf(secd, ";; %s\t=>\t", symname(sym)); dbg_print_cell(secd, val); symlist = list_next(secd, symlist); vallist = list_next(secd, vallist); } env = list_next(secd, env); } }
void dbg_print_list(secd_t *secd, cell_t *list) { printf(" -= "); while (not_nil(list)) { assertv(is_cons(list), "Not a cons at [%ld]\n", cell_index(secd, list)); printf("[%ld]:%ld\t", cell_index(secd, list), cell_index(secd, get_car(list))); dbg_print_cell(secd, get_car(list)); printf(" -> "); list = list_next(secd, list); } printf("NIL\n"); }
void dbg_printc(secd_t *secd, cell_t *c) { if (is_cons(c)) dbg_print_list(secd, c); else dbg_print_cell(secd, c); }