the dynamic stack is really a stack now, instead of a list
* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
2012-03-03 17:01:16 +01:00
|
|
|
|
/* Copyright (C) 1995,1996,1997,1998,1999,2000, 2001, 2002, 2006, 2008, 2009, 2012 Free Software Foundation, Inc.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
|
|
* as published by the Free Software Foundation; either version 3 of
|
|
|
|
|
|
* the License, or (at your option) any later version.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
|
* 02110-1301 USA
|
2003-04-05 19:15:35 +00:00
|
|
|
|
*/
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2008-09-13 15:35:27 +02:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
|
# include <config.h>
|
|
|
|
|
|
#endif
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2001-03-09 23:33:41 +00:00
|
|
|
|
#include <string.h>
|
2005-03-02 20:42:01 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
|
|
|
|
|
#include "libguile/stackchk.h"
|
|
|
|
|
|
#include "libguile/dynwind.h"
|
|
|
|
|
|
#include "libguile/eval.h"
|
|
|
|
|
|
#include "libguile/smob.h"
|
|
|
|
|
|
#include "libguile/pairs.h"
|
|
|
|
|
|
#include "libguile/throw.h"
|
|
|
|
|
|
#include "libguile/fluids.h"
|
|
|
|
|
|
#include "libguile/ports.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "libguile/root.h"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
/* {call-with-dynamic-root}
|
1996-10-01 03:19:14 +00:00
|
|
|
|
*
|
|
|
|
|
|
* Suspending the current thread to evaluate a thunk on the
|
|
|
|
|
|
* same C stack but under a new root.
|
|
|
|
|
|
*
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
* Calls to call-with-dynamic-root return exactly once (unless
|
1997-10-02 15:00:03 +00:00
|
|
|
|
* the process is somehow exitted). */
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
/* cwdr fills out both of these structures, and then passes a pointer
|
|
|
|
|
|
to them through scm_internal_catch to the cwdr_body and
|
|
|
|
|
|
cwdr_handler functions, to tell them how to behave and to get
|
|
|
|
|
|
information back from them.
|
1996-12-09 02:15:17 +00:00
|
|
|
|
|
|
|
|
|
|
A cwdr is a lot like a catch, except there is no tag (all
|
|
|
|
|
|
exceptions are caught), and the body procedure takes the arguments
|
1997-10-02 15:00:03 +00:00
|
|
|
|
passed to cwdr as A1 and ARGS. The handler is also special since
|
|
|
|
|
|
it is not directly run from scm_internal_catch. It is executed
|
|
|
|
|
|
outside the new dynamic root. */
|
1996-12-09 02:15:17 +00:00
|
|
|
|
|
|
|
|
|
|
struct cwdr_body_data {
|
|
|
|
|
|
/* Arguments to pass to the cwdr body function. */
|
|
|
|
|
|
SCM a1, args;
|
|
|
|
|
|
|
|
|
|
|
|
/* Scheme procedure to use as body of cwdr. */
|
|
|
|
|
|
SCM body_proc;
|
1997-10-02 15:00:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct cwdr_handler_data {
|
|
|
|
|
|
/* Do we need to run the handler? */
|
|
|
|
|
|
int run_handler;
|
1997-06-23 04:34:34 +00:00
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
/* The tag and args to pass it. */
|
|
|
|
|
|
SCM tag, args;
|
1996-12-09 02:15:17 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Invoke the body of a cwdr, assuming that the throw handler has
|
|
|
|
|
|
already been set up. DATA points to a struct set up by cwdr that
|
* throw.c (scm_internal_catch): Make body funcs and handler funcs
use separate data pointers, to allow them to be designed
independently and reused.
(scm_body_thunk, scm_handle_by_proc, scm_handle_by_message):
Renamed from catch_body, catch_handler, and uncaught_throw; made
generically useful.
(struct scm_catch_body_data): Renamed from catch_body_data; moved
to throw.h.
(scm_catch): Use the above.
(scm_throw): Don't bother printing a message for an uncaught
throw; we establish a default handler in init.
* throw.h (scm_internal_catch): Prototype updated.
(scm_body_thunk, scm_handle_by_proc, scm_handle_by_message): New
decls.
(struct scm_body_thunk_data): New structure, used as data
argument to scm_body_thunk.
* init.c (struct main_func_closure): New structure, packaging up
the data to pass to the user's main function.
(scm_boot_guile): Create one. Pass it to scm_boot_guile_1.
(scm_boot_guile_1): Pass it through to invoke_main_func. Use
scm_internal_catch to establish a catch-all handler, using
scm_handle_by_message. This replaces the special-case code in
scm_throw.
(invoke_main_func): Body function for scm_internal_catch; invoke
the user's main function, using the main_func_closure pointer to
decide what to pass it.
* root.c (struct cwdr_body_data): Remove handler_proc member.
(cwdr): Use scm_handle_by_proc instead of cwdr_handler.
(cwdr_handler): Removed.
1996-12-21 04:48:21 +00:00
|
|
|
|
says what proc to call, and what args to apply it to.
|
|
|
|
|
|
|
|
|
|
|
|
With a little thought, we could replace this with scm_body_thunk,
|
|
|
|
|
|
but I don't want to mess with that at the moment. */
|
1996-12-09 02:15:17 +00:00
|
|
|
|
static SCM
|
* backtrace.c (display_error_body, display_backtrace_body),
coop-threads.c (scheme_body_bootstrip, c_body_bootstrip),
gh_eval.c (eval_str_wrapper, eval_file_wrapper), init.c
(invoke_main_func), root.c (cwdr_body), throw.c (cwss_body,
scm_body_thunk, hbpca_body): Removed the second jmpbuf arg on body
functions.
1998-02-02 15:00:14 +00:00
|
|
|
|
cwdr_body (void *data)
|
1996-12-09 02:15:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
struct cwdr_body_data *c = (struct cwdr_body_data *) data;
|
|
|
|
|
|
|
|
|
|
|
|
return scm_apply (c->body_proc, c->a1, c->args);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
/* Record the fact that the body of the cwdr has thrown. Record
|
|
|
|
|
|
enough information to invoke the handler later when the dynamic
|
|
|
|
|
|
root has been deestablished. */
|
1996-12-09 02:15:17 +00:00
|
|
|
|
|
1997-06-23 04:34:34 +00:00
|
|
|
|
static SCM
|
1997-10-02 15:00:03 +00:00
|
|
|
|
cwdr_handler (void *data, SCM tag, SCM args)
|
1997-06-23 04:34:34 +00:00
|
|
|
|
{
|
1997-10-02 15:00:03 +00:00
|
|
|
|
struct cwdr_handler_data *c = (struct cwdr_handler_data *) data;
|
1997-06-23 04:34:34 +00:00
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
c->run_handler = 1;
|
|
|
|
|
|
c->tag = tag;
|
|
|
|
|
|
c->args = args;
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
1997-06-23 04:34:34 +00:00
|
|
|
|
}
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
SCM
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_internal_cwdr (scm_t_catch_body body, void *body_data,
|
|
|
|
|
|
scm_t_catch_handler handler, void *handler_data,
|
1997-10-02 15:00:03 +00:00
|
|
|
|
SCM_STACKITEM *stack_start)
|
1996-10-01 03:19:14 +00:00
|
|
|
|
{
|
1997-10-02 15:00:03 +00:00
|
|
|
|
struct cwdr_handler_data my_handler_data;
|
the dynamic stack is really a stack now, instead of a list
* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
2012-03-03 17:01:16 +01:00
|
|
|
|
scm_t_dynstack *dynstack = &SCM_I_CURRENT_THREAD->dynstack;
|
|
|
|
|
|
SCM answer;
|
|
|
|
|
|
scm_t_dynstack *old_dynstack;
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
1996-10-05 16:50:27 +00:00
|
|
|
|
/* Exit caller's dynamic state.
|
|
|
|
|
|
*/
|
the dynamic stack is really a stack now, instead of a list
* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
2012-03-03 17:01:16 +01:00
|
|
|
|
old_dynstack = scm_dynstack_capture_all (dynstack);
|
|
|
|
|
|
scm_dynstack_unwind (dynstack, SCM_DYNSTACK_FIRST (dynstack));
|
2005-03-02 20:42:01 +00:00
|
|
|
|
|
2006-01-29 00:23:28 +00:00
|
|
|
|
scm_dynwind_begin (SCM_F_DYNWIND_REWINDABLE);
|
|
|
|
|
|
scm_dynwind_current_dynamic_state (scm_make_dynamic_state (SCM_UNDEFINED));
|
1997-10-02 15:00:03 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
my_handler_data.run_handler = 0;
|
|
|
|
|
|
answer = scm_i_with_continuation_barrier (body, body_data,
|
* throw.h (scm_c_catch, scm_c_with_throw_handler,
scm_catch_with_pre_unwind_handler, scm_with_throw_handler): New.
* throw.c (SCM_JBPREUNWIND, SCM_SETJBPREUNWIND): New.
(struct pre_unwind_data): New, replaces struct lazy_catch.
(scm_c_catch): New, replaces scm_internal_catch as the primary
catch API for C code; adds pre-unwind handler support.
(scm_internal_catch): Now just a wrapper for scm_c_catch, for back
compatibility.
(tc16_pre_unwind_data, pre_unwind_data_print,
make_pre_unwind_data, SCM_PRE_UNWIND_DATA_P): Renamed from
"lazy_catch" equivalents.
(scm_c_with_throw_handler): New, replaces scm_internal_lazy_catch
as the primary C API for a "lazy" catch.
(scm_internal_lazy_catch): Now just a wrapper for
scm_c_with_throw_handler, for back compatibility.
(scm_catch_with_pre_unwind_handler): Renamed from scm_catch; adds
pre-unwind handler support.
(scm_catch): Now just a wrapper for
scm_catch_with_pre_unwind_handler, for back compatibility.
(scm_with_throw_handler): New.
(scm_lazy_catch): Update comment to say that the handler can
return, and what happens if it does.
(toggle_pre_unwind_running): New.
(scm_ithrow): When identifying the throw target, take running
flags into account. In general, change naming of things from
"lazy_catch" to "pre_unwind". When throwing to a throw handler,
don't unwind the dynamic context first. Add dynwind framing to
manage the running flag of a throw handler. If a lazy catch or
throw handler returns, rethrow the same exception again. Add
pre-unwind support to the normal catch case (SCM_JMPBUFP).
* root.c (scm_internal_cwdr): Add NULL args to
scm_i_with_continuation_barrier call.
* dynwind.c: Change comment mentioning lazy-catch to mention
pre-unwind data and throw handler also.
* continuations.h (scm_i_with_continuation_barrier): Add
pre-unwind handler args.
* continuations.c (scm_i_with_continuation_barrier): Add
pre-unwind handler args, and pass on to scm_c_catch (changed from
scm_internal_catch).
(c_handler): Remove scm_handle_by_message_noexit call.
(scm_c_with_continuation_barrier): Call
scm_i_with_continuation_barrier with scm_handle_by_message_noexit
as the pre-unwind handler.
(scm_handler): Remove scm_handle_by_message_noexit call.
(s_scm_with_continuation_barrier): Call
scm_i_with_continuation_barrier with scm_handle_by_message_noexit
as the pre-unwind handler.
2006-02-04 14:36:24 +00:00
|
|
|
|
cwdr_handler, &my_handler_data,
|
|
|
|
|
|
NULL, NULL);
|
2005-03-02 20:42:01 +00:00
|
|
|
|
|
2006-01-29 00:23:28 +00:00
|
|
|
|
scm_dynwind_end ();
|
2005-03-02 20:42:01 +00:00
|
|
|
|
|
|
|
|
|
|
/* Enter caller's dynamic state.
|
|
|
|
|
|
*/
|
the dynamic stack is really a stack now, instead of a list
* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
2012-03-03 17:01:16 +01:00
|
|
|
|
scm_dynstack_wind (dynstack, SCM_DYNSTACK_FIRST (old_dynstack));
|
1997-10-02 15:00:03 +00:00
|
|
|
|
|
|
|
|
|
|
/* Now run the real handler iff the body did a throw. */
|
|
|
|
|
|
if (my_handler_data.run_handler)
|
|
|
|
|
|
return handler (handler_data, my_handler_data.tag, my_handler_data.args);
|
|
|
|
|
|
else
|
|
|
|
|
|
return answer;
|
1996-10-01 03:19:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
/* The original CWDR for invoking Scheme code with a Scheme handler. */
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
cwdr (SCM proc, SCM a1, SCM args, SCM handler, SCM_STACKITEM *stack_start)
|
|
|
|
|
|
{
|
|
|
|
|
|
struct cwdr_body_data c;
|
|
|
|
|
|
|
|
|
|
|
|
c.a1 = a1;
|
|
|
|
|
|
c.args = args;
|
|
|
|
|
|
c.body_proc = proc;
|
|
|
|
|
|
|
|
|
|
|
|
return scm_internal_cwdr (cwdr_body, &c,
|
|
|
|
|
|
scm_handle_by_proc, &handler,
|
|
|
|
|
|
stack_start);
|
|
|
|
|
|
}
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_call_with_dynamic_root, "call-with-dynamic-root", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM thunk, SCM handler),
|
fix typos in the manual bits generated from source comments.
* libguile/bitvectors.c, libguile/chars.c,
libguile/deprecated.c, libguile/numbers.c, libguile/random.c,
libguile/read.c, libguile/root.c, libguile/srfi-1.c,
libguile/srfi-13.c, libguile/srfi-14.c, libguile/uniform.c:
Fix typos, add missing newlines.
2011-02-07 00:29:51 +01:00
|
|
|
|
"Call @var{thunk} with a new dynamic state and within\n"
|
|
|
|
|
|
"a continuation barrier. The @var{handler} catches all\n"
|
|
|
|
|
|
"otherwise uncaught throws and executes within the same\n"
|
2005-03-04 17:06:19 +00:00
|
|
|
|
"dynamic context as @var{thunk}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_call_with_dynamic_root
|
1996-10-01 03:19:14 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM_STACKITEM stack_place;
|
1996-10-05 16:50:27 +00:00
|
|
|
|
return cwdr (thunk, SCM_EOL, SCM_EOL, handler, &stack_place);
|
1996-10-01 03:19:14 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_dynamic_root, "dynamic-root", 0, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Return an object representing the current dynamic root.\n\n"
|
2005-03-02 20:42:01 +00:00
|
|
|
|
"These objects are only useful for comparison using @code{eq?}.\n")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_dynamic_root
|
1996-10-01 03:19:14 +00:00
|
|
|
|
{
|
2005-03-02 20:42:01 +00:00
|
|
|
|
return SCM_I_CURRENT_THREAD->continuation_root;
|
1996-10-01 03:19:14 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
|
|
|
|
|
SCM
|
1999-12-12 02:36:16 +00:00
|
|
|
|
scm_apply_with_dynamic_root (SCM proc, SCM a1, SCM args, SCM handler)
|
1996-10-01 03:19:14 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM_STACKITEM stack_place;
|
1996-10-05 16:50:27 +00:00
|
|
|
|
return cwdr (proc, a1, args, handler, &stack_place);
|
1996-10-01 03:19:14 +00:00
|
|
|
|
}
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-01 03:19:14 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_init_root ()
|
|
|
|
|
|
{
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/root.x"
|
1996-10-01 03:19:14 +00:00
|
|
|
|
}
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|