Add suspendable-continuation?

* doc/ref/api-control.texi (Prompt Primitives): Document
  suspendable-continuation?.
* libguile/control.c (scm_suspendable_continuation_p): New procedure.
  (scm_init_ice_9_control): New extension procedure, defines
  suspendable-continuation?.
  (scm_init_control): Register scm_init_ice_9_control.
* libguile/eval.c (eval):
* libguile/throw.c (catch):
* libguile/continuations.c (scm_i_make_continuation): Restore resumable
  prompt cookie after continuation invocation.
* libguile/vm.c (scm_call_n): Arrange to set resumable_prompt_cookie
  during invocation of VM.
* libguile/vm.h (struct scm_vm): Add resumable_prompt_cookie member.
* module/ice-9/control.scm: Export suspendable-continuation?.
* test-suite/tests/control.test ("suspendable-continuation?"): New
  test.
This commit is contained in:
Andy Wingo 2016-12-12 20:55:08 +01:00
commit 6dd87f4d8c
9 changed files with 104 additions and 4 deletions

View file

@ -425,6 +425,7 @@ eval (SCM x, SCM env)
struct scm_vm *vp;
SCM k, handler, res;
scm_i_jmp_buf registers;
const void *prev_cookie;
scm_t_ptrdiff saved_stack_depth;
k = EVAL1 (CAR (mx), env);
@ -442,9 +443,11 @@ eval (SCM x, SCM env)
vp->ip,
&registers);
prev_cookie = vp->resumable_prompt_cookie;
if (SCM_I_SETJMP (registers))
{
/* The prompt exited nonlocally. */
vp->resumable_prompt_cookie = prev_cookie;
scm_gc_after_nonlocal_exit ();
proc = handler;
args = scm_i_prompt_pop_abort_args_x (vp, saved_stack_depth);