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

prompt as part of guile's primitive language

* libguile/control.h:
* libguile/control.c: Remove scm_atcontrol and scm_atprompt.
  (scm_c_make_prompt): Remove handler arg, as the handler is inline.
  (scm_abort): New primitive, exported to Scheme as `abort'. The
  compiler will also recognize calls to `abort', but this is the base
  case.
  (scm_init_control): Remove scm_register_control, just have this
  function, which adds `abort' to the `(guile)' module.

* libguile/eval.c (eval): Add SCM_M_PROMPT case.

* libguile/init.c (scm_i_init_guile): Change scm_register_control call
  into a nice orderly scm_init_control call.

* libguile/memoize.h: (scm_sym_at_prompt, SCM_M_PROMPT):
* libguile/memoize.c (MAKMEMO_PROMPT, scm_m_at_prompt, unmemoize): Add
  prompt support to the memoizer.

* libguile/vm-i-system.c (prompt): Fix to not expect a handler on the
  stack.

* module/ice-9/boot-9.scm (prompt): Add definition in terms of @prompt.

* module/ice-9/control.scm: Simplify, and don't play with the compiler
  here, now that prompt and abort are primitive.

* module/ice-9/eval.scm (primitive-eval): Add a prompt case.

* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Add @prompt and prompt.
This commit is contained in:
Andy Wingo 2010-02-19 22:44:24 +01:00
parent 0bc8874c04
commit 747022e4cb
11 changed files with 117 additions and 63 deletions

View file

@ -31,6 +31,7 @@
#include "libguile/alist.h"
#include "libguile/async.h"
#include "libguile/continuations.h"
#include "libguile/control.h"
#include "libguile/debug.h"
#include "libguile/deprecation.h"
#include "libguile/dynwind.h"
@ -424,6 +425,38 @@ eval (SCM x, SCM env)
return SCM_UNSPECIFIED;
}
case SCM_M_PROMPT:
{
SCM prompt, handler, res;
prompt = scm_c_make_prompt (scm_the_vm (), eval (CAR (mx), env), 0);
handler = eval (CDDR (mx), env);
scm_i_set_dynwinds (scm_cons (prompt, scm_i_dynwinds ()));
if (SCM_PROMPT_SETJMP (prompt))
{
/* The prompt exited nonlocally. The args are on the VM stack. */
size_t i, n;
SCM vals = SCM_EOL;
n = scm_to_size_t (SCM_PROMPT_REGISTERS (prompt)->sp[0]);
for (i = 0; i < n; i++)
vals = scm_cons (SCM_PROMPT_REGISTERS (prompt)->sp[-(i + 1)], vals);
/* The abort did reset the VM's registers, but then these values
were pushed on; so we need to pop them ourselves. */
SCM_VM_DATA (scm_the_vm ())->sp -= n + 1;
/* FIXME NULLSTACK */
/* FIXME mark cont as non-reentrant */
proc = handler;
args = vals;
goto apply_proc;
}
res = eval (CADR (mx), env);
scm_i_set_dynwinds (CDR (scm_i_dynwinds ()));
return res;
}
default:
abort ();
}