diff options
author | Andy Wingo <wingo@pobox.com> | 2010-02-06 17:00:03 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-02-08 13:00:54 +0100 |
commit | 1d1cae0e2e063d9a36e7d600f87cf3d6eaf940f3 (patch) | |
tree | 136a102cc12ca78edbcb740ecc11f89fa0920e7b /libguile/continuations.h | |
parent | 217167c6b2e6e400306c8cb4a0bff86c17eef28c (diff) | |
download | guile-1d1cae0e2e063d9a36e7d600f87cf3d6eaf940f3.tar.gz |
continuations are vm procedures
* libguile/vm-i-system.c (continuation-call): New op, like subr-call or
foreign-call, but for continuations.
* libguile/continuations.h: Add scm_i_continuation_call internal
declaration.
(SCM_CONTINUATIONP): Reimplement in terms of
SCM_PROGRAM_IS_CONTINUATION.
(scm_tc16_continuation, SCM_CONTREGS, SCM_CONTINUATION_LENGTH)
(SCM_SET_CONTINUATION_LENGTH, SCM_JMPBUF, SCM_DYNENV, SCM_THROW_VALUE)
(SCM_CONTINUATION_ROOT, SCM_DFRAME): Remove these from the exposed
API.
(scm_i_continuation_to_frame): New internal declaration.
* libguile/continuations.c
* libguile/continuations.c: Add trickery like in foreign.c, smob.c, and
gsubr.c, so that we can make procedural trampolines for continuations.
(scm_i_continuation_to_frame): New internal function, from stacks.c.
* libguile/programs.h (SCM_F_PROGRAM_IS_CONTINUATION)
(SCM_PROGRAM_IS_CONTINUATION): Add a flag for programs that are
continuations. Probably should add flags for the other trampoline
types too.
* libguile/programs.c (scm_i_program_print): Print continuations as
before.
* libguile/stacks.c (scm_stack_id, scm_make_stack): Use
scm_i_continuation_to_frame in the continuation case.
Diffstat (limited to 'libguile/continuations.h')
-rw-r--r-- | libguile/continuations.h | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/libguile/continuations.h b/libguile/continuations.h index a04c53f2c..a15a0fd0c 100644 --- a/libguile/continuations.h +++ b/libguile/continuations.h @@ -3,7 +3,7 @@ #ifndef SCM_CONTINUATIONS_H #define SCM_CONTINUATIONS_H -/* Copyright (C) 1995,1996,2000,2001, 2006, 2008, 2009 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,2000,2001, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -31,6 +31,9 @@ #endif /* __ia64__ */ +#define SCM_CONTINUATIONP(x) \ + (SCM_PROGRAM_P (x) && SCM_PROGRAM_IS_CONTINUATION (x)) + /* a continuation SCM is a non-immediate pointing to a heap cell with: word 0: bits 0-15: smob type tag: scm_tc16_continuation. bits 16-31: unused. @@ -39,8 +42,6 @@ in the num_stack_items field of the structure. */ -SCM_API scm_t_bits scm_tc16_continuation; - typedef struct { SCM throw_value; @@ -67,22 +68,12 @@ typedef struct SCM_STACKITEM stack[1]; /* copied stack of size num_stack_items. */ } scm_t_contregs; -#define SCM_CONTINUATIONP(x) SCM_TYP16_PREDICATE (scm_tc16_continuation, x) - -#define SCM_CONTREGS(x) ((scm_t_contregs *) SCM_SMOB_DATA_1 (x)) - -#define SCM_CONTINUATION_LENGTH(x) (SCM_CONTREGS (x)->num_stack_items) -#define SCM_SET_CONTINUATION_LENGTH(x, n)\ - (SCM_CONTREGS (x)->num_stack_items = (n)) -#define SCM_JMPBUF(x) ((SCM_CONTREGS (x))->jmpbuf) -#define SCM_DYNENV(x) ((SCM_CONTREGS (x))->dynenv) -#define SCM_THROW_VALUE(x) ((SCM_CONTREGS (x))->throw_value) -#define SCM_CONTINUATION_ROOT(x) ((SCM_CONTREGS (x))->root) -#define SCM_DFRAME(x) ((SCM_CONTREGS (x))->dframe) SCM_API SCM scm_make_continuation (int *first); +SCM_INTERNAL SCM scm_i_continuation_to_frame (SCM cont); +SCM_INTERNAL void scm_i_continuation_call (SCM cont, size_t n, SCM *argv); SCM_API void *scm_c_with_continuation_barrier (void *(*func)(void*), void *); SCM_API SCM scm_with_continuation_barrier (SCM proc); |