summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-09 07:06:31 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-09 07:06:31 -0700
commitab77a519ba5d9ad21a1cc732d78b6b49e9ca2c2b (patch)
tree9d32b53621f50414ae85d4fdc4b79cf04268e199
parentc6c05649f5d3890281e6fe95694794d39f6f0841 (diff)
downloadtxr-ab77a519ba5d9ad21a1cc732d78b6b49e9ca2c2b.tar.gz
txr-ab77a519ba5d9ad21a1cc732d78b6b49e9ca2c2b.tar.bz2
txr-ab77a519ba5d9ad21a1cc732d78b6b49e9ca2c2b.zip
More informative printed rep for functions.
* lib.c (obj_print_impl): Print whether a function is interpreted or intrinsic, and include argument information. * tests/012/struct.tl: Test case relying on function printed rep updated.
-rw-r--r--lib.c19
-rw-r--r--tests/012/struct.tl2
2 files changed, 19 insertions, 2 deletions
diff --git a/lib.c b/lib.c
index d31a06bb..b912e9b0 100644
--- a/lib.c
+++ b/lib.c
@@ -7380,7 +7380,24 @@ finish:
format(out, lit("#<package: ~s>"), obj->pk.name, nao);
break;
case FUN:
- format(out, lit("#<function: type ~a>"), num(obj->f.functype), nao);
+ {
+ struct func *f = &obj->f;
+ if (f->functype == FINTERP) {
+ val fun = f->f.interp_fun;
+ format(out, lit("#<interpreted fun: ~s ~s>"),
+ car(fun), cadr(fun), nao);
+ } else {
+ format(out, lit("#<intrinsic fun: ~a param"),
+ num_fast(f->fixparam - f->optargs), nao);
+ if (f->optargs)
+ format(out, lit(" + ~a optional"),
+ num_fast(f->optargs), nao);
+ if (obj->f.variadic)
+ put_string(lit(" + variadic>"), out);
+ else
+ put_char(chr('>'), out);
+ }
+ }
break;
case VEC:
{
diff --git a/tests/012/struct.tl b/tests/012/struct.tl
index 047204a6..5be89cab 100644
--- a/tests/012/struct.tl
+++ b/tests/012/struct.tl
@@ -103,7 +103,7 @@
(defvarl bz (new baz))
(stest bz
- "#S(baz array #(1 2 3) increment #<function: type 0>)")
+ "#S(baz array #(1 2 3) increment #<interpreted fun: lambda (self which delta)>)")
(test bz.[array 2] 3)
(test bz.(increment 0 42) 43)