diff options
author | Keith Packard <keithp@keithp.com> | 2017-12-17 22:22:50 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2017-12-17 22:22:50 -0800 |
commit | e1a6b3bf458f311d832aea7eec34935d42f8efed (patch) | |
tree | 7141f7e4ae75f23969722f75517f4c39cb623263 /src/scheme/ao_scheme_vector.c | |
parent | 9d1131da911f7220ac8b6cb7ba5a0afd3deef657 (diff) |
altos/scheme: Use memory manager mark code to note recursive print
This flags any object being printed and checks before recursing to
avoid infinite loops.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/scheme/ao_scheme_vector.c')
-rw-r--r-- | src/scheme/ao_scheme_vector.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/scheme/ao_scheme_vector.c b/src/scheme/ao_scheme_vector.c index a4127f64..ff2067e2 100644 --- a/src/scheme/ao_scheme_vector.c +++ b/src/scheme/ao_scheme_vector.c @@ -78,16 +78,19 @@ ao_scheme_vector_write(ao_poly v) struct ao_scheme_vector *vector = ao_scheme_poly_vector(v); unsigned int i; - printf("#("); - for (i = 0; i < vector->length; i++) { - if (i != 0) - printf(" "); - if (vector->vals[i] == v) - printf ("..."); - else + ao_scheme_print_start(); + if (ao_scheme_print_mark_addr(vector)) + printf ("..."); + else { + printf("#("); + for (i = 0; i < vector->length; i++) { + if (i != 0) + printf(" "); ao_scheme_poly_write(vector->vals[i]); + } + printf(")"); } - printf(")"); + ao_scheme_print_stop(); } void @@ -96,10 +99,11 @@ ao_scheme_vector_display(ao_poly v) struct ao_scheme_vector *vector = ao_scheme_poly_vector(v); unsigned int i; - for (i = 0; i < vector->length; i++) { - if (vector->vals[i] == v) - printf("..."); - else + ao_scheme_print_start(); + if (ao_scheme_print_mark_addr(vector)) + printf ("..."); + else { + for (i = 0; i < vector->length; i++) ao_scheme_poly_display(vector->vals[i]); } } |