void fl_print_child(ios_t *f, value_t v) { char *name, *str; char buf[64]; if (print_level >= 0 && P_LEVEL >= print_level && (iscons(v) || isvector(v) || isclosure(v))) { outc('#', f); return; } P_LEVEL++; switch (tag(v)) { case TAG_NUM : case TAG_NUM1: //HPOS+=ios_printf(f, "%ld", numval(v)); break; str = uint2str(&buf[1], sizeof(buf)-1, labs(numval(v)), 10); if (numval(v)<0) *(--str) = '-'; outs(str, f); break; case TAG_SYM: name = symbol_name(v); if (print_princ) outs(name, f); else if (ismanaged(v)) { outsn("#:", f, 2); outs(name, f); } else print_symbol_name(f, name); break; case TAG_FUNCTION: if (v == FL_T) { outsn("#t", f, 2); } else if (v == FL_F) { outsn("#f", f, 2); } else if (v == FL_NIL) { outsn("()", f, 2); } else if (v == FL_EOF) { outsn("#<eof>", f, 6); } else if (isbuiltin(v)) { if (!print_princ) outsn("#.", f, 2); outs(builtin_names[uintval(v)], f); } else { assert(isclosure(v)); if (!print_princ) { if (print_circle_prefix(f, v)) break; function_t *fn = (function_t*)ptr(v); outs("#fn(", f); char *data = cvalue_data(fn->bcode); size_t i, sz = cvalue_len(fn->bcode); for(i=0; i < sz; i++) data[i] += 48; fl_print_child(f, fn->bcode); for(i=0; i < sz; i++) data[i] -= 48; outc(' ', f); fl_print_child(f, fn->vals); if (fn->env != NIL) { outc(' ', f); fl_print_child(f, fn->env); } if (fn->name != LAMBDA) { outc(' ', f); fl_print_child(f, fn->name); } outc(')', f); } else { outs("#<function>", f); } } break; case TAG_CVALUE: case TAG_CPRIM: if (v == UNBOUND) { outs("#<undefined>", f); break; } case TAG_VECTOR: case TAG_CONS: if (print_circle_prefix(f, v)) break; if (isvector(v)) { outc('[', f); int newindent = HPOS, est; int i, sz = vector_size(v); for(i=0; i < sz; i++) { if (print_length >= 0 && i >= print_length && i < sz-1) { outsn("...", f, 3); break; } fl_print_child(f, vector_elt(v,i)); if (i < sz-1) { if (!print_pretty) { outc(' ', f); } else { est = lengthestimate(vector_elt(v,i+1)); if (HPOS > SCR_WIDTH-4 || (est!=-1 && (HPOS+est > SCR_WIDTH-2)) || (HPOS > SCR_WIDTH/2 && !smallp(vector_elt(v,i+1)) && !tinyp(vector_elt(v,i)))) newindent = outindent(newindent, f); else outc(' ', f); } } } outc(']', f); break; } if (iscvalue(v) || iscprim(v)) cvalue_print(f, v); else print_pair(f, v); break; } P_LEVEL--; }
void print_symbol (STREAM stream, D instance, BOOL escape_p, int print_depth) { ignore(escape_p); put_string("#", stream); print_symbol_name(stream, instance, TRUE, print_depth); }