fix bug printing custom cvalue types that lack print methods

This commit is contained in:
Jeff Bezanson 2013-03-31 00:20:54 -04:00 committed by Lassi Kortela
parent 2eef9d5a5d
commit 687cf8fdb5
2 changed files with 11 additions and 6 deletions

View File

@ -768,7 +768,6 @@ static numerictype_t sym_to_numtype(value_t type)
return T_FLOAT;
else if (type == doublesym)
return T_DOUBLE;
assert(0);
return N_NUMTYPES;
}

View File

@ -700,12 +700,18 @@ static void cvalue_printdata(ios_t *f, void *data, size_t len, value_t type,
else if (issymbol(type)) {
// handle other integer prims. we know it's smaller than uint64
// at this point, so int64 is big enough to capture everything.
numerictype_t nt = sym_to_numtype(type);
if (nt == N_NUMTYPES) {
HPOS += ios_printf(f, "#<%s>", symbol_name(type));
}
else {
int64_t i64 = conv_to_int64(data, sym_to_numtype(type));
if (weak || print_princ)
HPOS += ios_printf(f, "%lld", i64);
else
HPOS += ios_printf(f, "#%s(%lld)", symbol_name(type), i64);
}
}
else if (iscons(type)) {
if (car_(type) == arraysym) {
value_t eltype = car(cdr_(type));