diff options
| author | Keith Packard <keithp@keithp.com> | 2017-12-19 11:33:36 -0800 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2017-12-19 11:33:36 -0800 | 
| commit | 431165e5fa72ba6dffd477de32960745cdec332c (patch) | |
| tree | e27c174d5d6cea72caf92de3a4fe2c97e9249ddf /src/scheme/ao_scheme_vector.c | |
| parent | 5628b983497d9d03e10cccee157419210a49cfa9 (diff) | |
altos/scheme: Rework display/write code
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 <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, 8 insertions, 20 deletions
| 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 | 
