}
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);
+ }
+ }
}
/*
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");