diff options
| author | Bdale Garbee <bdale@gag.com> | 2017-12-21 19:05:46 -0700 | 
|---|---|---|
| committer | Bdale Garbee <bdale@gag.com> | 2017-12-21 19:05:46 -0700 | 
| commit | dbb78c8222c45f4430601deee0194b0c9dc2e79a (patch) | |
| tree | 6805b815727c58ad6c01f9163e42ab3177ee56d5 /src/scheme/ao_scheme_stack.c | |
| parent | fe38c22595b050435dbacd35f1baae064fb7de75 (diff) | |
| parent | 87aab99521dc44d1d29fbb0b7f227f868f074836 (diff) | |
Merge branch 'master' into branch-1.8
Diffstat (limited to 'src/scheme/ao_scheme_stack.c')
| -rw-r--r-- | src/scheme/ao_scheme_stack.c | 46 | 
1 files changed, 28 insertions, 18 deletions
| diff --git a/src/scheme/ao_scheme_stack.c b/src/scheme/ao_scheme_stack.c index d19dd6d6..863df3ca 100644 --- a/src/scheme/ao_scheme_stack.c +++ b/src/scheme/ao_scheme_stack.c @@ -158,26 +158,35 @@ ao_scheme_stack_clear(void)  }  void -ao_scheme_stack_write(ao_poly poly) +ao_scheme_stack_write(ao_poly poly, bool write)  { -	struct ao_scheme_stack *s = ao_scheme_poly_stack(poly); +	struct ao_scheme_stack 	*s = ao_scheme_poly_stack(poly); +	struct ao_scheme_stack	*clear = s; +	int			written = 0; +	(void) write; +	ao_scheme_print_start(); +	ao_scheme_frame_print_indent += 2;  	while (s) { -		if (s->type & AO_SCHEME_STACK_PRINT) { +		if (ao_scheme_print_mark_addr(s)) {  			printf("[recurse...]"); -			return; +			break;  		} -		s->type |= AO_SCHEME_STACK_PRINT; +		written++;  		printf("\t[\n"); -		printf("\t\texpr:   "); ao_scheme_poly_write(s->list); printf("\n"); -		printf("\t\tstate:  %s\n", ao_scheme_state_names[s->state]); -		ao_scheme_error_poly ("values: ", s->values, s->values_tail); -		ao_scheme_error_poly ("sexprs: ", s->sexprs, AO_SCHEME_NIL); -		ao_scheme_error_frame(2, "frame:  ", ao_scheme_poly_frame(s->frame)); +		ao_scheme_printf("\t\texpr:     %v\n", s->list); +		ao_scheme_printf("\t\tvalues:   %v\n", s->values); +		ao_scheme_printf("\t\tframe:    %v\n", s->frame);  		printf("\t]\n"); -		s->type &= ~AO_SCHEME_STACK_PRINT;  		s = ao_scheme_poly_stack(s->prev);  	} +	ao_scheme_frame_print_indent -= 2; +	if (ao_scheme_print_stop()) { +		while (written--) { +			ao_scheme_print_clear_addr(clear); +			clear = ao_scheme_poly_stack(clear->prev); +		} +	}  }  /* @@ -190,13 +199,13 @@ ao_scheme_stack_copy(struct ao_scheme_stack *old)  	struct ao_scheme_stack *n, *prev = NULL;  	while (old) { -		ao_scheme_stack_stash(0, old); -		ao_scheme_stack_stash(1, new); -		ao_scheme_stack_stash(2, prev); +		ao_scheme_stack_stash(old); +		ao_scheme_stack_stash(new); +		ao_scheme_stack_stash(prev);  		n = ao_scheme_stack_new(); -		prev = ao_scheme_stack_fetch(2); -		new = ao_scheme_stack_fetch(1); -		old = ao_scheme_stack_fetch(0); +		prev = ao_scheme_stack_fetch(); +		new = ao_scheme_stack_fetch(); +		old = ao_scheme_stack_fetch();  		if (!n)  			return NULL; @@ -221,11 +230,12 @@ ao_scheme_stack_copy(struct ao_scheme_stack *old)  ao_poly  ao_scheme_stack_eval(void)  { +	struct ao_scheme_cons	*cons;  	struct ao_scheme_stack	*new = ao_scheme_stack_copy(ao_scheme_poly_stack(ao_scheme_v));  	if (!new)  		return AO_SCHEME_NIL; -	struct ao_scheme_cons	*cons = ao_scheme_poly_cons(ao_scheme_stack->values); +	cons = ao_scheme_poly_cons(ao_scheme_stack->values);  	if (!cons || !cons->cdr)  		return ao_scheme_error(AO_SCHEME_INVALID, "continuation requires a value"); | 
