1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-12 14:50:19 +02:00

scm_i_prompt_pop_abort_args_x takes struct scm_vm* as arg

* libguile/control.h:
* libguile/control.c (scm_i_prompt_pop_abort_args_x): Change to take VP
  as an arg, not VM.

* libguile/eval.c (eval):
* libguile/throw.c (pre_init_catch): Adapt.
This commit is contained in:
Andy Wingo 2013-11-21 18:09:29 +01:00
parent 9b4c3ab5fa
commit 4fcbc1b0d8
4 changed files with 28 additions and 22 deletions

View file

@ -39,18 +39,18 @@
/* Only to be called if the SCM_I_SETJMP returns 1 */ /* Only to be called if the SCM_I_SETJMP returns 1 */
SCM SCM
scm_i_prompt_pop_abort_args_x (SCM vm) scm_i_prompt_pop_abort_args_x (struct scm_vm *vp)
{ {
size_t i, n; size_t i, n;
SCM vals = SCM_EOL; SCM vals = SCM_EOL;
n = scm_to_size_t (SCM_VM_DATA (vm)->sp[0]); n = scm_to_size_t (vp->sp[0]);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
vals = scm_cons (SCM_VM_DATA (vm)->sp[-(i + 1)], vals); vals = scm_cons (vp->sp[-(i + 1)], vals);
/* The abort did reset the VM's registers, but then these values /* The abort did reset the VM's registers, but then these values
were pushed on; so we need to pop them ourselves. */ were pushed on; so we need to pop them ourselves. */
SCM_VM_DATA (vm)->sp -= n + 1; vp->sp -= n + 1;
/* FIXME NULLSTACK */ /* FIXME NULLSTACK */
return vals; return vals;

View file

@ -22,7 +22,7 @@
#include "libguile/vm.h" #include "libguile/vm.h"
SCM_INTERNAL SCM scm_i_prompt_pop_abort_args_x (SCM vm); SCM_INTERNAL SCM scm_i_prompt_pop_abort_args_x (struct scm_vm *vp);
SCM_INTERNAL void scm_c_abort (struct scm_vm *vp, SCM tag, size_t n, SCM *argv, SCM_INTERNAL void scm_c_abort (struct scm_vm *vp, SCM tag, size_t n, SCM *argv,
scm_i_jmp_buf *registers) SCM_NORETURN; scm_i_jmp_buf *registers) SCM_NORETURN;

View file

@ -438,7 +438,8 @@ eval (SCM x, SCM env)
case SCM_M_CALL_WITH_PROMPT: case SCM_M_CALL_WITH_PROMPT:
{ {
SCM vm, k, res; struct scm_vm *vp;
SCM k, res;
scm_i_jmp_buf registers; scm_i_jmp_buf registers;
/* We need the handler after nonlocal return to the setjmp, so /* We need the handler after nonlocal return to the setjmp, so
make sure it is volatile. */ make sure it is volatile. */
@ -446,23 +447,24 @@ eval (SCM x, SCM env)
k = EVAL1 (CAR (mx), env); k = EVAL1 (CAR (mx), env);
handler = EVAL1 (CDDR (mx), env); handler = EVAL1 (CDDR (mx), env);
vm = scm_the_vm (); vp = SCM_VM_DATA (scm_the_vm ());
/* Push the prompt onto the dynamic stack. */ /* Push the prompt onto the dynamic stack. */
scm_dynstack_push_prompt scm_dynstack_push_prompt (&SCM_I_CURRENT_THREAD->dynstack,
(&SCM_I_CURRENT_THREAD->dynstack, SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY
SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY | SCM_F_DYNSTACK_PROMPT_PUSH_NARGS, | SCM_F_DYNSTACK_PROMPT_PUSH_NARGS,
k, k,
SCM_VM_DATA (vm)->fp - SCM_VM_DATA (vm)->stack_base, vp->fp - vp->stack_base,
SCM_VM_DATA (vm)->sp - SCM_VM_DATA (vm)->stack_base, vp->sp - vp->stack_base,
SCM_VM_DATA (vm)->ip, vp->ip,
&registers); &registers);
if (SCM_I_SETJMP (registers)) if (SCM_I_SETJMP (registers))
{ {
/* The prompt exited nonlocally. */ /* The prompt exited nonlocally. */
proc = handler; proc = handler;
args = scm_i_prompt_pop_abort_args_x (scm_the_vm ()); vp = SCM_VM_DATA (scm_the_vm ());
args = scm_i_prompt_pop_abort_args_x (vp);
goto apply_proc; goto apply_proc;
} }

View file

@ -456,7 +456,8 @@ SCM_SYMBOL (sym_pre_init_catch_tag, "%pre-init-catch-tag");
static SCM static SCM
pre_init_catch (SCM tag, SCM thunk, SCM handler, SCM pre_unwind_handler) pre_init_catch (SCM tag, SCM thunk, SCM handler, SCM pre_unwind_handler)
{ {
volatile SCM vm, v_handler; struct scm_vm *vp;
volatile SCM v_handler;
SCM res; SCM res;
scm_t_dynstack *dynstack = &SCM_I_CURRENT_THREAD->dynstack; scm_t_dynstack *dynstack = &SCM_I_CURRENT_THREAD->dynstack;
scm_i_jmp_buf registers; scm_i_jmp_buf registers;
@ -469,7 +470,7 @@ pre_init_catch (SCM tag, SCM thunk, SCM handler, SCM pre_unwind_handler)
/* These two are volatile, so we know we can access them after a /* These two are volatile, so we know we can access them after a
nonlocal return to the setjmp. */ nonlocal return to the setjmp. */
vm = scm_the_vm (); vp = SCM_VM_DATA (scm_the_vm ());
v_handler = handler; v_handler = handler;
/* Push the prompt onto the dynamic stack. */ /* Push the prompt onto the dynamic stack. */
@ -477,15 +478,18 @@ pre_init_catch (SCM tag, SCM thunk, SCM handler, SCM pre_unwind_handler)
SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY
| SCM_F_DYNSTACK_PROMPT_PUSH_NARGS, | SCM_F_DYNSTACK_PROMPT_PUSH_NARGS,
sym_pre_init_catch_tag, sym_pre_init_catch_tag,
SCM_VM_DATA (vm)->fp - SCM_VM_DATA (vm)->stack_base, vp->fp - vp->stack_base,
SCM_VM_DATA (vm)->sp - SCM_VM_DATA (vm)->stack_base, vp->sp - vp->stack_base,
SCM_VM_DATA (vm)->ip, vp->ip,
&registers); &registers);
if (SCM_I_SETJMP (registers)) if (SCM_I_SETJMP (registers))
{ {
/* nonlocal exit */ /* nonlocal exit */
SCM args = scm_i_prompt_pop_abort_args_x (vm); SCM args;
/* vp is not volatile */
vp = SCM_VM_DATA (scm_the_vm ());
args = scm_i_prompt_pop_abort_args_x (vp);
/* cdr past the continuation */ /* cdr past the continuation */
return scm_apply_0 (v_handler, scm_cdr (args)); return scm_apply_0 (v_handler, scm_cdr (args));
} }