From 431165e5fa72ba6dffd477de32960745cdec332c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 Dec 2017 11:33:36 -0800 Subject: altos/scheme: Rework display/write code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unify output functions and add bool to switch between write and display mode. Make that only affect strings (as per r⁷rs). Use print recursion detection in frame and stack code, eliminating PRINT flags in type field. Signed-off-by: Keith Packard --- src/scheme/ao_scheme_vector.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'src/scheme/ao_scheme_vector.c') diff --git a/src/scheme/ao_scheme_vector.c b/src/scheme/ao_scheme_vector.c index ff2067e2..419d6765 100644 --- a/src/scheme/ao_scheme_vector.c +++ b/src/scheme/ao_scheme_vector.c @@ -73,39 +73,27 @@ ao_scheme_vector_alloc(uint16_t length, ao_poly fill) } void -ao_scheme_vector_write(ao_poly v) +ao_scheme_vector_write(ao_poly v, bool write) { struct ao_scheme_vector *vector = ao_scheme_poly_vector(v); unsigned int i; + int was_marked = 0; ao_scheme_print_start(); - if (ao_scheme_print_mark_addr(vector)) + was_marked = ao_scheme_print_mark_addr(vector); + if (was_marked) { printf ("..."); - else { + } else { printf("#("); for (i = 0; i < vector->length; i++) { if (i != 0) printf(" "); - ao_scheme_poly_write(vector->vals[i]); + ao_scheme_poly_write(vector->vals[i], write); } printf(")"); } - ao_scheme_print_stop(); -} - -void -ao_scheme_vector_display(ao_poly v) -{ - struct ao_scheme_vector *vector = ao_scheme_poly_vector(v); - unsigned int i; - - 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]); - } + if (ao_scheme_print_stop() && !was_marked) + ao_scheme_print_clear_addr(vector); } static int32_t -- cgit v1.2.3