[uim-commit] r1801 - branches/r5rs/sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Tue Oct 4 08:04:25 PDT 2005
Author: yamaken
Date: 2005-10-04 08:04:22 -0700 (Tue, 04 Oct 2005)
New Revision: 1801
Modified:
branches/r5rs/sigscheme/datas.c
Log:
* This commit enables dynamic extent aware continuation handling. The
two dynamic-wind tests of test-exp.scm has been passed
* sigscheme/datas.c
- (INVALID_CONTINUATION_JMPENV, CONTINUATION_DYNEXT,
CONTINUATION_SET_DYNEXT): New macro
- (CONTINUATION_UPPER, CONTINUATION_SET_UPPER,
INVALID_CONTINUATION): Removed
- (Scm_NewContinuation):
* Initialize jmpenv slot with INVALID_CONTINUATION_JMPENV
* Set current dynamic extent to the continuation object
- (enter_dynamic_extent, exit_dynamic_extent): Fix an incorrect loop
- (continuation_stack_push): Change continuation_stack format
- (continuation_stack_pop):
* Ditto
* Return SCM_FALSE when the stack is SCM_NULL
- (continuation_stack_unwind): Return SCM_FALSE when the unwinding
has been failed
- (Scm_CallWithCurrentContinuation): Add dynamic extent handling
- (Scm_CallContinuation):
* Ditto
* Follow the interface change of continuation_stack_unwind
Modified: branches/r5rs/sigscheme/datas.c
===================================================================
--- branches/r5rs/sigscheme/datas.c 2005-10-04 14:27:49 UTC (rev 1800)
+++ branches/r5rs/sigscheme/datas.c 2005-10-04 15:04:22 UTC (rev 1801)
@@ -113,6 +113,13 @@
*/
#define SCM_NESTED_CONTINUATION_ONLY 1
+#define INVALID_CONTINUATION_JMPENV NULL
+
+#define CONTINUATION_JMPENV SCM_CONTINUATION_OPAQUE0
+#define CONTINUATION_SET_JMPENV SCM_CONTINUATION_SET_OPAQUE0
+#define CONTINUATION_DYNEXT SCM_CONTINUATION_OPAQUE1
+#define CONTINUATION_SET_DYNEXT SCM_CONTINUATION_SET_OPAQUE1
+
#define NAMEHASH_SIZE 1024
#define SCM_NEW_OBJ_INTERNAL(VALNAME) \
@@ -826,8 +833,8 @@
SCM_NEW_OBJ_INTERNAL(obj);
SCM_ENTYPE_CONTINUATION(obj);
- SCM_CONTINUATION_SET_OPAQUE0(obj, NULL);
- SCM_CONTINUATION_SET_OPAQUE1(obj, NULL);
+ CONTINUATION_SET_JMPENV(obj, INVALID_CONTINUATION_JMPENV);
+ CONTINUATION_SET_DYNEXT(obj, current_dynamic_extent);
return obj;
}
@@ -907,10 +914,10 @@
ScmObj unwound = SCM_FALSE;
ScmObj retpath = SCM_NULL;
- /* assumes that (SCM_NULL != NULL) */
- for (unwound = dest; SCM_SHIFT_RAW(frame, unwound);) {
+ for (unwound = dest; !NULLP(unwound); unwound = CDR(unwound)) {
if (EQ(unwound, current_dynamic_extent))
break;
+ frame = CAR(unwound);
retpath = CONS(frame, retpath);
}
@@ -925,10 +932,13 @@
{
ScmObj frame = SCM_FALSE;
- /* assumes that (SCM_NULL != NULL) */
- while (SCM_SHIFT_RAW(frame, current_dynamic_extent)) {
+ for (;
+ !NULLP(current_dynamic_extent);
+ current_dynamic_extent = CDR(current_dynamic_extent))
+ {
if (EQ(current_dynamic_extent, dest))
return;
+ frame = CAR(current_dynamic_extent);
Scm_call(DYNEXT_FRAME_AFTER(frame), SCM_NULL);
}
}
@@ -951,13 +961,6 @@
/*============================================================================
Continuation
============================================================================*/
-#define CONTINUATION_JMPENV SCM_CONTINUATION_OPAQUE0
-#define CONTINUATION_SET_JMPENV SCM_CONTINUATION_SET_OPAQUE0
-#define CONTINUATION_UPPER SCM_CONTINUATION_OPAQUE1
-#define CONTINUATION_SET_UPPER SCM_CONTINUATION_SET_OPAQUE1
-
-#define INVALID_CONTINUATION NULL
-
static void initialize_continuation_env(void)
{
continuation_thrown_obj = SCM_FALSE;
@@ -972,16 +975,17 @@
static void continuation_stack_push(ScmObj cont)
{
- CONTINUATION_SET_UPPER(cont, continuation_stack);
- continuation_stack = cont;
+ continuation_stack = CONS(cont, continuation_stack);
}
static ScmObj continuation_stack_pop(void)
{
- ScmObj recentmost;
+ ScmObj recentmost = SCM_FALSE;
- recentmost = continuation_stack;
- continuation_stack = CONTINUATION_UPPER(continuation_stack);
+ if (!NULLP(continuation_stack)) {
+ recentmost = CAR(continuation_stack);
+ continuation_stack = CDR(continuation_stack);
+ }
return recentmost;
}
@@ -989,13 +993,13 @@
/* expire all descendant continuations and dest_cont */
static ScmObj continuation_stack_unwind(ScmObj dest_cont)
{
- ScmObj cont;
+ ScmObj cont = SCM_FALSE;
do {
- if (NULLP(continuation_stack))
- return INVALID_CONTINUATION;
cont = continuation_stack_pop();
- CONTINUATION_SET_JMPENV(cont, INVALID_CONTINUATION);
+ if (FALSEP(cont))
+ return SCM_FALSE;
+ CONTINUATION_SET_JMPENV(cont, INVALID_CONTINUATION_JMPENV);
} while (!EQ(dest_cont, cont));
return dest_cont;
@@ -1018,6 +1022,8 @@
ret = continuation_thrown_obj;
continuation_thrown_obj = SCM_FALSE; /* make ret sweepable */
+ enter_dynamic_extent(CONTINUATION_DYNEXT(cont));
+
eval_state->ret_type = SCM_RETTYPE_AS_IS;
return ret;
} else {
@@ -1050,12 +1056,14 @@
env = CONTINUATION_JMPENV(cont);
- if (env != INVALID_CONTINUATION
+ if (env != INVALID_CONTINUATION_JMPENV
#if SCM_NESTED_CONTINUATION_ONLY
- && continuation_stack_unwind(cont) != INVALID_CONTINUATION
+ && CONTINUATIONP(continuation_stack_unwind(cont))
#endif
)
{
+ exit_dynamic_extent(CONTINUATION_DYNEXT(cont));
+
continuation_thrown_obj = ret;
longjmp(*env, 1);
/* NOTREACHED */
More information about the uim-commit
mailing list