[uim-commit] r2051 - branches/r5rs/sigscheme
kzk at freedesktop.org
kzk at freedesktop.org
Mon Nov 7 02:29:07 PST 2005
Author: kzk
Date: 2005-11-07 02:29:03 -0800 (Mon, 07 Nov 2005)
New Revision: 2051
Modified:
branches/r5rs/sigscheme/operations-srfi34.c
branches/r5rs/sigscheme/sigschemeinternal.h
branches/r5rs/sigscheme/sigschemetype.h
branches/r5rs/sigscheme/storage-continuation.c
branches/r5rs/sigscheme/storage-gc.c
branches/r5rs/sigscheme/storage.c
Log:
* Change continuation data structure
* sigscheme/sigschemetype.h
- (struct ScmContinuationInfo): new struct
- (ScmCell_.obj.continuation): change structure
- (SCM_CONTINUATION_OPAQUE0, SCM_CONTINUATION_SET_OPAQUE0
SCM_CONTINUATION_OPAQUE1, SCM_CONTINUATION_SET_OPAQUE1): removed
- (SCM_CONTINUATION_INFO, SCM_CONTINUATION_SET_INFO,
SCM_CONTINUATION_JMPENV, SCM_CONTINUATION_SET_JMPENV,
SCM_CONTINUATION_DYNEXT, SCM_CONTINUATION_SET_DYNEXT): new macro
* sigscheme/sigschemeinternal.h
- (CONTINUATION_JMPENV, CONTINUATION_SET_JMPENV,
CONTINUATION_DYNEXT, CONTINUATION_SET_DYNEXT): removed
* sigscheme/storage-continuation.c
- (continuation_stack_unwind, Scm_CallWithCurrentContinuation,
Scm_CallContinuation): use new SCM_CONTINUATION* macro
* sigscheme/operations-srfi34.c
- (ScmOp_SRFI34_with_exception_handler, ScmExp_SRFI34_guard,
ScmOp_SRFI34_raise): use new SCM_CONTINUATION* macro
- (CONTINUATION_JMPENV, CONTINUATION_SET_JMPENV): removed
* sigscheme/storage-gc.c
- (sweep_obj): free ScmContinuationInfo
* sigscheme/storage.c
- (Scm_NewContinuation): change to allocate new structure
Modified: branches/r5rs/sigscheme/operations-srfi34.c
===================================================================
--- branches/r5rs/sigscheme/operations-srfi34.c 2005-11-07 10:04:01 UTC (rev 2050)
+++ branches/r5rs/sigscheme/operations-srfi34.c 2005-11-07 10:29:03 UTC (rev 2051)
@@ -50,8 +50,6 @@
/*=======================================
File Local Macro Declarations
=======================================*/
-#define CONTINUATION_JMPENV SCM_CONTINUATION_OPAQUE0
-#define CONTINUATION_SET_JMPENV SCM_CONTINUATION_SET_OPAQUE0
/*=======================================
Variable Declarations
@@ -102,8 +100,8 @@
ASSERT_PROCEDUREP(handler);
ASSERT_PROCEDUREP(thunk);
- CONTINUATION_SET_JMPENV(cont, &jmpenv);
- if (setjmp(CONTINUATION_JMPENV(cont))) {
+ SCM_CONTINUATION_SET_JMPENV(cont, &jmpenv);
+ if (setjmp(SCM_CONTINUATION_JMPENV(cont))) {
ret = Scm_call(CURRENT_EXCEPTION_HANDLER(), LIST_1(exception_thrown_obj));
POP_EXCEPTION_CONTINUATION();
POP_EXCEPTION_HANDLER();
@@ -143,8 +141,8 @@
ASSERT_SYMBOLP(var);
/* check if return from "raise" */
- CONTINUATION_SET_JMPENV(cont, &jmpenv);
- if (setjmp(CONTINUATION_JMPENV(cont))) {
+ SCM_CONTINUATION_SET_JMPENV(cont, &jmpenv);
+ if (setjmp(SCM_CONTINUATION_JMPENV(cont))) {
POP_EXCEPTION_CONTINUATION();
env = Scm_ExtendEnvironment(LIST_1(var), LIST_1(exception_thrown_obj), env);
return guard_handle_clauses(clauses, env);
@@ -242,7 +240,7 @@
exception_thrown_obj = obj;
- env = CONTINUATION_JMPENV(CURRENT_EXCEPTION_CONTINUATION());
+ env = SCM_CONTINUATION_JMPENV(CURRENT_EXCEPTION_CONTINUATION());
longjmp(*env, 1);
/* never reaches here */
Modified: branches/r5rs/sigscheme/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/sigschemeinternal.h 2005-11-07 10:04:01 UTC (rev 2050)
+++ branches/r5rs/sigscheme/sigschemeinternal.h 2005-11-07 10:29:03 UTC (rev 2051)
@@ -319,10 +319,6 @@
/* Macros For Handling Continuation Object */
#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
/* Symbol Name Hash Size */
#define NAMEHASH_SIZE 1024
Modified: branches/r5rs/sigscheme/sigschemetype.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype.h 2005-11-07 10:04:01 UTC (rev 2050)
+++ branches/r5rs/sigscheme/sigschemetype.h 2005-11-07 10:29:03 UTC (rev 2051)
@@ -38,6 +38,7 @@
System Include
=======================================*/
#include <stdio.h>
+#include <setjmp.h>
/*=======================================
Local Include
@@ -157,6 +158,11 @@
#define SCM_CHARCELL_SIZE 8
+struct ScmContinuationInfo {
+ void *jmpenv;
+ ScmObj dynext;
+};
+
/* Scheme Object */
struct ScmCell_ {
enum ScmObjType type;
@@ -212,8 +218,7 @@
} port;
struct ScmContinuation {
- void *opaque0;
- void *opaque1;
+ struct ScmContinuationInfo *info;
} continuation;
#if !SCM_USE_VALUECONS
@@ -335,12 +340,14 @@
#define SCM_PORT_IMPL(a) (SCM_AS_PORT(a)->obj.port.impl)
#define SCM_PORT_SET_IMPL(a, impl) (SCM_PORT_IMPL(a) = (impl))
-#define SCM_CONTINUATIONP(a) (SCM_TYPE(a) == ScmContinuation)
-#define SCM_ENTYPE_CONTINUATION(a) (SCM_ENTYPE((a), ScmContinuation))
-#define SCM_CONTINUATION_OPAQUE0(a) (SCM_AS_CONTINUATION(a)->obj.continuation.opaque0)
-#define SCM_CONTINUATION_SET_OPAQUE0(a, val) (SCM_CONTINUATION_OPAQUE0(a) = (val))
-#define SCM_CONTINUATION_OPAQUE1(a) (SCM_AS_CONTINUATION(a)->obj.continuation.opaque1)
-#define SCM_CONTINUATION_SET_OPAQUE1(a, val) (SCM_CONTINUATION_OPAQUE1(a) = (val))
+#define SCM_CONTINUATIONP(a) (SCM_TYPE(a) == ScmContinuation)
+#define SCM_ENTYPE_CONTINUATION(a) (SCM_ENTYPE((a), ScmContinuation))
+#define SCM_CONTINUATION_INFO(a) (SCM_AS_CONTINUATION(a)->obj.continuation.info)
+#define SCM_CONTINUATION_SET_INFO(a, info) (SCM_CONTINUATION_INFO(a) = info)
+#define SCM_CONTINUATION_JMPENV(a) (SCM_CONTINUATION_INFO(a)->jmpenv)
+#define SCM_CONTINUATION_SET_JMPENV(a, env) (SCM_CONTINUATION_JMPENV(a) = (void*)env)
+#define SCM_CONTINUATION_DYNEXT(a) (SCM_CONTINUATION_INFO(a)->dynext)
+#define SCM_CONTINUATION_SET_DYNEXT(a, dyn) (SCM_CONTINUATION_DYNEXT(a) = dyn)
#if SCM_USE_VALUECONS
/* to modify a VALUECONS, rewrite its type to cons by SCM_ENTYPE_CONS(vcons) */
Modified: branches/r5rs/sigscheme/storage-continuation.c
===================================================================
--- branches/r5rs/sigscheme/storage-continuation.c 2005-11-07 10:04:01 UTC (rev 2050)
+++ branches/r5rs/sigscheme/storage-continuation.c 2005-11-07 10:29:03 UTC (rev 2051)
@@ -227,7 +227,7 @@
cont = continuation_stack_pop();
if (FALSEP(cont))
return SCM_FALSE;
- CONTINUATION_SET_JMPENV(cont, INVALID_CONTINUATION_JMPENV);
+ SCM_CONTINUATION_SET_JMPENV(cont, INVALID_CONTINUATION_JMPENV);
} while (!EQ(dest_cont, cont));
return dest_cont;
@@ -241,7 +241,7 @@
struct trace_frame *saved_trace_stack;
cont = Scm_NewContinuation();
- CONTINUATION_SET_JMPENV(cont, &env);
+ SCM_CONTINUATION_SET_JMPENV(cont, &env);
#if SCM_NESTED_CONTINUATION_ONLY
continuation_stack_push(cont);
#endif
@@ -252,7 +252,7 @@
continuation_thrown_obj = SCM_FALSE; /* make ret sweepable */
trace_stack = saved_trace_stack;
- enter_dynamic_extent(CONTINUATION_DYNEXT(cont));
+ enter_dynamic_extent(SCM_CONTINUATION_DYNEXT(cont));
eval_state->ret_type = SCM_RETTYPE_AS_IS;
return ret;
@@ -285,7 +285,7 @@
{
jmp_buf *env;
- env = CONTINUATION_JMPENV(cont);
+ env = SCM_CONTINUATION_JMPENV(cont);
if (env != INVALID_CONTINUATION_JMPENV
#if SCM_NESTED_CONTINUATION_ONLY
@@ -293,7 +293,7 @@
#endif
)
{
- exit_dynamic_extent(CONTINUATION_DYNEXT(cont));
+ exit_dynamic_extent(SCM_CONTINUATION_DYNEXT(cont));
continuation_thrown_obj = ret;
longjmp(*env, 1);
Modified: branches/r5rs/sigscheme/storage-gc.c
===================================================================
--- branches/r5rs/sigscheme/storage-gc.c 2005-11-07 10:04:01 UTC (rev 2050)
+++ branches/r5rs/sigscheme/storage-gc.c 2005-11-07 10:29:03 UTC (rev 2051)
@@ -564,8 +564,12 @@
SCM_PORT_CLOSE_IMPL(obj);
break;
+ case ScmContinuation:
+ if (SCM_CONTINUATION_INFO(obj))
+ free(SCM_CONTINUATION_INFO(obj));
+ break;
+
/* rarely swept objects */
- case ScmContinuation:
case ScmFunc:
case ScmConstant:
case ScmFreeCell:
Modified: branches/r5rs/sigscheme/storage.c
===================================================================
--- branches/r5rs/sigscheme/storage.c 2005-11-07 10:04:01 UTC (rev 2050)
+++ branches/r5rs/sigscheme/storage.c 2005-11-07 10:29:03 UTC (rev 2051)
@@ -284,11 +284,14 @@
ScmObj Scm_NewContinuation(void)
{
ScmObj obj = SigScm_NewObjFromHeap();
+ struct ScmContinuationInfo *info = (struct ScmContinuationInfo*)malloc(sizeof(struct ScmContinuationInfo));
SCM_ENTYPE_CONTINUATION(obj);
- CONTINUATION_SET_JMPENV(obj, INVALID_CONTINUATION_JMPENV);
- CONTINUATION_SET_DYNEXT(obj, scm_current_dynamic_extent);
+ SCM_CONTINUATION_SET_INFO(obj, info);
+ SCM_CONTINUATION_SET_JMPENV(obj, INVALID_CONTINUATION_JMPENV);
+ SCM_CONTINUATION_SET_DYNEXT(obj, scm_current_dynamic_extent);
+
return obj;
}
More information about the uim-commit
mailing list