summaryrefslogtreecommitdiff
path: root/libguile/vm-i-system.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-02-26 13:05:25 +0100
committerAndy Wingo <wingo@pobox.com>2010-02-26 13:05:25 +0100
commitadbdfd6d2418b1404af48d480c2273f501517d6e (patch)
tree9624620bcedfbdd1cc29a9454b2cbcfdebdf808b /libguile/vm-i-system.c
parent416f26c7534a018c59f1c8d888dc9153f42d86d1 (diff)
downloadguile-adbdfd6d2418b1404af48d480c2273f501517d6e.tar.gz
rewinding prompts works
* libguile/control.h (SCM_PROMPT_HANDLER): Remove, it was unused. (SCM_PROMPT_DYNWINDS): Rename from SCM_PROMPT_DYNENV. * libguile/control.c: (scm_c_make_prompt): Take another arg, the winds that are to be in place for the prompt. Fix allocation to be 4 words instead of 5 (the handler was never used). * libguile/eval.c (eval): * libguile/throw.c (pre_init_catch): Adapt to scm_c_make_prompt change. * libguile/vm-i-system.c (partial-cont-call): Grovel the new elements of the wind list in order to call setjmp() on the new prompts. Pass cookie to vm_reinstate_partial_continuation. (prompt): Adapt to scm_c_make_prompt change. * libguile/vm.c (vm_reinstate_partial_continuation): Take a cookie arg, used when winding captured prompts onto the stack. Winding a prompt implies making a new prompt, actually -- with new registers, a new jump buffer, new winds, etc. * test-suite/tests/control.test ("rewinding prompts"): Add a test for rewinding prompts.
Diffstat (limited to 'libguile/vm-i-system.c')
-rw-r--r--libguile/vm-i-system.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c
index 262bb876d..e21a9109e 100644
--- a/libguile/vm-i-system.c
+++ b/libguile/vm-i-system.c
@@ -995,7 +995,7 @@ VM_DEFINE_INSTRUCTION (89, continuation_call, "continuation-call", 0, -1, 0)
VM_DEFINE_INSTRUCTION (94, partial_cont_call, "partial-cont-call", 0, -1, 0)
{
- SCM vmcont, intwinds;
+ SCM vmcont, intwinds, prevwinds;
POP (intwinds);
POP (vmcont);
SYNC_REGISTER ();
@@ -1003,7 +1003,18 @@ VM_DEFINE_INSTRUCTION (94, partial_cont_call, "partial-cont-call", 0, -1, 0)
{ finish_args = vmcont;
goto vm_error_continuation_not_rewindable;
}
- vm_reinstate_partial_continuation (vm, vmcont, intwinds, sp + 1 - fp, fp);
+ prevwinds = scm_i_dynwinds ();
+ vm_reinstate_partial_continuation (vm, vmcont, intwinds, sp + 1 - fp, fp,
+ vm_cookie);
+
+ /* Rewind prompt jmpbuffers, if any. */
+ {
+ SCM winds = scm_i_dynwinds ();
+ for (; !scm_is_eq (winds, prevwinds); winds = scm_cdr (winds))
+ if (SCM_PROMPT_P (scm_car (winds)) && SCM_PROMPT_SETJMP (scm_car (winds)))
+ break;
+ }
+
CACHE_REGISTER ();
program = SCM_FRAME_PROGRAM (fp);
CACHE_PROGRAM ();
@@ -1480,8 +1491,9 @@ VM_DEFINE_INSTRUCTION (83, prompt, "prompt", 4, 2, 0)
SYNC_REGISTER ();
/* Push the prompt onto the dynamic stack. */
- prompt = scm_c_make_prompt (k, fp, sp, ip + offset, escape_only_p, vm_cookie);
- scm_i_set_dynwinds (scm_cons (prompt, scm_i_dynwinds ()));
+ prompt = scm_c_make_prompt (k, fp, sp, ip + offset, escape_only_p, vm_cookie,
+ scm_i_dynwinds ());
+ scm_i_set_dynwinds (scm_cons (prompt, SCM_PROMPT_DYNWINDS (prompt)));
if (SCM_PROMPT_SETJMP (prompt))
{
/* The prompt exited nonlocally. Cache the regs back from the vp, and go