[uim-commit] r2078 - branches/r5rs/sigscheme
kzk at freedesktop.org
kzk at freedesktop.org
Tue Nov 8 02:37:59 PST 2005
Author: kzk
Date: 2005-11-08 02:37:55 -0800 (Tue, 08 Nov 2005)
New Revision: 2078
Modified:
branches/r5rs/sigscheme/sigschemetype-compact.h
branches/r5rs/sigscheme/storage.c
branches/r5rs/sigscheme/test-compact.c
Log:
* sigscheme/sigschemetype-compact.h
- (SCM_TAG_OTHERS_VALUE_OFFSET_CONTINUATION,
SCM_CONTINUATION_OPAQUE,
SCM_CONTINUATION_SET_OPAQUE,
SCM_CONTINUATION_TAG,
SCM_CONTINUATION_SET_TAG): new macro
* sigscheme/test-compact.c
- (Scm_CheckPort, Scm_CheckContinuation): enabled
* sigscheme/storage.c
- (Scm_Type): new func
Modified: branches/r5rs/sigscheme/sigschemetype-compact.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype-compact.h 2005-11-07 22:02:30 UTC (rev 2077)
+++ branches/r5rs/sigscheme/sigschemetype-compact.h 2005-11-08 10:37:55 UTC (rev 2078)
@@ -63,7 +63,7 @@
* ..000|11|1 : Values : all 0 (for efficiency)
* ..001|11|1 : Func : ScmFuncTypeCode
* ..010|11|1 : Port : ScmPortDirection
- * ..011|11|1 : Continuation : all 0 (for efficiency)
+ * ..011|11|1 : Continuation : tag
* ..100|11|1 : C Pointer : pointer type
* : 0 = void*, 1 = ScmFuncType
* ..101|11|1 : Reserved :
@@ -97,6 +97,7 @@
/*=======================================
Local Include
=======================================*/
+#include "baseport.h"
/*=======================================
Type Declarations
@@ -246,6 +247,7 @@
#define SCM_TAG_OTHERS_VALUE_OFFSET_VECTOR (SCM_GCBIT_WIDTH + SCM_TAG_WIDTH)
#define SCM_TAG_OTHERS_VALUE_OFFSET_FUNC (SCM_GCBIT_WIDTH + SCM_TAG_WIDTH + 3)
#define SCM_TAG_OTHERS_VALUE_OFFSET_PORT (SCM_GCBIT_WIDTH + SCM_TAG_WIDTH + 3)
+#define SCM_TAG_OTHERS_VALUE_OFFSET_CONTINUATION (SCM_GCBIT_WIDTH + SCM_TAG_WIDTH + 3)
/*==============================================================================
Masks Offsets, and Tags : IMM
@@ -476,15 +478,13 @@
#define SCM_PORT_SET_IMPL(a, impl) (SCM_AS_PORT(a)->car = (ScmObj)impl)
#define SCM_PORT_SET_FLAG(a, flag) (SCM_SET_VALUE_AS_INT(SCM_AS_PORT(a)->cdr, flag, SCM_TAG_OTHERS_VALUE_OFFSET_PORT, SCM_TAG_OTHERS_PORT))
-/*
-#define SCM_CONTINUATION_INFO(a) ((struct ScmContinuationInfo*)(SCM_AS_CONTINUATION(a)->car))
-#define SCM_CONTINUATION_SET_INFO(a, info) (SCM_AS_CONTINUATION(a)->car = info)
-#define SCM_CONTINUATION_JMPENV(a) (SCM_CONTINUATION_INFO(a)->jmpenv)
-#define SCM_CONTINUATION_DYNEXT(a) (SCM_CONTINUATION_INFO(a)->dynext)
-#define SCM_CONTINUATION_SET_JMPENV(a, jmp) (SCM_CONTINUATION_JMPENV(a) = jmp)
-#define SCM_CONTINUATION_SET_DYNEXT(a, ext) (SCM_CONTINUATION_DYNEXT(a) = ext)
-*/
+#define SCM_CONTINUATION_OPAQUE(a) ((void*)(SCM_AS_CONTINUATION(a)->car))
+#define SCM_CONTINUATION_SET_OPAQUE(a, val) (SCM_AS_CONTINUATION(a)->car = (ScmObj)val)
+#define SCM_CONTINUATION_TAG(a) (SCM_GET_VALUE_AS_INT(SCM_AS_CONTINUATION(a)->cdr, SCM_TAG_OTHERS_VALUE_OFFSET_CONTINUATION))
+#define SCM_CONTINUATION_SET_TAG(a, val) (SCM_SET_VALUE_AS_INT(SCM_AS_CONTINUATION(a)->cdr, val, SCM_TAG_OTHERS_VALUE_OFFSET_CONTINUATION, SCM_TAG_OTHERS_CONTINUATION))
+
+
#define SCM_C_POINTER_VALUE(a) ((void*)SCM_AS_C_POINTER(a)->car)
#define SCM_C_POINTER_SET_VALUE(a, val) (SCM_AS_C_POINTER(a)->car = (ScmObj)val)
@@ -593,7 +593,7 @@
};
/* storage.c */
-#define SCM_TYPE(a) Scm_Type(a);
+#define SCM_TYPE(a) Scm_Type(a)
extern enum ScmObjType Scm_Type(ScmObj obj);
#if YAMAKEN
Modified: branches/r5rs/sigscheme/storage.c
===================================================================
--- branches/r5rs/sigscheme/storage.c 2005-11-07 22:02:30 UTC (rev 2077)
+++ branches/r5rs/sigscheme/storage.c 2005-11-08 10:37:55 UTC (rev 2078)
@@ -331,3 +331,35 @@
return obj;
}
#endif /* SCM_USE_NONSTD_FEATURES */
+
+#if SCM_OBJ_COMPACT
+enum ScmObjType Scm_Type(ScmObj obj)
+{
+ if (CONSP(obj))
+ return ScmCons;
+ else if (INTP(obj))
+ return ScmInt;
+ else if (CHARP(obj))
+ return ScmChar;
+ else if (CLOSUREP(obj))
+ return ScmClosure;
+ else if (SYMBOLP(obj))
+ return ScmSymbol;
+ else if (STRINGP(obj))
+ return ScmString;
+ else if (VECTORP(obj))
+ return ScmVector;
+ else if (VALUEPACKETP(obj))
+ return ScmValuePacket;
+ else if (FUNCP(obj))
+ return ScmFunc;
+ else if (PORTP(obj))
+ return ScmPort;
+ else if (CONTINUATIONP(obj))
+ return ScmContinuation;
+ else if (C_POINTERP(obj))
+ return ScmCPointer;
+ else if (C_FUNCPOINTERP(obj))
+ return ScmCFuncPointer;
+}
+#endif /* SCM_OBJ_COMPACT */
Modified: branches/r5rs/sigscheme/test-compact.c
===================================================================
--- branches/r5rs/sigscheme/test-compact.c 2005-11-07 22:02:30 UTC (rev 2077)
+++ branches/r5rs/sigscheme/test-compact.c 2005-11-08 10:37:55 UTC (rev 2078)
@@ -153,7 +153,6 @@
#define SCM_MB_MAX_LEN 4
ScmObj obj;
- int len;
char *val = aligned_strdup(ch);
SCM_ASSERT(strlen(ch) <= SCM_MB_MAX_LEN);
@@ -266,40 +265,49 @@
return obj;
}
-/*
-ScmObj Scm_CheckPort(ScmCharPort *cport, enum ScmPortFlag flag)
+
+ScmObj Scm_CheckPort()
{
- ScmObj obj;
+ ScmObj obj = (ScmObj)malloc(sizeof(ScmCell));
+ ScmCharPort port;
SCM_ENTYPE_PORT(obj);
+ SCM_ASSERT(SCM_PORTP(obj));
- if (flag & SCM_PORTFLAG_INPUT)
- flag |= SCM_PORTFLAG_LIVE_INPUT;
- if (flag & SCM_PORTFLAG_OUTPUT)
- flag |= SCM_PORTFLAG_LIVE_OUTPUT;
- SCM_PORT_SET_FLAG(obj, flag);
+ SCM_PORT_SET_FLAG(obj, SCM_PORTFLAG_INPUT);
+ SCM_ASSERT(SCM_PORTP(obj));
+ SCM_ASSERT(SCM_PORT_FLAG(obj) == SCM_PORTFLAG_INPUT);
- SCM_PORT_SET_IMPL(obj, cport);
+ SCM_PORT_SET_IMPL(obj, &port);
+ SCM_ASSERT(SCM_PORTP(obj));
+ SCM_ASSERT(SCM_PORT_IMPL(obj) == &port);
return obj;
}
-*/
-/*
+
ScmObj Scm_CheckContinuation(void)
{
- ScmObj obj;
- struct ScmContinuationInfo *info = (struct ScmContinuationInfo*)malloc(sizeof(struct ScmContinuationInfo));
+ ScmObj obj = (ScmObj)malloc(sizeof(ScmCell));
+ void *val = (void*)0x20;
SCM_ENTYPE_CONTINUATION(obj);
+ SCM_ASSERT(SCM_CONTINUATIONP(obj));
- SCM_CONTINUATION_SET_INFO(obj, info);
- SCM_CONTINUATION_SET_JMPENV(obj, INVALID_CONTINUATION_JMPENV);
- SCM_CONTINUATION_SET_DYNEXT(obj, scm_current_dynamic_extent);
+ SCM_CONTINUATION_SET_OPAQUE(obj, val);
+ SCM_ASSERT(SCM_CONTINUATIONP(obj));
+ SCM_ASSERT(SCM_CONTINUATION_OPAQUE(obj) == val);
+ SCM_CONTINUATION_SET_TAG(obj, 10);
+ SCM_ASSERT(SCM_CONTINUATIONP(obj));
+ SCM_ASSERT(SCM_CONTINUATION_TAG(obj) == 10);
+
+ SCM_CONTINUATION_SET_TAG(obj, 0);
+ SCM_ASSERT(SCM_CONTINUATIONP(obj));
+ SCM_ASSERT(SCM_CONTINUATION_TAG(obj) == 0);
+
return obj;
}
-*/
ScmObj Scm_CheckValuePacket()
{
@@ -361,6 +369,8 @@
Scm_CheckFunc();
Scm_CheckVector(5);
Scm_CheckValuePacket();
+ Scm_CheckContinuation();
+ Scm_CheckPort();
Scm_CheckCPointer();
Scm_CheckCFuncPointer();
}
More information about the uim-commit
mailing list