[uim-commit] r2529 - branches/r5rs/sigscheme

kzk at freedesktop.org kzk at freedesktop.org
Sun Dec 11 16:04:18 PST 2005


Author: kzk
Date: 2005-12-11 16:04:13 -0800 (Sun, 11 Dec 2005)
New Revision: 2529

Modified:
   branches/r5rs/sigscheme/sigschemetype-compact.h
   branches/r5rs/sigscheme/test-compact.c
Log:
* sigscheme/sigschemetype-compact.h
  - (SCM_TAG_IMM_NULLP,
     SCM_TAG_IMM_INVALIDP,
     SCM_TAG_IMM_UNBOUNDP,
     SCM_TAG_IMM_FALSEP,
     SCM_TAG_IMM_TRUEP,
     SCM_TAG_IMM_EOFP,
     SCM_TAG_IMM_UNDEFP): check equality with SCM_EQ
  - (SCM_DEREF): should not care GC bit

* sigscheme/test-compact.c
  - (Scm_CheckRef): testcases around ScmRef


Modified: branches/r5rs/sigscheme/sigschemetype-compact.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype-compact.h	2005-12-11 23:28:36 UTC (rev 2528)
+++ branches/r5rs/sigscheme/sigschemetype-compact.h	2005-12-12 00:04:13 UTC (rev 2529)
@@ -418,13 +418,13 @@
 #define SCM_TAG_IMM_CHARP(a)              ((SCM_CAST_UINT(a) & SCM_TAG_IMM_MASK_CHAR)  == SCM_TAG_IMM_CHAR)
 
 #define SCM_TAG_IMM_CONSTANTP(a)          ((SCM_CAST_UINT(a) & SCM_TAG_IMM_MASK_CONST) == (SCM_TAG_IMM | (0x3 << 3)))
-#define SCM_TAG_IMM_NULLP(a)              (SCM_CAST_UINT(a) == SCM_IMM_NULL)
-#define SCM_TAG_IMM_INVALIDP(a)           (SCM_CAST_UINT(a) == SCM_IMM_INVALID)
-#define SCM_TAG_IMM_UNBOUNDP(a)           (SCM_CAST_UINT(a) == SCM_IMM_UNBOUND)
-#define SCM_TAG_IMM_FALSEP(a)             (SCM_CAST_UINT(a) == SCM_IMM_FALSE)
-#define SCM_TAG_IMM_TRUEP(a)              (SCM_CAST_UINT(a) == SCM_IMM_TRUE)
-#define SCM_TAG_IMM_EOFP(a)               (SCM_CAST_UINT(a) == SCM_IMM_EOF)
-#define SCM_TAG_IMM_UNDEFP(a)             (SCM_CAST_UINT(a) == SCM_IMM_UNDEF)
+#define SCM_TAG_IMM_NULLP(a)              (SCM_EQ((a), SCM_IMM_NULL))
+#define SCM_TAG_IMM_INVALIDP(a)           (SCM_EQ((a), SCM_IMM_INVALID))
+#define SCM_TAG_IMM_UNBOUNDP(a)           (SCM_EQ((a), SCM_IMM_UNBOUND))
+#define SCM_TAG_IMM_FALSEP(a)             (SCM_EQ((a), SCM_IMM_FALSE))
+#define SCM_TAG_IMM_TRUEP(a)              (SCM_EQ((a), SCM_IMM_TRUE))
+#define SCM_TAG_IMM_EOFP(a)               (SCM_EQ((a), SCM_IMM_EOF))
+#define SCM_TAG_IMM_UNDEFP(a)             (SCM_EQ((a), SCM_IMM_UNDEF))
 
 /* Type Predicates */
 #define SCM_CONSP(a)             (SCM_TAG_CONSP(a))
@@ -765,7 +765,7 @@
 #define SCM_REF_OFF_HEAP(obj) (&(obj))
 
 /* SCM_DEREF(ref) is not permitted to be used as lvalue */
-#define SCM_DEREF(ref)    ((ScmObj)(SCM_CAST_UINT(*(ref)) & ~SCM_GCBIT_MASK))
+#define SCM_DEREF(ref)    ((ScmObj)(SCM_CAST_UINT(*(ref))))
 
 /* RFC: Is there a better name? */
 #define SCM_SET(ref, obj) (*(ref) = (ScmObj)(SCM_GC_BIT(*(ref)) | (SCM_CAST_UINT(obj) & ~SCM_GCBIT_MASK)))

Modified: branches/r5rs/sigscheme/test-compact.c
===================================================================
--- branches/r5rs/sigscheme/test-compact.c	2005-12-11 23:28:36 UTC (rev 2528)
+++ branches/r5rs/sigscheme/test-compact.c	2005-12-12 00:04:13 UTC (rev 2529)
@@ -732,6 +732,30 @@
     return SCM_NULL;
 }
 
+ScmObj Scm_CheckRef()
+{
+    PRINT_SECTION("REF");
+
+    ScmObj cons = Scm_CheckCons();
+    ScmObj tmp  = Scm_CheckCons();
+    ScmRef ref_car = SCM_REF_CAR(cons);
+    ScmRef ref_cdr = SCM_REF_CDR(cons);
+
+    SCM_ASSERT(SCM_EQ(cons, SCM_DEREF(SCM_REF_OFF_HEAP(cons))));
+    SCM_ASSERT(SCM_EQ(SCM_CAR(cons), SCM_DEREF(SCM_REF_OFF_HEAP(SCM_CAR(cons)))));
+    SCM_ASSERT(SCM_EQ(SCM_CDR(cons), SCM_DEREF(SCM_REF_OFF_HEAP(SCM_CDR(cons)))));
+    SCM_ASSERT(SCM_EQ(SCM_CAR(cons), SCM_DEREF(ref_car)));
+    SCM_ASSERT(SCM_EQ(SCM_CDR(cons), SCM_DEREF(ref_cdr)));
+
+    SCM_SET(ref_car, tmp);
+    SCM_SET(ref_cdr, tmp);
+    SCM_ASSERT(SCM_EQ(cons, SCM_DEREF(SCM_REF_OFF_HEAP(cons))));
+    SCM_ASSERT(SCM_EQ(SCM_CAR(cons), SCM_DEREF(SCM_REF_OFF_HEAP(SCM_CAR(cons)))));
+    SCM_ASSERT(SCM_EQ(SCM_CDR(cons), SCM_DEREF(SCM_REF_OFF_HEAP(SCM_CDR(cons)))));
+    SCM_ASSERT(SCM_EQ(SCM_CAR(cons), SCM_DEREF(ref_car)));
+    SCM_ASSERT(SCM_EQ(SCM_CDR(cons), SCM_DEREF(ref_cdr)));
+}
+
 int main(void)
 {
     Scm_CheckInt(0);
@@ -761,6 +785,7 @@
     Scm_CheckCFuncPointer((ScmCFunc)0xfffffffe);
     Scm_CheckCFuncPointer((ScmCFunc)0xffffffff);
     Scm_CheckConstant();
+    Scm_CheckRef();
 
     SCM_INVALIDP(SCM_INVALID);
 }



More information about the uim-commit mailing list