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

kzk at freedesktop.org kzk at freedesktop.org
Fri Oct 21 18:50:11 PDT 2005


Author: kzk
Date: 2005-10-21 18:50:08 -0700 (Fri, 21 Oct 2005)
New Revision: 1865

Modified:
   branches/r5rs/sigscheme/config.h
   branches/r5rs/sigscheme/sigscheme.h
   branches/r5rs/sigscheme/sigschemeinternal.h
   branches/r5rs/sigscheme/sigschemetype-compact.h
   branches/r5rs/sigscheme/test-compact.c
Log:
* sigscheme/config.h
  - (SCM_OBJ_COMPACT): new flag
* sigscheme/sigschemeinternal.h
  - add SCM_FREECELL handling macro for SCM_OBJ_COMPACT
* sigscheme/sigschemetype-compact.h
  - add MBS handling data structures and macros
  - reorganize accessor macros
* sigscheme/sigscheme.h
  - include "sigschemetype-compact.h" when SCM_OBJ_COMPACT
    is enabled
* sigscheme/test-compact.c
  - add entype test


Modified: branches/r5rs/sigscheme/config.h
===================================================================
--- branches/r5rs/sigscheme/config.h	2005-10-21 08:25:57 UTC (rev 1864)
+++ branches/r5rs/sigscheme/config.h	2005-10-22 01:50:08 UTC (rev 1865)
@@ -53,6 +53,8 @@
 #define SCM_COMPAT_SIOD         1  /* use SIOD compatible features */
 #define SCM_COMPAT_SIOD_BUGS    1  /* emulate the buggy behaviors of SIOD */
 
+#define SCM_OBJ_COMPACT         1  /* object representation compaction (experimental) */
+
 /*===========================================================================
   Character Encoding Handlers
 ===========================================================================*/

Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h	2005-10-21 08:25:57 UTC (rev 1864)
+++ branches/r5rs/sigscheme/sigscheme.h	2005-10-22 01:50:08 UTC (rev 1865)
@@ -143,7 +143,11 @@
 typedef void (*ScmCFunc)(void);
 
 /* type declaration */
+#if SCM_OBJ_COMPACT
+#include "sigschemetype-compact.h"
+#else
 #include "sigschemetype.h"
+#endif
 
 enum ScmDebugCategory {
     SCM_DBG_NONE         = 0,

Modified: branches/r5rs/sigscheme/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/sigschemeinternal.h	2005-10-21 08:25:57 UTC (rev 1864)
+++ branches/r5rs/sigscheme/sigschemeinternal.h	2005-10-22 01:50:08 UTC (rev 1865)
@@ -90,13 +90,23 @@
    Macro Declarations
 =======================================*/
 /* FreeCell Handling Macros */
-#define SCM_FREECELLP(a)     (SCM_TYPE(a) == ScmFreeCell)
-#define SCM_AS_FREECELL(a)   (SCM_ASSERT_TYPE(SCM_FREECELLP(a), (a)))
-#define SCM_FREECELL_CAR(a)  (SCM_AS_FREECELL(a)->obj.cons.car)
-#define SCM_FREECELL_CDR(a)  (SCM_AS_FREECELL(a)->obj.cons.cdr)
-#define SCM_ENTYPE_FREECELL(a)     (SCM_ENTYPE((a), ScmFreeCell))
+#if SCM_OBJ_COMPACT
+#define SCM_FREECELLP(a)            (SCM_CONSP(a))
+#define SCM_AS_FREECELL(a)          (SCM_ASSERT_TYPE(SCM_CONSP(a), (a)))
+#define SCM_FREECELL_CAR(a)         (SCM_CAR(a))
+#define SCM_FREECELL_CDR(a)         (SCM_CDR(a))
+#define SCM_ENTYPE_FREECELL(a)      (SCM_ENTYPE_CONS(a))
+#define SCM_FREECELL_SET_CAR(a,car) (SCM_CONS_SET_CAR(a))
+#define SCM_FREECELL_SET_CDR(a,cdr) (SCM_CONS_SET_CDR(a))
+#else
+#define SCM_FREECELLP(a)            (SCM_TYPE(a) == ScmFreeCell)
+#define SCM_AS_FREECELL(a)          (SCM_ASSERT_TYPE(SCM_FREECELLP(a), (a)))
+#define SCM_FREECELL_CAR(a)         (SCM_AS_FREECELL(a)->obj.cons.car)
+#define SCM_FREECELL_CDR(a)         (SCM_AS_FREECELL(a)->obj.cons.cdr)
+#define SCM_ENTYPE_FREECELL(a)      (SCM_ENTYPE((a), ScmFreeCell))
 #define SCM_FREECELL_SET_CAR(a,car) (SCM_FREECELL_CAR(a) = car)
 #define SCM_FREECELL_SET_CDR(a,cdr) (SCM_FREECELL_CDR(a) = cdr)
+#endif
 
 /* Prefix-less Abbreviation Names For Convenient Internal Use */
 #define EQ             SCM_EQ

Modified: branches/r5rs/sigscheme/sigschemetype-compact.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype-compact.h	2005-10-21 08:25:57 UTC (rev 1864)
+++ branches/r5rs/sigscheme/sigschemetype-compact.h	2005-10-22 01:50:08 UTC (rev 1865)
@@ -218,11 +218,79 @@
 };
 
 /*=======================================
-   Width, Masks and Offsets
+   Multibyte encoding support
 =======================================*/
-/* FIXME: hardcoded width 32 */
-#define SCM_WORD_WIDTH      32
 
+/* This type will actually contain some encoding-dependent enum value.
+ * It might as well be defined as mbstate_t if we're using libc. */
+typedef int ScmMultibyteState;
+
+/* Metadata of a multibyte character.  These are usually allocated on
+   stack or register, so we'll make liberal use of space. */
+typedef struct {
+    const char *start;
+    int flag;
+    int size;
+
+#if SCM_USE_STATEFUL_ENCODING
+    /* Shift state at the *end* of the described character. */
+    ScmMultibyteState state;
+#endif
+} ScmMultibyteCharInfo;
+
+typedef struct {
+    const char *str;
+
+    /* Only the size is stored because ScmObj caches the length, and
+     * we'll have to traverse from the beginning all the time
+     * anyway. */
+    int size;
+#if SCM_USE_STATEFUL_ENCODING
+    ScmMultibyteState state;
+#endif
+} ScmMultibyteString;
+
+#define SCM_MBS_SET_STR(mbs, s)         ((mbs).str = (s))
+#define SCM_MBS_GET_STR(mbs)            ((mbs).str)
+#define SCM_MBS_SET_SIZE(mbs, siz)      ((mbs).size = (siz))
+#define SCM_MBS_GET_SIZE(mbs)           ((mbs).size)
+
+#define SCM_MBCINFO_SET_SIZE SCM_MBS_SET_SIZE
+#define SCM_MBCINFO_GET_SIZE SCM_MBS_GET_SIZE
+#define SCM_MBCINFO_CLEAR_STATE SCM_MBS_CLEAR_STATE
+#define SCM_MBCINFO_SET_STATE SCM_MBS_SET_STATE
+#define SCM_MBCINFO_GET_STATE SCM_MBS_GET_STATE
+#define SCM_MBCINFO_CLEAR_FLAG(inf)     ((inf).flag = 0)
+#define SCM_MBCINFO_SET_ERROR(inf)      ((inf).flag |= 1)
+#define SCM_MBCINFO_SET_INCOMPLETE(inf) ((inf).flag |= 2)
+#define SCM_MBCINFO_ERRORP(inf)         ((inf).flag & 1)
+#define SCM_MBCINFO_INCOMPLETEP(inf)    ((inf).flag & 2)
+#define SCM_MBCINFO_INIT(inf)  (SCM_MBCINFO_SET_SIZE((inf), 0),  \
+                                SCM_MBCINFO_CLEAR_STATE(inf),    \
+                                SCM_MBCINFO_CLEAR_FLAG(inf))
+
+
+#if SCM_USE_STATEFUL_ENCODING
+#define SCM_MBS_GET_STATE(mbs)        ((mbs).state)
+#define SCM_MBS_SET_STATE(mbs, stat)  ((mbs).state = (stat))
+#define SCM_MBS_CLEAR_STATE(mbs)      ((mbs).state = 0)
+#else
+#define SCM_MBS_GET_STATE(mbs)        0
+#define SCM_MBS_SET_STATE(mbs, stat)  0
+#define SCM_MBS_CLEAR_STATE(mbs)      0
+#endif
+#define SCM_MBS_INIT(mbs)  (SCM_MBS_SET_STR((mbs), NULL), \
+                            SCM_MBS_SET_SIZE((mbs), 0),   \
+                            SCM_MBS_CLEAR_STATE(mbs))
+#define SCM_MBS_SKIP_CHAR(mbs, inf)                                           \
+    (SCM_MBS_SET_STR((mbs), SCM_MBS_GET_STR(mbs) + SCM_MBCINFO_GET_SIZE(inf)),\
+     SCM_MBS_SET_SIZE((mbs),                                                  \
+                      SCM_MBS_GET_SIZE(mbs) - SCM_MBCINFO_GET_SIZE(inf)),     \
+     SCM_MBS_SET_STATE((mbs), SCM_MBCINFO_GET_STATE(inf)))
+
+/*=======================================
+   Masks Offsets, and Tags
+=======================================*/
 #define SCM_GCBIT_WIDTH     1
 #define SCM_GCBIT_OFFSET    0
 #define SCM_GCBIT_MASK      (0x1 << SCM_GCBIT_OFFSET)
@@ -244,189 +312,79 @@
 #define SCM_VALUE_MASK      (~0U << SCM_VALUE_OFFSET)
 
 /*==============================================================================
-  Width, Masks and Offsets: Others
+  Masks Offsets, and Tags : Others
 ==============================================================================*/
-/* primary tag */
-#define SCM_OTHERS_CDR_TAG_WIDTH         2
-#define SCM_OTHERS_CDR_TAG_OFFSET        SCM_GCBIT_WIDTH
-#define SCM_OTHERS_CDR_TAG_MASK          (0x3 << SCM_OTHERS_CDR_TAG_OFFSET)
-#define SCM_OTHERS_CDR_TAG_SYMBOL        (0x0 << SCM_OTHERS_CDR_TAG_OFFSET)
-#define SCM_OTHERS_CDR_TAG_STRING        (0x1 << SCM_OTHERS_CDR_TAG_OFFSET)
-#define SCM_OTHERS_CDR_TAG_VECTOR        (0x2 << SCM_OTHERS_CDR_TAG_OFFSET)
-#define SCM_OTHERS_CDR_TAG_EXT           (0x3 << SCM_OTHERS_CDR_TAG_OFFSET)
+/* mask */
+#define SCM_TAG_OTHERS_MASK_SYMBOL               (0x1 | (0x0 << SCM_GCBIT_WIDTH))
+#define SCM_TAG_OTHERS_MASK_STRING               (0x1 | (0x1 << SCM_GCBIT_WIDTH))
+#define SCM_TAG_OTHERS_MASK_VECTOR               (0x1 | (0x2 << SCM_GCBIT_WIDTH))
+#define SCM_TAG_OTHERS_MASK_VALUES               (0x1 | (0x3 << SCM_GCBIT_WIDTH) | (0x0 << 3))
+#define SCM_TAG_OTHERS_MASK_FUNC                 (0x1 | (0x3 << SCM_GCBIT_WIDTH) | (0x1 << 3))
+#define SCM_TAG_OTHERS_MASK_PORT                 (0x1 | (0x3 << SCM_GCBIT_WIDTH) | (0x2 << 3))
+#define SCM_TAG_OTHERS_MASK_CONTINUATION         (0x1 | (0x3 << SCM_GCBIT_WIDTH) | (0x3 << 3))
+#define SCM_TAG_OTHERS_MASK_C_POINTER            (0x1 | (0x3 << SCM_GCBIT_WIDTH) | (0x4 << 3) | (0x1 << 6))
+#define SCM_TAG_OTHERS_MASK_FREECELL             (0x1 | (0x3 << SCM_GCBIT_WIDTH) | (0x7 << 3))
 
-/* subtag */
-#define SCM_OTHERS_CDR_SUB_TAG_WIDTH     3
-#define SCM_OTHERS_CDR_SUB_TAG_OFFSET    (SCM_OTHERS_CDR_TAG_OFFSET          \
-                                          + SCM_OTHERS_CDR_TAG_WIDTH)
-#define SCM_OTHERS_CDR_SUB_TAG_MASK      (0x7 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
-#define SCM_OTHERS_CDR_SUB_TAG_VALUES    (0x0 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
-#define SCM_OTHERS_CDR_SUB_TAG_FUNC      (0x1 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
-#define SCM_OTHERS_CDR_SUB_TAG_PORT      (0x2 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
-#define SCM_OTHERS_CDR_SUB_TAG_CONTINUATION (0x3 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
-#define SCM_OTHERS_CDR_SUB_TAG_C_POINTER (0x4 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
-#define SCM_OTHERS_CDR_SUB_TAG_RESERVED5 (0x5 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
-#define SCM_OTHERS_CDR_SUB_TAG_RESERVED6 (0x6 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
-#define SCM_OTHERS_CDR_SUB_TAG_FREECELL  (0x7 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
+/* tag */
+#define SCM_TAG_OTHERS_SYMBOL                    (0x1 | (0x0 << SCM_GCBIT_WIDTH))
+#define SCM_TAG_OTHERS_STRING                    (0x1 | (0x1 << SCM_GCBIT_WIDTH))
+#define SCM_TAG_OTHERS_VECTOR                    (0x1 | (0x2 << SCM_GCBIT_WIDTH))
+#define SCM_TAG_OTHERS_VALUES                    (0x1 | (0x3 << SCM_GCBIT_WIDTH) | (0x0 << 3))
+#define SCM_TAG_OTHERS_FUNC                      (0x1 | (0x3 << SCM_GCBIT_WIDTH) | (0x1 << 3))
+#define SCM_TAG_OTHERS_PORT                      (0x1 | (0x3 << SCM_GCBIT_WIDTH) | (0x2 << 3))
+#define SCM_TAG_OTHERS_CONTINUATION              (0x1 | (0x3 << SCM_GCBIT_WIDTH) | (0x3 << 3))
+#define SCM_TAG_OTHERS_C_POINTER                 (0x1 | (0x3 << SCM_GCBIT_WIDTH) | (0x4 << 3) | (0x0 << 6))
+#define SCM_TAG_OTHERS_C_FUNCPOINTER             (0x1 | (0x3 << SCM_GCBIT_WIDTH) | (0x4 << 3) | (0x1 << 6))
+#define SCM_TAG_OTHERS_FREECELL                  (0x1 | (0x3 << SCM_GCBIT_WIDTH) | (0x7 << 3))
 
-/* extended tag combines primary tag and subtag */
-#define SCM_OTHERS_CDR_EXT_TAG_WIDTH     (SCM_OTHERS_CDR_TAG_WIDTH           \
-                                          + SCM_OTHERS_CDR_SUB_TAG_WIDTH)
-#define SCM_OTHERS_CDR_EXT_TAG_OFFSET    (SCM_OTHERS_CDR_TAG_OFFSET          \
-                                          + SCM_OTHERS_CDR_SUB_TAG_OFFSET)
-#define SCM_OTHERS_CDR_EXT_TAG_MASK      (SCM_OTHERS_CDR_TAG_MASK            \
-                                          + SCM_OTHERS_CDR_SUB_TAG_MASK)
-#define SCM_OTHERS_CDR_EXT_TAG_VALUES    (SCM_OTHERS_CDR_SUB_TAG_VALUES      \
-                                          | SCM_OTHERS_CDR_TAG_EXT)
-#define SCM_OTHERS_CDR_EXT_TAG_FUNC      (SCM_OTHERS_CDR_SUB_TAG_FUNC        \
-                                          | SCM_OTHERS_CDR_TAG_EXT)
-#define SCM_OTHERS_CDR_EXT_TAG_PORT      (SCM_OTHERS_CDR_SUB_TAG_PORT        \
-                                          | SCM_OTHERS_CDR_TAG_EXT)
-#define SCM_OTHERS_CDR_EXT_TAG_CONTINUATION (SCM_OTHERS_CDR_SUB_TAG_CONTINUATION \
-                                             | SCM_OTHERS_CDR_TAG_EXT)
-#define SCM_OTHERS_CDR_EXT_TAG_C_POINTER (SCM_OTHERS_CDR_SUB_TAG_C_POINTER   \
-                                          | SCM_OTHERS_CDR_TAG_EXT)
-#define SCM_OTHERS_CDR_EXT_TAG_RESERVED5 (SCM_OTHERS_CDR_SUB_TAG_RESERVED5   \
-                                          | SCM_OTHERS_CDR_TAG_EXT)
-#define SCM_OTHERS_CDR_EXT_TAG_RESERVED6 (SCM_OTHERS_CDR_SUB_TAG_RESERVED6   \
-                                          | SCM_OTHERS_CDR_TAG_EXT)
-#define SCM_OTHERS_CDR_EXT_TAG_FREECELL  (SCM_OTHERS_CDR_SUB_TAG_FREECELL    \
-                                          | SCM_OTHERS_CDR_TAG_EXT)
+/* offset */
+#define SCM_TAG_OTHERS_VALUE_OFFSET_STRING       (SCM_GCBIT_WIDTH + SCM_TAG_WIDTH)
+#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)
 
-/* value field for primary tag */
-#define SCM_OTHERS_CDR_VALUE_WIDTH   (SCM_WORD_WIDTH                         \
-                                      - (SCM_OTHERS_CDR_TAG_WIDTH            \
-                                         + SCM_GCBIT_WIDTH))
-#define SCM_OTHERS_CDR_VALUE_OFFSET  (SCM_OTHERS_CDR_TAG_WIDTH               \
-                                      + SCM_GCBIT_WIDTH)
-#define SCM_OTHERS_CDR_VALUE_MASK    (~0U << SCM_OTHERS_CDR_VALUE_OFFSET)
-
-/* value field for extended tag */
-#define SCM_OTHERS_CDR_NARROW_VALUE_WIDTH  (SCM_WORD_WIDTH                   \
-                                            - (SCM_OTHERS_CDR_SUB_TAG_WIDTH  \
-                                               + SCM_OTHERS_CDR_TAG_WIDTH    \
-                                               + SCM_GCBIT_WIDTH))
-#define SCM_OTHERS_CDR_NARROW_VALUE_OFFSET (SCM_OTHERS_CDR_SUB_TAG_WIDTH     \
-                                            + SCM_OTHERS_CDR_TAG_WIDTH       \
-                                            + SCM_GCBIT_WIDTH)
-#define SCM_OTHERS_CDR_NARROW_VALUE_MASK   (~0U << SCM_OTHERS_CDR_VALUE_OFFSET)
-
-/* for specific types */
-#define SCM_OTHERS_CDR_TAG_WIDTH_SYMBOL     SCM_OTHERS_CDR_TAG_WIDTH
-#define SCM_OTHERS_CDR_TAG_OFFSET_SYMBOL    SCM_OTHERS_CDR_TAG_OFFSET
-#define SCM_OTHERS_CDR_TAG_MASK_SYMBOL      SCM_OTHERS_CDR_TAG_MASK
-#define SCM_OTHERS_CDR_VALUE_WIDTH_SYMBOL   SCM_OTHERS_CDR_VALUE_WIDTH
-#define SCM_OTHERS_CDR_VALUE_OFFSET_SYMBOL  SCM_OTHERS_CDR_VALUE_OFFSET
-#define SCM_OTHERS_CDR_VALUE_MASK_SYMBOL    SCM_OTHERS_CDR_VALUE_MASK
-
-#define SCM_OTHERS_CDR_TAG_WIDTH_STRING     SCM_OTHERS_CDR_TAG_WIDTH
-#define SCM_OTHERS_CDR_TAG_OFFSET_STRING    SCM_OTHERS_CDR_TAG_OFFSET
-#define SCM_OTHERS_CDR_TAG_MASK_STRING      SCM_OTHERS_CDR_TAG_MASK
-#define SCM_OTHERS_CDR_VALUE_WIDTH_STRING   SCM_OTHERS_CDR_VALUE_WIDTH
-#define SCM_OTHERS_CDR_VALUE_OFFSET_STRING  SCM_OTHERS_CDR_VALUE_OFFSET
-#define SCM_OTHERS_CDR_VALUE_MASK_STRING    SCM_OTHERS_CDR_VALUE_MASK
-
-#define SCM_OTHERS_CDR_TAG_WIDTH_VECTOR     SCM_OTHERS_CDR_TAG_WIDTH
-#define SCM_OTHERS_CDR_TAG_OFFSET_VECTOR    SCM_OTHERS_CDR_TAG_OFFSET
-#define SCM_OTHERS_CDR_TAG_MASK_VECTOR      SCM_OTHERS_CDR_TAG_MASK
-#define SCM_OTHERS_CDR_VALUE_WIDTH_VECTOR   SCM_OTHERS_CDR_VALUE_WIDTH
-#define SCM_OTHERS_CDR_VALUE_OFFSET_VECTOR  SCM_OTHERS_CDR_VALUE_OFFSET
-#define SCM_OTHERS_CDR_VALUE_MASK_VECTOR    SCM_OTHERS_CDR_VALUE_MASK
-
-#define SCM_OTHERS_CDR_TAG_WIDTH_VALUES     SCM_OTHERS_CDR_EXT_TAG_WIDTH
-#define SCM_OTHERS_CDR_TAG_OFFSET_VALUES    SCM_OTHERS_CDR_EXT_TAG_OFFSET
-#define SCM_OTHERS_CDR_TAG_MASK_VALUES      SCM_OTHERS_CDR_EXT_TAG_MASK
-#define SCM_OTHERS_CDR_VALUE_WIDTH_VALUES   SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
-#define SCM_OTHERS_CDR_VALUE_OFFSET_VALUES  SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
-#define SCM_OTHERS_CDR_VALUE_MASK_VALUES    SCM_OTHERS_CDR_NARROW_VALUE_MASK
-
-#define SCM_OTHERS_CDR_TAG_WIDTH_FUNC       SCM_OTHERS_CDR_EXT_TAG_WIDTH
-#define SCM_OTHERS_CDR_TAG_OFFSET_FUNC      SCM_OTHERS_CDR_EXT_TAG_OFFSET
-#define SCM_OTHERS_CDR_TAG_MASK_FUNC        SCM_OTHERS_CDR_EXT_TAG_MASK
-#define SCM_OTHERS_CDR_VALUE_WIDTH_FUNC     SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
-#define SCM_OTHERS_CDR_VALUE_OFFSET_FUNC    SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
-#define SCM_OTHERS_CDR_VALUE_MASK_FUNC      SCM_OTHERS_CDR_NARROW_VALUE_MASK
-
-#define SCM_OTHERS_CDR_TAG_WIDTH_PORT       SCM_OTHERS_CDR_EXT_TAG_WIDTH
-#define SCM_OTHERS_CDR_TAG_OFFSET_PORT      SCM_OTHERS_CDR_EXT_TAG_OFFSET
-#define SCM_OTHERS_CDR_TAG_MASK_PORT        SCM_OTHERS_CDR_EXT_TAG_MASK
-#define SCM_OTHERS_CDR_VALUE_WIDTH_PORT     SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
-#define SCM_OTHERS_CDR_VALUE_OFFSET_PORT    SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
-#define SCM_OTHERS_CDR_VALUE_MASK_PORT      SCM_OTHERS_CDR_NARROW_VALUE_MASK
-
-#define SCM_OTHERS_CDR_TAG_WIDTH_CONTINUATION    SCM_OTHERS_CDR_EXT_TAG_WIDTH
-#define SCM_OTHERS_CDR_TAG_OFFSET_CONTINUATION   SCM_OTHERS_CDR_EXT_TAG_OFFSET
-#define SCM_OTHERS_CDR_TAG_MASK_CONTINUATION     SCM_OTHERS_CDR_EXT_TAG_MASK
-#define SCM_OTHERS_CDR_VALUE_WIDTH_CONTINUATION  SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
-#define SCM_OTHERS_CDR_VALUE_OFFSET_CONTINUATION SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
-#define SCM_OTHERS_CDR_VALUE_MASK_CONTINUATION   SCM_OTHERS_CDR_NARROW_VALUE_MASK
-
-#define SCM_OTHERS_CDR_TAG_WIDTH_C_POINTER    SCM_OTHERS_CDR_EXT_TAG_WIDTH
-#define SCM_OTHERS_CDR_TAG_OFFSET_C_POINTER   SCM_OTHERS_CDR_EXT_TAG_OFFSET
-#define SCM_OTHERS_CDR_TAG_MASK_C_POINTER     SCM_OTHERS_CDR_EXT_TAG_MASK
-#define SCM_OTHERS_CDR_VALUE_WIDTH_C_POINTER  SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
-#define SCM_OTHERS_CDR_VALUE_OFFSET_C_POINTER SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
-#define SCM_OTHERS_CDR_VALUE_MASK_C_POINTER   SCM_OTHERS_CDR_NARROW_VALUE_MASK
-
-#define SCM_OTHERS_CDR_TAG_WIDTH_RESERVED5    SCM_OTHERS_CDR_EXT_TAG_WIDTH
-#define SCM_OTHERS_CDR_TAG_OFFSET_RESERVED5   SCM_OTHERS_CDR_EXT_TAG_OFFSET
-#define SCM_OTHERS_CDR_TAG_MASK_RESERVED5     SCM_OTHERS_CDR_EXT_TAG_MASK
-#define SCM_OTHERS_CDR_VALUE_WIDTH_RESERVED5  SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
-#define SCM_OTHERS_CDR_VALUE_OFFSET_RESERVED5 SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
-#define SCM_OTHERS_CDR_VALUE_MASK_RESERVED5   SCM_OTHERS_CDR_NARROW_VALUE_MASK
-
-#define SCM_OTHERS_CDR_TAG_WIDTH_RESERVED6    SCM_OTHERS_CDR_EXT_TAG_WIDTH
-#define SCM_OTHERS_CDR_TAG_OFFSET_RESERVED6   SCM_OTHERS_CDR_EXT_TAG_OFFSET
-#define SCM_OTHERS_CDR_TAG_MASK_RESERVED6     SCM_OTHERS_CDR_EXT_TAG_MASK
-#define SCM_OTHERS_CDR_VALUE_WIDTH_RESERVED6  SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
-#define SCM_OTHERS_CDR_VALUE_OFFSET_RESERVED6 SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
-#define SCM_OTHERS_CDR_VALUE_MASK_RESERVED6   SCM_OTHERS_CDR_NARROW_VALUE_MASK
-
-#define SCM_OTHERS_CDR_TAG_WIDTH_FREECELL     SCM_OTHERS_CDR_EXT_TAG_WIDTH
-#define SCM_OTHERS_CDR_TAG_OFFSET_FREECELL    SCM_OTHERS_CDR_EXT_TAG_OFFSET
-#define SCM_OTHERS_CDR_TAG_MASK_FREECELL      SCM_OTHERS_CDR_EXT_TAG_MASK
-#define SCM_OTHERS_CDR_VALUE_WIDTH_FREECELL   SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
-#define SCM_OTHERS_CDR_VALUE_OFFSET_FREECELL  SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
-#define SCM_OTHERS_CDR_VALUE_MASK_FREECELL    SCM_OTHERS_CDR_NARROW_VALUE_MASK
-
 /*==============================================================================
-  Width, Masks and Offsets: Immediates
+  Masks Offsets, and Tags : IMM
 ==============================================================================*/
-#define SCM_IMM_SUB_TAG_WIDTH     2
-#define SCM_IMM_SUB_TAG_OFFSET    (SCM_TAG_OFFSET + SCM_TAG_WIDTH)
+/* mask */
+#define SCM_TAG_IMM_MASK_INT                     (SCM_TAG_MASK | (0x0 << 3))
+#define SCM_TAG_IMM_MASK_CHAR                    (SCM_TAG_MASK | (0x1 << 3))
+#define SCM_TAG_IMM_MASK_CONST                   (SCM_TAG_MASK | (0x3 << 3)  | (0x7 << 5))
 
-#define SCM_IMM_CONST_TAG_WIDTH   3
-#define SCM_IMM_CONST_TAG_OFFSET  (SCM_IMM_SUB_TAG_OFFSET + SCM_IMM_SUB_TAG_WIDTH)
+/* tag */
+#define SCM_TAG_IMM_INT                          (SCM_TAG_IMM  | (0x0 << 3))
+#define SCM_TAG_IMM_CHAR                         (SCM_TAG_IMM  | (0x1 << 3))
+#define SCM_IMM_NULL                             (SCM_TAG_IMM  | (0x3 << 3)  | (0x0 << 5))
+#define SCM_IMM_INVALID                          (SCM_TAG_IMM  | (0x3 << 3)  | (0x1 << 5))
+#define SCM_IMM_UNBOUND                          (SCM_TAG_IMM  | (0x3 << 3)  | (0x2 << 5))
+#define SCM_IMM_FALSE                            (SCM_TAG_IMM  | (0x3 << 3)  | (0x3 << 5))
+#define SCM_IMM_TRUE                             (SCM_TAG_IMM  | (0x3 << 3)  | (0x4 << 5))
+#define SCM_IMM_EOF                              (SCM_TAG_IMM  | (0x3 << 3)  | (0x5 << 5))
+#define SCM_IMM_UNDEF                            (SCM_TAG_IMM  | (0x3 << 3)  | (0x6 << 5))
 
-#define SCM_IMM_TAG_VALUE_OFFSET_INT        SCM_IMM_CONST_TAG_OFFSET - 1 /* FIXME: Rid the magic number */
-#define SCM_IMM_TAG_VALUE_OFFSET_CHAR       SCM_IMM_CONST_TAG_OFFSET
-#define SCM_IMM_TAG_VALUE_OFFSET_CONST      SCM_IMM_CONST_TAG_OFFSET
-#define SCM_IMM_TAG_MASK_INT                ((0x1 << SCM_IMM_TAG_VALUE_OFFSET_INT)   - 1)
-#define SCM_IMM_TAG_MASK_CHAR               ((0x1 << SCM_IMM_TAG_VALUE_OFFSET_CHAR)  - 1)
-#define SCM_IMM_TAG_MASK_CONST              ((0x1 << SCM_IMM_TAG_VALUE_OFFSET_CONST) - 1)
-#define SCM_IMM_TAG_INT                     (SCM_TAG_IMM | (0x0 << SCM_IMM_TAG_VALUE_OFFSET_INT))
-#define SCM_IMM_TAG_CHAR                    (SCM_TAG_IMM | (0x1 << SCM_IMM_TAG_VALUE_OFFSET_CHAR))
+/* offset */
+#define SCM_TAG_IMM_VALUE_OFFSET_INT             (SCM_GCBIT_WIDTH + SCM_TAG_WIDTH + 1)
+#define SCM_TAG_IMM_VALUE_OFFSET_CHAR            (SCM_GCBIT_WIDTH + SCM_TAG_WIDTH + 2)
 
-#define SCM_IMM_NULL                        (SCM_TAG_IMM | (0x3 << SCM_IMM_SUB_TAG_OFFSET) | (0x0 << SCM_IMM_CONST_TAG_OFFSET))
-#define SCM_IMM_INVALID                     (SCM_TAG_IMM | (0x3 << SCM_IMM_SUB_TAG_OFFSET) | (0x1 << SCM_IMM_CONST_TAG_OFFSET))
-#define SCM_IMM_UNBOUND                     (SCM_TAG_IMM | (0x3 << SCM_IMM_SUB_TAG_OFFSET) | (0x2 << SCM_IMM_CONST_TAG_OFFSET))
-#define SCM_IMM_FALSE                       (SCM_TAG_IMM | (0x3 << SCM_IMM_SUB_TAG_OFFSET) | (0x3 << SCM_IMM_CONST_TAG_OFFSET))
-#define SCM_IMM_TRUE                        (SCM_TAG_IMM | (0x3 << SCM_IMM_SUB_TAG_OFFSET) | (0x4 << SCM_IMM_CONST_TAG_OFFSET))
-#define SCM_IMM_EOF                         (SCM_TAG_IMM | (0x3 << SCM_IMM_SUB_TAG_OFFSET) | (0x5 << SCM_IMM_CONST_TAG_OFFSET))
-#define SCM_IMM_UNDEF                       (SCM_TAG_IMM | (0x3 << SCM_IMM_SUB_TAG_OFFSET) | (0x6 << SCM_IMM_CONST_TAG_OFFSET))
 
 /*=======================================
-   Casting Macro
+   Getter & Setter
 =======================================*/
-#define SCM_CAST_UINT(a)    ((unsigned int)(a))
+#define SCM_GET_VALUE_AS_OBJ(a)                   ((ScmObj)(SCM_CAST_UINT(a) & SCM_VALUE_MASK))
+#define SCM_GET_VALUE_AS_INT(a, offset)           ((int)   (SCM_CAST_UINT(a) >> offset))
+#define SCM_GET_VALUE_AS_PTR(a, mask)             ((void*) (SCM_CAST_UINT(a) & mask))
+#define SCM_GET_VALUE_AS_STR(a, mask)             ((char*) (SCM_GET_VALUE_AS_PTR(a, mask)))
+#define SCM_SET_VALUE_AS_OBJ(a, b)                (a = (ScmObj)((SCM_CAST_UINT(a) & SCM_GCBIT_MASK) | (SCM_CAST_UINT(b) & ~SCM_GCBIT_MASK)))
+#define SCM_SET_VALUE_AS_INT(a, val, offset, tag) (a = (ScmObj)(tag | (val << offset)))
+#define SCM_SET_VALUE_AS_PTR(a, val, tag)         (a = (ScmObj)(tag | val))
+#define SCM_SET_VALUE_AS_STR(a, val, tag)         (SCM_SET_VALUE_AS_PTR(a, val, tag))
 
 /*=======================================
-   car and cdr accessor
+   Casting to unsigned int
 =======================================*/
-#define SCM_ACCESS_CAR(a)   (SCM_GET_AS_OBJ(a)->car)
-#define SCM_ACCESS_CDR(a)   (SCM_GET_AS_OBJ(a)->cdr)
-#define SCM_CAR_UINT(a)     (SCM_CAST_UINT(SCM_ACCESS_CAR(a)))
-#define SCM_CDR_UINT(a)     (SCM_CAST_UINT(SCM_ACCESS_CDR(a)))
+#define SCM_CAST_UINT(a)     ((unsigned int)(a))
+#define SCM_CAST_CAR_UINT(a) SCM_CAST_UINT(SCM_GET_VALUE_AS_OBJ(a)->car)
+#define SCM_CAST_CDR_UINT(a) SCM_CAST_UINT(SCM_GET_VALUE_AS_OBJ(a)->cdr)
 
 /*=======================================
    GC bit Accessor
@@ -442,56 +400,56 @@
 #define SCM_TAG_CONSP(a)      ((SCM_CAST_UINT(a) & SCM_TAG_MASK) == SCM_TAG_CONS)
 #define SCM_TAG_CLOSUREP(a)   ((SCM_CAST_UINT(a) & SCM_TAG_MASK) == SCM_TAG_CLOSURE)
 #define SCM_TAG_OTHERSP(a)    ((SCM_CAST_UINT(a) & SCM_TAG_MASK) == SCM_TAG_OTHERS)
-#define SCM_TAG_IMMEDIATEP(a) ((SCM_CAST_UINT(a) & SCM_TAG_MASK) == SCM_TAG_IMM)
+#define SCM_TAG_IMMP(a)       ((SCM_CAST_UINT(a) & SCM_TAG_MASK) == SCM_TAG_IMM)
 
 /* Tag -> Others */
-#define SCM_TAG_OTHERS_SYMBOLP(a)         ((SCM_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_SYMBOL) \
+#define SCM_TAG_OTHERS_SYMBOLP(a)         ((SCM_CAST_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_SYMBOL) \
                                              == SCM_TAG_OTHERS_SYMBOL)
-#define SCM_TAG_OTHERS_STRINGP(a)         ((SCM_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_STRING) \
+#define SCM_TAG_OTHERS_STRINGP(a)         ((SCM_CAST_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_STRING) \
                                              == SCM_TAG_OTHERS_STRING)
-#define SCM_TAG_OTHERS_VECTORP(a)         ((SCM_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_VECTOR) \
+#define SCM_TAG_OTHERS_VECTORP(a)         ((SCM_CAST_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_VECTOR) \
                                              == SCM_TAG_OTHERS_VECTOR)
-#define SCM_TAG_OTHERS_VALUESP(a)         ((SCM_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_VALUES) \
+#define SCM_TAG_OTHERS_VALUESP(a)         ((SCM_CAST_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_VALUES) \
                                              == SCM_TAG_OTHERS_VALUES)
-#define SCM_TAG_OTHERS_FUNCP(a)           ((SCM_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_FUNC) \
+#define SCM_TAG_OTHERS_FUNCP(a)           ((SCM_CAST_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_FUNC) \
                                              == SCM_TAG_OTHERS_FUNC)
-#define SCM_TAG_OTHERS_PORTP(a)           ((SCM_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_PORT) \
+#define SCM_TAG_OTHERS_PORTP(a)           ((SCM_CAST_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_PORT) \
                                              == SCM_TAG_OTHERS_PORT)
-#define SCM_TAG_OTHERS_CONTINUATIONP(a)   ((SCM_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_CONTINUATION) \
+#define SCM_TAG_OTHERS_CONTINUATIONP(a)   ((SCM_CAST_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_CONTINUATION) \
                                              == SCM_TAG_OTHERS_CONTINUATION)
-#define SCM_TAG_OTHERS_C_POINTERP(a)      ((SCM_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_C_POINTER) \
+#define SCM_TAG_OTHERS_C_POINTERP(a)      ((SCM_CAST_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_C_POINTER) \
                                              == SCM_TAG_OTHERS_C_POINTER)
-#define SCM_TAG_OTHERS_C_FUNC_POINTERP(a) ((SCM_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_C_POINTER) \
-                                             == SCM_TAG_OTHERS_C_FUNC_POINTER)
-#define SCM_TAG_OTHERS_FREECELLP(a)       ((SCM_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_FREECELL) \
-                                             == SCM_TAG_OTHERS_FREECELL)
+#define SCM_TAG_OTHERS_C_FUNCPOINTERP(a) ((SCM_CAST_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_C_POINTER) \
+                                             == SCM_TAG_OTHERS_C_FUNCPOINTER)
+#define SCM_TAG_OTHERS_FREECELLP(a)       ((SCM_CAST_CDR_UINT(a) & SCM_TAG_OTHERS_MASK_FREECELL) \
+
 /* Tag -> Imm */
-#define SCM_IMM_TAG_INTP(a)      ((SCM_CAST_UINT(a) & SCM_IMM_TAG_MASK_INT)   == SCM_IMM_TAG_INT)
-#define SCM_IMM_TAG_CHARP(a)     ((SCM_CAST_UINT(a) & SCM_IMM_TAG_MASK_CHAR)  == SCM_IMM_TAG_CHAR)
-#define SCM_IMM_TAG_NULLP(a)     ((SCM_CAST_UINT(a) & SCM_IMM_TAG_MASK_CONST) == SCM_IMM_NULL)
-#define SCM_IMM_TAG_INVALIDP(a)  ((SCM_CAST_UINT(a) & SCM_IMM_TAG_MASK_CONST) == SCM_IMM_INVALID)
-#define SCM_IMM_TAG_UNBOUNDP(a)  ((SCM_CAST_UINT(a) & SCM_IMM_TAG_MASK_CONST) == SCM_IMM_UNBOUND)
-#define SCM_IMM_TAG_FALSEP(a)    ((SCM_CAST_UINT(a) & SCM_IMM_TAG_MASK_CONST) == SCM_IMM_FALSE)
-#define SCM_IMM_TAG_TRUEP(a)     ((SCM_CAST_UINT(a) & SCM_IMM_TAG_MASK_CONST) == SCM_IMM_TRUE)
-#define SCM_IMM_TAG_EOFP(a)      ((SCM_CAST_UINT(a) & SCM_IMM_TAG_MASK_CONST) == SCM_IMM_EOF)
-#define SCM_IMM_TAG_UNDEFP(a)    ((SCM_CAST_UINT(a) & SCM_IMM_TAG_MASK_CONST) == SCM_IMM_UNDEF)
+#define SCM_TAG_IMM_INTP(a)               ((SCM_CAST_UINT(a) & SCM_TAG_IMM_MASK_INT)   == SCM_TAG_IMM_INT)
+#define SCM_TAG_IMM_CHARP(a)              ((SCM_CAST_UINT(a) & SCM_TAG_IMM_MASK_CHAR)  == SCM_TAG_IMM_CHAR)
+#define SCM_TAG_IMM_NULLP(a)              ((SCM_CAST_UINT(a) & SCM_TAG_IMM_MASK_CONST) == SCM_IMM_NULL)
+#define SCM_TAG_IMM_INVALIDP(a)           ((SCM_CAST_UINT(a) & SCM_TAG_IMM_MASK_CONST) == SCM_IMM_INVALID)
+#define SCM_TAG_IMM_UNBOUNDP(a)           ((SCM_CAST_UINT(a) & SCM_TAG_IMM_MASK_CONST) == SCM_IMM_UNBOUND)
+#define SCM_TAG_IMM_FALSEP(a)             ((SCM_CAST_UINT(a) & SCM_TAG_IMM_MASK_CONST) == SCM_IMM_FALSE)
+#define SCM_TAG_IMM_TRUEP(a)              ((SCM_CAST_UINT(a) & SCM_TAG_IMM_MASK_CONST) == SCM_IMM_TRUE)
+#define SCM_TAG_IMM_EOFP(a)               ((SCM_CAST_UINT(a) & SCM_TAG_IMM_MASK_CONST) == SCM_IMM_EOF)
+#define SCM_TAG_IMM_UNDEFP(a)             ((SCM_CAST_UINT(a) & SCM_TAG_IMM_MASK_CONST) == SCM_IMM_UNDEF)
 
 /* Type Predicates */
 #define SCM_CONSP(a)             (SCM_TAG_CONSP(a))
 #define SCM_CLOSUREP(a)          (SCM_TAG_CLOSUREP(a))
-#define SCM_SYMBOLP(a)           (SCM_TAG_OTHERS_SYMBOLP(a))
-#define SCM_STRINGP(a)           (SCM_TAG_OTHERS_STRINGP(a))
-#define SCM_VECTORP(a)           (SCM_TAG_OTHERS_VECTORP(a))
-#define SCM_VALUEPACKETP(a)      (SCM_TAG_OTHERS_VALUESP(a))
-#define SCM_FUNCP(a)             (SCM_TAG_OTHERS_FUNCP(a))
-#define SCM_PORTP(a)             (SCM_TAG_OTHERS_PORTP(a))
-#define SCM_CONTINUATIONP(a)     (SCM_TAG_OTHERS_CONTINUATIONP(a))
-#define SCM_C_POINTERP(a)        (SCM_TAG_OTHERS_C_POINTERP(a))
-#define SCM_C_FUNCPOINTERP(a)    (SCM_TAG_OTHERS_C_FUNC_POINTERP(a))
-#define SCM_FREECELLP(a)         (SCM_TAG_OTHERS_FREECELLP(a))
-#define SCM_INTP(a)              (SCM_IMM_TAG_INTP(a))
-#define SCM_CHARP(a)             (SCM_IMM_TAG_CHARP(a))
 
+#define SCM_SYMBOLP(a)           (SCM_TAG_OTHERSP(a), SCM_TAG_OTHERS_SYMBOLP(a))
+#define SCM_STRINGP(a)           (SCM_TAG_OTHERSP(a), SCM_TAG_OTHERS_STRINGP(a))
+#define SCM_VECTORP(a)           (SCM_TAG_OTHERSP(a), SCM_TAG_OTHERS_VECTORP(a))
+#define SCM_VALUEPACKETP(a)      (SCM_TAG_OTHERSP(a), SCM_TAG_OTHERS_VALUESP(a))
+#define SCM_FUNCP(a)             (SCM_TAG_OTHERSP(a), SCM_TAG_OTHERS_FUNCP(a))
+#define SCM_PORTP(a)             (SCM_TAG_OTHERSP(a), SCM_TAG_OTHERS_PORTP(a))
+#define SCM_CONTINUATIONP(a)     (SCM_TAG_OTHERSP(a), SCM_TAG_OTHERS_CONTINUATIONP(a))
+#define SCM_C_POINTERP(a)        (SCM_TAG_OTHERSP(a), SCM_TAG_OTHERS_C_POINTERP(a))
+#define SCM_C_FUNCPOINTERP(a)    (SCM_TAG_OTHERSP(a), SCM_TAG_OTHERS_C_FUNCPOINTERP(a))
+#define SCM_INTP(a)              (SCM_TAG_IMM_INTP(a))
+#define SCM_CHARP(a)             (SCM_TAG_IMM_CHARP(a))
+
 /*=======================================
    Type Confirmation
 =======================================*/
@@ -517,42 +475,41 @@
 /*=======================================
    Entyping Macros
 =======================================*/
-#define SCM_ENTYPE_SYMBOL(a)          (a = (ScmObj)SCM_TAG_OTHERS_SYMBOL)
-#define SCM_ENTYPE_STRING(a)          (a = (ScmObj)SCM_TAG_OTHERS_STRING)
-#define SCM_ENTYPE_VECTOR(a)          (a = (ScmObj)SCM_TAG_OTHERS_VECTOR)
-#define SCM_ENTYPE_VALUES(a)          (a = (ScmObj)SCM_TAG_OTHERS_VALUES)
-#define SCM_ENTYPE_FUNC(a)            (a = (ScmObj)SCM_TAG_OTHERS_FUNC)
-#define SCM_ENTYPE_PORT(a)            (a = (ScmObj)SCM_TAG_OTHERS_PORT)
-#define SCM_ENTYPE_CONTINUATION(a)    (a = (ScmObj)SCM_TAG_OTHERS_CONTINUATION)
-#define SCM_ENTYPE_C_POINTER(a)       (a = (ScmObj)SCM_TAG_OTHERS_C_POINTER)
-#define SCM_ENTYPE_C_FUNC_POINTER(a)  (a = (ScmObj)SCM_TAG_OTHERS_C_FUNC_POINTERP)
-#define SCM_ENTYPE_FREECELL(a)        (a = (ScmObj)SCM_TAG_OTHERS_FREECELL)
-#define SCM_ENTYPE_INT(a)             (a = (ScmObj)SCM_IMM_TAG_INT)
-#define SCM_ENTYPE_CHAR(a)            (a = (ScmObj)SCM_IMM_TAG_CHAR)
-#define SCM_ENTYPE_NULL(a)            (a = (ScmObj)SCM_IMM_TAG_NULL)
-#define SCM_ENTYPE_INVALID(a)         (a = (ScmObj)SCM_IMM_TAG_INVALID)
-#define SCM_ENTYPE_UNBOUND(a)         (a = (ScmObj)SCM_IMM_TAG_UNBOUND)
-#define SCM_ENTYPE_FALSE(a)           (a = (ScmObj)SCM_IMM_TAG_FALSE)
-#define SCM_ENTYPE_TRUE(a)            (a = (ScmObj)SCM_IMM_TAG_TRUE)
-#define SCM_ENTYPE_EOF(a)             (a = (ScmObj)SCM_IMM_TAG_EOF)
-#define SCM_ENTYPE_UNDEF(a)           (a = (ScmObj)SCM_IMM_TAG_UNDEF)
+#define SCM_ENTYPE_TAG_CONS(a)        (a = (ScmObj)(SCM_GC_BIT(a) | SCM_CAST_UINT(SCM_GET_VALUE_AS_OBJ(a)) | SCM_TAG_CONS))
+#define SCM_ENTYPE_TAG_CLOSURE(a)     (a = (ScmObj)(SCM_GC_BIT(a) | SCM_CAST_UINT(SCM_GET_VALUE_AS_OBJ(a)) | SCM_TAG_CLOSURE))
+#define SCM_ENTYPE_TAG_OTHERS(a)      (a = (ScmObj)(SCM_GC_BIT(a) | SCM_CAST_UINT(SCM_GET_VALUE_AS_OBJ(a)) | SCM_TAG_OTHERS))
+#define SCM_ENTYPE_TAG_IMM(a)         (a = (ScmObj)(SCM_GC_BIT(a) | SCM_CAST_UINT(SCM_GET_VALUE_AS_OBJ(a)) | SCM_TAG_IMM))
 
+#define SCM_ENTYPE_CDR_TAG(a, tag)    (SCM_GET_VALUE_AS_OBJ(a)->cdr = (ScmObj)(tag))
+
+#define SCM_ENTYPE_CONS(a)            (SCM_ENTYPE_TAG_CONS(a),    SCM_ENTYPE_CDR_TAG(a, 0x0))
+#define SCM_ENTYPE_CLOSURE(a)         (SCM_ENTYPE_TAG_CLOSURE(a), SCM_ENTYPE_CDR_TAG(a, 0x0))
+#define SCM_ENTYPE_SYMBOL(a)          (SCM_ENTYPE_TAG_OTHERS(a),  SCM_ENTYPE_CDR_TAG(a, SCM_TAG_OTHERS_SYMBOL))
+#define SCM_ENTYPE_STRING(a)          (SCM_ENTYPE_TAG_OTHERS(a),  SCM_ENTYPE_CDR_TAG(a, SCM_TAG_OTHERS_STRING))
+#define SCM_ENTYPE_VECTOR(a)          (SCM_ENTYPE_TAG_OTHERS(a),  SCM_ENTYPE_CDR_TAG(a, SCM_TAG_OTHERS_VECTOR))
+#define SCM_ENTYPE_VALUES(a)          (SCM_ENTYPE_TAG_OTHERS(a),  SCM_ENTYPE_CDR_TAG(a, SCM_TAG_OTHERS_VALUES))
+#define SCM_ENTYPE_FUNC(a)            (SCM_ENTYPE_TAG_OTHERS(a),  SCM_ENTYPE_CDR_TAG(a, SCM_TAG_OTHERS_FUNC))
+#define SCM_ENTYPE_PORT(a)            (SCM_ENTYPE_TAG_OTHERS(a),  SCM_ENTYPE_CDR_TAG(a, SCM_TAG_OTHERS_PORT))
+#define SCM_ENTYPE_CONTINUATION(a)    (SCM_ENTYPE_TAG_OTHERS(a),  SCM_ENTYPE_CDR_TAG(a, SCM_TAG_OTHERS_CONTINUATION))
+#define SCM_ENTYPE_C_POINTER(a)       (SCM_ENTYPE_TAG_OTHERS(a),  SCM_ENTYPE_CDR_TAG(a, SCM_TAG_OTHERS_C_POINTER))
+#define SCM_ENTYPE_C_FUNCPOINTER(a)   (SCM_ENTYPE_TAG_OTHERS(a),  SCM_ENTYPE_CDR_TAG(a, SCM_TAG_OTHERS_C_FUNCPOINTER))
+#define SCM_ENTYPE_INT(a)             (SCM_ENTYPE_TAG_IMM(a),     SCM_ENTYPE_CDR_TAG(a, SCM_TAG_IMM_INT))
+#define SCM_ENTYPE_CHAR(a)            (SCM_ENTYPE_TAG_IMM(a),     SCM_ENTYPE_CDR_TAG(a, SCM_TAG_IMM_CHAR))
+#define SCM_ENTYPE_NULL(a)            (SCM_ENTYPE_TAG_IMM(a),     SCM_ENTYPE_CDR_TAG(a, SCM_IMM_NULL))
+#define SCM_ENTYPE_INVALID(a)         (SCM_ENTYPE_TAG_IMM(a),     SCM_ENTYPE_CDR_TAG(a, SCM_IMM_INVALID))
+#define SCM_ENTYPE_UNBOUND(a)         (SCM_ENTYPE_TAG_IMM(a),     SCM_ENTYPE_CDR_TAG(a, SCM_IMM_UNBOUND))
+#define SCM_ENTYPE_FALSE(a)           (SCM_ENTYPE_TAG_IMM(a),     SCM_ENTYPE_CDR_TAG(a, SCM_IMM_FALSE))
+#define SCM_ENTYPE_TRUE(a)            (SCM_ENTYPE_TAG_IMM(a),     SCM_ENTYPE_CDR_TAG(a, SCM_IMM_TRUE))
+#define SCM_ENTYPE_EOF(a)             (SCM_ENTYPE_TAG_IMM(a),     SCM_ENTYPE_CDR_TAG(a, SCM_IMM_EOF))
+#define SCM_ENTYPE_UNDEF(a)           (SCM_ENTYPE_TAG_IMM(a),     SCM_ENTYPE_CDR_TAG(a, SCM_IMM_UNDEF))
+
 /*=======================================
    Real Accessors
 =======================================*/
-#define SCM_GET_AS_OBJ(a)         ((ScmObj)(SCM_CAST_UINT(a) & SCM_VALUE_MASK))
-#define SCM_GET_AS_INT(a, offset) ((int)   (SCM_CAST_UINT(a) >> offset))
-#define SCM_GET_AS_PTR(a, mask)   ((void*) (SCM_CAST_UINT(a) & mask))
-#define SCM_GET_AS_STR(a, mask)   ((char*) (SCM_GET_AS_PTR(a, mask)))
-#define SCM_SET_AS_OBJ(a, b)      (a = (ScmObj)((SCM_CAST_UINT(a) & SCM_GCBIT_MASK) | (SCM_CAST_UINT(b) & ~SCM_GCBIT_MASK)))
-#define SCM_SET_AS_INT(a, val, offset, tag) (a = (ScmObj)(tag | (val << offset)))
-#define SCM_SET_AS_PTR(a, val, tag)         (a = (ScmObj)(tag | val))
-#define SCM_SET_AS_STR(a, val, tag)         (SCM_SET_AS_PTR(a, val, tag))
-
 #define SCM_CAR(a)                     (SCM_AS_CONS(a)->car)
 #define SCM_CDR(a)                     (SCM_AS_CONS(a)->cdr)
-#define SCM_CONS_SET_CAR(a, car)       (SCM_SET_AS_OBJ(SCM_CAR(a), car))
-#define SCM_CONS_SET_CDR(a, cdr)       (SCM_SET_AS_OBJ(SCM_CDR(a), cdr))
+#define SCM_CONS_SET_CAR(a, car)       (SCM_SET_VALUE_AS_OBJ(SCM_CAR(a), car))
+#define SCM_CONS_SET_CDR(a, cdr)       (SCM_SET_VALUE_AS_OBJ(SCM_CDR(a), cdr))
 #define SCM_CAAR(a)                    (SCM_CAR(SCM_CAR(a)))
 #define SCM_CADR(a)                    (SCM_CAR(SCM_CDR(a)))
 #define SCM_CDAR(a)                    (SCM_CDR(SCM_CAR(a)))
@@ -560,40 +517,40 @@
 
 #define SCM_CLOSURE_EXP(a)             (SCM_AS_CLOSURE(a)->car)
 #define SCM_CLOSURE_ENV(a)             (SCM_AS_CLOSURE(a)->cdr)
-#define SCM_CLOSURE_SET_EXP(a, exp)    (SCM_SET_AS_OBJ(SCM_CLOSURE_EXP(a), exp))
-#define SCM_CLOSURE_SET_ENV(a, exp)    (SCM_SET_AS_OBJ(SCM_CLOSURE_EXP(a), env))
+#define SCM_CLOSURE_SET_EXP(a, exp)    (SCM_SET_VALUE_AS_OBJ(SCM_CLOSURE_EXP(a), exp))
+#define SCM_CLOSURE_SET_ENV(a, exp)    (SCM_SET_VALUE_AS_OBJ(SCM_CLOSURE_EXP(a), env))
 
 #define SCM_SYMBOL_VCELL(a)            (SCM_AS_SYMBOL(a)->car)
-#define SCM_SYMBOL_NAME(a)             (SCM_GET_AS_STR(SCM_AS_SYMBOL(a)->cdr, ~SCM_TAG_OTHERS_MASK_SYMBOL))
-#define SCM_SYMBOL_SET_VCELL(a, vcell) (SCM_SET_AS_OBJ(SCM_SYMBOL_VCELL(a), vcell))
-#define SCM_SYMBOL_SET_NAME(a, name)   (SCM_SET_AS_STR(SCM_AS_SYMBOL(a)->cdr, name, SCM_TAG_OTHERS_SYMBOL))
+#define SCM_SYMBOL_NAME(a)             (SCM_GET_VALUE_AS_STR(SCM_AS_SYMBOL(a)->cdr, ~SCM_TAG_OTHERS_MASK_SYMBOL))
+#define SCM_SYMBOL_SET_VCELL(a, vcell) (SCM_SET_VALUE_AS_OBJ(SCM_SYMBOL_VCELL(a), vcell))
+#define SCM_SYMBOL_SET_NAME(a, name)   (SCM_SET_VALUE_AS_STR(SCM_AS_SYMBOL(a)->cdr, name, SCM_TAG_OTHERS_SYMBOL))
 
-#define SCM_STRING_LEN(a)              (SCM_GET_AS_INT(SCM_AS_STRING(a)->car, SCM_TAG_OTHERS_VALUE_OFFSET_STRING))
-#define SCM_STRING_STR(a)              (SCM_GET_AS_STR(SCM_AS_STRING(a)->cdr, ~SCM_TAG_OTHERS_MASK_STRING))
-#define SCM_STRING_SET_LEN(a, len)     (SCM_SET_AS_INT(SCM_AS_STRING(a)->car, len, SCM_TAG_OTHERS_VALUE_OFFSET_STRING, SCM_TAG_OTHERS_STRING))
-#define SCM_STRING_SET_STR(a, str)     (SCM_SET_AS_STR(SCM_AS_STRING(a)->cdr, str, SCM_TAG_OTHERS_STRING))
+#define SCM_STRING_LEN(a)              (SCM_GET_VALUE_AS_INT(SCM_AS_STRING(a)->car, SCM_TAG_OTHERS_VALUE_OFFSET_STRING))
+#define SCM_STRING_STR(a)              (SCM_GET_VALUE_AS_STR(SCM_AS_STRING(a)->cdr, ~SCM_TAG_OTHERS_MASK_STRING))
+#define SCM_STRING_SET_LEN(a, len)     (SCM_SET_VALUE_AS_INT(SCM_AS_STRING(a)->car, len, SCM_TAG_OTHERS_VALUE_OFFSET_STRING, SCM_TAG_OTHERS_STRING))
+#define SCM_STRING_SET_STR(a, str)     (SCM_SET_VALUE_AS_STR(SCM_AS_STRING(a)->cdr, str, SCM_TAG_OTHERS_STRING))
 
-#define SCM_VECTOR_VEC(a)              (SCM_GET_AS_PTR(SCM_AS_VECTOR(a)->car, ~SCM_TAG_OTHERS_MASK_VECTOR))
-#define SCM_VECTOR_LEN(a)              (SCM_GET_AS_INT(SCM_AS_VECTOR(a)->cdr, SCM_TAG_OTHERS_VALUE_OFFSET_VECTOR))
-#define SCM_VECTOR_SET_VEC(a, vec)     (SCM_SET_AS_PTR(SCM_AS_VECTOR(a)->car, vec, SCM_TAG_OTHERS_VECTOR))
-#define SCM_VECTOR_SET_LEN(a, len)     (SCM_SET_AS_INT(a, len, SCM_TAG_OTHERS_VALUE_OFFSET_VECTOR, SCM_TAG_OTHERS_VECTOR))
+#define SCM_VECTOR_VEC(a)              (SCM_GET_VALUE_AS_PTR(SCM_AS_VECTOR(a)->car, ~SCM_TAG_OTHERS_MASK_VECTOR))
+#define SCM_VECTOR_LEN(a)              (SCM_GET_VALUE_AS_INT(SCM_AS_VECTOR(a)->cdr, SCM_TAG_OTHERS_VALUE_OFFSET_VECTOR))
+#define SCM_VECTOR_SET_VEC(a, vec)     (SCM_SET_VALUE_AS_PTR(SCM_AS_VECTOR(a)->car, vec, SCM_TAG_OTHERS_VECTOR))
+#define SCM_VECTOR_SET_LEN(a, len)     (SCM_SET_VALUE_AS_INT(a, len, SCM_TAG_OTHERS_VALUE_OFFSET_VECTOR, SCM_TAG_OTHERS_VECTOR))
 #define SCM_VECTOR_CREF(a, idx)        (SCM_VECTOR_VEC(a)[idx])
 #define SCM_VECTOR_SET_CREF(a, idx, b) (SCM_VECTOR_CREF((a), (idx)) = (b))
 #define SCM_VECTOR_REF(a, idx)         (SCM_VECTOR_CREF((a), SCM_INT_VALUE(idx)))
 #define SCM_VECTOR_SET_REF(a, idx, b)  (SCM_VECTOR_REF((a), (idx)) = (b))
 
 #define SCM_VALUEPACKET_VALUES(a)        (SCM_AS_VALUEPACKET(a)->car)
-#define SCM_VALUEPACKET_SET_VALUES(a, v) (SCM_SET_AS_OBJ(SCM_AS_VALUEPACKET(a)-X, v))
+#define SCM_VALUEPACKET_SET_VALUES(a, v) (SCM_SET_VALUE_AS_OBJ(SCM_AS_VALUEPACKET(a)-X, v))
 
-#define SCM_FUNC_CFUNC(a)              ((ScmFuncType)SCM_GET_AS_PTR(SCM_AS_FUNC(a)->car, ~SCM_TAG_OTHERS_MASK_FUNC))
-#define SCM_FUNC_TYPECODE(a)           ((ScmFuncTypeCode)SCM_GET_AS_INT(SCM_AS_FUNC(a)->cdr, SCM_TAG_OTHERS_VALUE_OFFSET_FUNC))
-#define SCM_FUNC_SET_CFUNC(a, fptr)    (SCM_SET_AS_PTR(SCM_AS_FUNC(a)->car, fptr, SCM_TAG_OTHERS_FUNC))
-#define SCM_FUNC_SET_TYPECODE(a, code) (SCM_SET_AS_INT(SCM_AS_FUNC(a)->cdr, code, SCM_TAG_OTHERS_VALUE_OFFSET_FUNC, SCM_TAG_OTHERS_FUNC))
+#define SCM_FUNC_CFUNC(a)              ((ScmFuncType)SCM_GET_VALUE_AS_PTR(SCM_AS_FUNC(a)->car, ~SCM_TAG_OTHERS_MASK_FUNC))
+#define SCM_FUNC_TYPECODE(a)           ((ScmFuncTypeCode)SCM_GET_VALUE_AS_INT(SCM_AS_FUNC(a)->cdr, SCM_TAG_OTHERS_VALUE_OFFSET_FUNC))
+#define SCM_FUNC_SET_CFUNC(a, fptr)    (SCM_SET_VALUE_AS_PTR(SCM_AS_FUNC(a)->car, fptr, SCM_TAG_OTHERS_FUNC))
+#define SCM_FUNC_SET_TYPECODE(a, code) (SCM_SET_VALUE_AS_INT(SCM_AS_FUNC(a)->cdr, code, SCM_TAG_OTHERS_VALUE_OFFSET_FUNC, SCM_TAG_OTHERS_FUNC))
 
-#define SCM_PORT_PORTINFO(a)                (SCM_GET_AS_PTR(SCM_AS_PORT(a)->car, ~SCM_TAG_OTHERS_MASK_PORT))
-#define SCM_PORT_PORTDIRECTION(a)           (SCM_GET_AS_INT(SCM_AS_PORT(a)->cdr, SCM_TAG_OTHERS_VALUE_OFFSET_PORT))
-#define SCM_PORT_SET_PORTINFO(a, info)      (SCM_SET_AS_PTR(SCM_AS_PORT(a)->car, info, SCM_TAG_OTHERS_PORT))
-#define SCM_PORT_SET_PORTDIRECTION(a, dir)  (SCM_SET_AS_INT(SCM_AS_PORT(a)->cdr, dir, SCM_TAG_OTHERS_VALUE_OFFSET_PORT, SCM_TAG_OTHERS_PORT))
+#define SCM_PORT_PORTINFO(a)                (SCM_GET_VALUE_AS_PTR(SCM_AS_PORT(a)->car, ~SCM_TAG_OTHERS_MASK_PORT))
+#define SCM_PORT_PORTDIRECTION(a)           (SCM_GET_VALUE_AS_INT(SCM_AS_PORT(a)->cdr, SCM_TAG_OTHERS_VALUE_OFFSET_PORT))
+#define SCM_PORT_SET_PORTINFO(a, info)      (SCM_SET_VALUE_AS_PTR(SCM_AS_PORT(a)->car, info, SCM_TAG_OTHERS_PORT))
+#define SCM_PORT_SET_PORTDIRECTION(a, dir)  (SCM_SET_VALUE_AS_INT(SCM_AS_PORT(a)->cdr, dir, SCM_TAG_OTHERS_VALUE_OFFSET_PORT, SCM_TAG_OTHERS_PORT))
 
 #define SCM_PORT_PORTTYPE(a)                (SCM_PORT_PORTINFO(a)->port_type)
 #define SCM_PORT_SET_PORTTYPE(a, type)      (SCM_PORT_PORTTYPE(a) = type)
@@ -616,34 +573,36 @@
 #define SCM_PORT_STR_CURRENTPOS(a)          (SCM_PORT_PORTINFO(a)->info.str_port.str_currentpos)
 #define SCM_PORT_SET_STR_CURRENTPOS(a, pos) (SCM_PORT_STR_CURRENTPOS(a) = pos)
 
-#define SCM_CONTINUATION_ENV(a)             (SCM_GET_AS_PTR(a, ~SCM_TAG_OTHERS_MASK_CONTINUATION))
+#define SCM_CONTINUATION_ENV(a)             (SCM_GET_VALUE_AS_PTR(a, ~SCM_TAG_OTHERS_MASK_CONTINUATION))
 #define SCM_CONTINUATION_JMPENV(a)          (SCM_CONTINUATION_ENV(a)->jmpenv)
 #define SCM_CONTINUATION_DYNEXT(a)          (SCM_CONTINUATION_ENV(a)->dynext)
-#define SCM_CONTINUATION_SET_ENV(a, env)    (SCM_SET_AS_PTR(a, env, SCM_TAG_OTHERS_CONTINUATION))
+#define SCM_CONTINUATION_SET_ENV(a, env)    (SCM_SET_VALUE_AS_PTR(a, env, SCM_TAG_OTHERS_CONTINUATION))
 #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_INT_VALUE(a)               (SCM_GET_AS_INT(a, SCM_IMM_TAG_VALUE_OFFSET_INT))
-#define SCM_INT_SET_VALUE(a, val)      (SCM_SET_AS_INT(a, val, SCM_IMM_TAG_VALUE_OFFSET_INT, SCM_IMM_TAG_INT))
+#define SCM_INT_VALUE(a)               (SCM_GET_VALUE_AS_INT(a, SCM_TAG_IMM_VALUE_OFFSET_INT))
+#define SCM_INT_SET_VALUE(a, val)      (SCM_SET_VALUE_AS_INT(a, val, SCM_TAG_IMM_VALUE_OFFSET_INT, SCM_TAG_IMM_INT))
+#define SCM_CHAR_VALUE(a)              (SCM_GET_VALUE_AS_STR(a, ~SCM_TAG_IMM_MASK_CHAR))
+#define SCM_CHAR_SET_VALUE(a, ch)      (SCM_SET_VALUE_AS_STR(a, ch, SCM_TAG_IMM_CHAR))
 
-#define SCM_CHAR_VALUE(a)              (SCM_GET_AS_STR(a, ~SCM_IMM_TAG_MASK_CHAR))
-#define SCM_CHAR_SET_VALUE(a, ch)      (SCM_SET_AS_STR(a, ch, SCM_IMM_TAG_CHAR))
-
 /*=======================================
    Scheme Special Constants
 =======================================*/
-#define SCM_EOF        SigScm_eof
-#define SCM_UNDEF      SigScm_undef
-#define SCM_INVALID    SigScm_invalid
-#define SCM_UNBOUND    SigScm_unbound
-#define SCM_FALSE      SigScm_false
-#define SCM_TRUE       SigScm_true
+#define SCM_NULL       SCM_IMM_NULL
+#define SCM_EOF        SCM_IMM_EOF
+#define SCM_UNDEF      SCM_IMM_UNDEF
+#define SCM_INVALID    SCM_IMM_INVALID
+#define SCM_UNBOUND    SCM_IMM_UNBOUND
+#define SCM_FALSE      SCM_IMM_FALSE
+#define SCM_TRUE       SCM_IMM_TRUE
 
-#define SCM_EQ(a, b)   ((a) == (b))
-#define SCM_NULLP(a)   (SCM_EQ((a),  SCM_NULL))
-#define SCM_FALSEP(a)  (SCM_EQ((a),  SCM_FALSE))
-#define SCM_NFALSEP(a) (!SCM_EQ((a), SCM_FALSE))
-#define SCM_EOFP(a)    (SCM_EQ((a),  SCM_EOF))
+#define SCM_EQ(a, b)    ((a) == (b))
+#define SCM_VALIDP(a)   (!SCM_TAG_IMM_INVALIDP(a))
+#define SCM_INVALIDP(a) (SCM_TAG_IMM_INVALIDP(a))
+#define SCM_NULLP(a)    (SCM_TAG_IMM_NULLP(a))
+#define SCM_FALSEP(a)   (SCM_TAG_IMM_FALSEP(a))
+#define SCM_NFALSEP(a)  (!SCM_TAG_IMM_FALSEP(a))
+#define SCM_EOFP(a)     (SCM_TAG_IMM_EOFP(a))
 
 /*============================================================================
   Predefined Symbols
@@ -702,4 +661,164 @@
 /* RFC: Is there a better name? */
 #define SCM_SET(ref, obj) (*(ref) = (obj))
 
+#if YAMAKEN
+/* FIXME: hardcoded width 32 */
+#define SCM_WORD_WIDTH      32
+
+/*
+ * I suggest these macro defining convention to achieve:
+ *   - making names consistent
+ *   - avoiding misunderstanding of names
+ *   - magic number-free obvious meaning on value definition
+ *   - hiding bitwise representation from accessor layer
+ *
+ * Rewrite the immediate type and special constants likewise if the convention
+ * is felt reasonable.  -- YamaKen 2005-10-18
+ */
+
+/* primary tag */
+#define SCM_OTHERS_CDR_TAG_WIDTH         2
+#define SCM_OTHERS_CDR_TAG_OFFSET        SCM_GCBIT_WIDTH
+#define SCM_OTHERS_CDR_TAG_MASK          (0x3 << SCM_OTHERS_CDR_TAG_OFFSET)
+#define SCM_OTHERS_CDR_TAG_SYMBOL        (0x0 << SCM_OTHERS_CDR_TAG_OFFSET)
+#define SCM_OTHERS_CDR_TAG_STRING        (0x1 << SCM_OTHERS_CDR_TAG_OFFSET)
+#define SCM_OTHERS_CDR_TAG_VECTOR        (0x2 << SCM_OTHERS_CDR_TAG_OFFSET)
+#define SCM_OTHERS_CDR_TAG_EXT           (0x3 << SCM_OTHERS_CDR_TAG_OFFSET)
+
+/* subtag */
+#define SCM_OTHERS_CDR_SUB_TAG_WIDTH     3
+#define SCM_OTHERS_CDR_SUB_TAG_OFFSET    (SCM_OTHERS_CDR_TAG_OFFSET          \
+                                          + SCM_OTHERS_CDR_TAG_WIDTH)
+#define SCM_OTHERS_CDR_SUB_TAG_MASK      (0x7 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
+#define SCM_OTHERS_CDR_SUB_TAG_VALUES    (0x0 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
+#define SCM_OTHERS_CDR_SUB_TAG_FUNC      (0x1 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
+#define SCM_OTHERS_CDR_SUB_TAG_PORT      (0x2 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
+#define SCM_OTHERS_CDR_SUB_TAG_CONTINUATION (0x3 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
+#define SCM_OTHERS_CDR_SUB_TAG_C_POINTER (0x4 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
+#define SCM_OTHERS_CDR_SUB_TAG_RESERVED5 (0x5 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
+#define SCM_OTHERS_CDR_SUB_TAG_RESERVED6 (0x6 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
+#define SCM_OTHERS_CDR_SUB_TAG_FREECELL  (0x7 << SCM_OTHERS_CDR_SUB_TAG_OFFSET)
+
+/* extended tag combines primary tag and subtag */
+#define SCM_OTHERS_CDR_EXT_TAG_WIDTH     (SCM_OTHERS_CDR_TAG_WIDTH           \
+                                          + SCM_OTHERS_CDR_SUB_TAG_WIDTH)
+#define SCM_OTHERS_CDR_EXT_TAG_OFFSET    (SCM_OTHERS_CDR_TAG_OFFSET          \
+                                          + SCM_OTHERS_CDR_SUB_TAG_OFFSET)
+#define SCM_OTHERS_CDR_EXT_TAG_MASK      (SCM_OTHERS_CDR_TAG_MASK            \
+                                          + SCM_OTHERS_CDR_SUB_TAG_MASK)
+#define SCM_OTHERS_CDR_EXT_TAG_VALUES    (SCM_OTHERS_CDR_SUB_TAG_VALUES      \
+                                          | SCM_OTHERS_CDR_TAG_EXT)
+#define SCM_OTHERS_CDR_EXT_TAG_FUNC      (SCM_OTHERS_CDR_SUB_TAG_FUNC        \
+                                          | SCM_OTHERS_CDR_TAG_EXT)
+#define SCM_OTHERS_CDR_EXT_TAG_PORT      (SCM_OTHERS_CDR_SUB_TAG_PORT        \
+                                          | SCM_OTHERS_CDR_TAG_EXT)
+#define SCM_OTHERS_CDR_EXT_TAG_CONTINUATION (SCM_OTHERS_CDR_SUB_TAG_CONTINUATION \
+                                             | SCM_OTHERS_CDR_TAG_EXT)
+#define SCM_OTHERS_CDR_EXT_TAG_C_POINTER (SCM_OTHERS_CDR_SUB_TAG_C_POINTER   \
+                                          | SCM_OTHERS_CDR_TAG_EXT)
+#define SCM_OTHERS_CDR_EXT_TAG_RESERVED5 (SCM_OTHERS_CDR_SUB_TAG_RESERVED5   \
+                                          | SCM_OTHERS_CDR_TAG_EXT)
+#define SCM_OTHERS_CDR_EXT_TAG_RESERVED6 (SCM_OTHERS_CDR_SUB_TAG_RESERVED6   \
+                                          | SCM_OTHERS_CDR_TAG_EXT)
+#define SCM_OTHERS_CDR_EXT_TAG_FREECELL  (SCM_OTHERS_CDR_SUB_TAG_FREECELL    \
+                                          | SCM_OTHERS_CDR_TAG_EXT)
+
+/* value field for primary tag */
+#define SCM_OTHERS_CDR_VALUE_WIDTH   (SCM_WORD_WIDTH                         \
+                                      - (SCM_OTHERS_CDR_TAG_WIDTH            \
+                                         + SCM_GCBIT_WIDTH))
+#define SCM_OTHERS_CDR_VALUE_OFFSET  (SCM_OTHERS_CDR_TAG_WIDTH               \
+                                      + SCM_GCBIT_WIDTH)
+#define SCM_OTHERS_CDR_VALUE_MASK    (~0U << SCM_OTHERS_CDR_VALUE_OFFSET)
+
+/* value field for extended tag */
+#define SCM_OTHERS_CDR_NARROW_VALUE_WIDTH  (SCM_WORD_WIDTH                   \
+                                            - (SCM_OTHERS_CDR_SUB_TAG_WIDTH  \
+                                               + SCM_OTHERS_CDR_TAG_WIDTH    \
+                                               + SCM_GCBIT_WIDTH))
+#define SCM_OTHERS_CDR_NARROW_VALUE_OFFSET (SCM_OTHERS_CDR_SUB_TAG_WIDTH     \
+                                            + SCM_OTHERS_CDR_TAG_WIDTH       \
+                                            + SCM_GCBIT_WIDTH)
+#define SCM_OTHERS_CDR_NARROW_VALUE_MASK   (~0U << SCM_OTHERS_CDR_VALUE_OFFSET)
+
+/* for specific types */
+#define SCM_OTHERS_CDR_TAG_WIDTH_SYMBOL     SCM_OTHERS_CDR_TAG_WIDTH
+#define SCM_OTHERS_CDR_TAG_OFFSET_SYMBOL    SCM_OTHERS_CDR_TAG_OFFSET
+#define SCM_OTHERS_CDR_TAG_MASK_SYMBOL      SCM_OTHERS_CDR_TAG_MASK
+#define SCM_OTHERS_CDR_VALUE_WIDTH_SYMBOL   SCM_OTHERS_CDR_VALUE_WIDTH
+#define SCM_OTHERS_CDR_VALUE_OFFSET_SYMBOL  SCM_OTHERS_CDR_VALUE_OFFSET
+#define SCM_OTHERS_CDR_VALUE_MASK_SYMBOL    SCM_OTHERS_CDR_VALUE_MASK
+
+#define SCM_OTHERS_CDR_TAG_WIDTH_STRING     SCM_OTHERS_CDR_TAG_WIDTH
+#define SCM_OTHERS_CDR_TAG_OFFSET_STRING    SCM_OTHERS_CDR_TAG_OFFSET
+#define SCM_OTHERS_CDR_TAG_MASK_STRING      SCM_OTHERS_CDR_TAG_MASK
+#define SCM_OTHERS_CDR_VALUE_WIDTH_STRING   SCM_OTHERS_CDR_VALUE_WIDTH
+#define SCM_OTHERS_CDR_VALUE_OFFSET_STRING  SCM_OTHERS_CDR_VALUE_OFFSET
+#define SCM_OTHERS_CDR_VALUE_MASK_STRING    SCM_OTHERS_CDR_VALUE_MASK
+
+#define SCM_OTHERS_CDR_TAG_WIDTH_VECTOR     SCM_OTHERS_CDR_TAG_WIDTH
+#define SCM_OTHERS_CDR_TAG_OFFSET_VECTOR    SCM_OTHERS_CDR_TAG_OFFSET
+#define SCM_OTHERS_CDR_TAG_MASK_VECTOR      SCM_OTHERS_CDR_TAG_MASK
+#define SCM_OTHERS_CDR_VALUE_WIDTH_VECTOR   SCM_OTHERS_CDR_VALUE_WIDTH
+#define SCM_OTHERS_CDR_VALUE_OFFSET_VECTOR  SCM_OTHERS_CDR_VALUE_OFFSET
+#define SCM_OTHERS_CDR_VALUE_MASK_VECTOR    SCM_OTHERS_CDR_VALUE_MASK
+
+#define SCM_OTHERS_CDR_TAG_WIDTH_VALUES     SCM_OTHERS_CDR_EXT_TAG_WIDTH
+#define SCM_OTHERS_CDR_TAG_OFFSET_VALUES    SCM_OTHERS_CDR_EXT_TAG_OFFSET
+#define SCM_OTHERS_CDR_TAG_MASK_VALUES      SCM_OTHERS_CDR_EXT_TAG_MASK
+#define SCM_OTHERS_CDR_VALUE_WIDTH_VALUES   SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
+#define SCM_OTHERS_CDR_VALUE_OFFSET_VALUES  SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
+#define SCM_OTHERS_CDR_VALUE_MASK_VALUES    SCM_OTHERS_CDR_NARROW_VALUE_MASK
+
+#define SCM_OTHERS_CDR_TAG_WIDTH_FUNC       SCM_OTHERS_CDR_EXT_TAG_WIDTH
+#define SCM_OTHERS_CDR_TAG_OFFSET_FUNC      SCM_OTHERS_CDR_EXT_TAG_OFFSET
+#define SCM_OTHERS_CDR_TAG_MASK_FUNC        SCM_OTHERS_CDR_EXT_TAG_MASK
+#define SCM_OTHERS_CDR_VALUE_WIDTH_FUNC     SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
+#define SCM_OTHERS_CDR_VALUE_OFFSET_FUNC    SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
+#define SCM_OTHERS_CDR_VALUE_MASK_FUNC      SCM_OTHERS_CDR_NARROW_VALUE_MASK
+
+#define SCM_OTHERS_CDR_TAG_WIDTH_PORT       SCM_OTHERS_CDR_EXT_TAG_WIDTH
+#define SCM_OTHERS_CDR_TAG_OFFSET_PORT      SCM_OTHERS_CDR_EXT_TAG_OFFSET
+#define SCM_OTHERS_CDR_TAG_MASK_PORT        SCM_OTHERS_CDR_EXT_TAG_MASK
+#define SCM_OTHERS_CDR_VALUE_WIDTH_PORT     SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
+#define SCM_OTHERS_CDR_VALUE_OFFSET_PORT    SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
+#define SCM_OTHERS_CDR_VALUE_MASK_PORT      SCM_OTHERS_CDR_NARROW_VALUE_MASK
+
+#define SCM_OTHERS_CDR_TAG_WIDTH_CONTINUATION    SCM_OTHERS_CDR_EXT_TAG_WIDTH
+#define SCM_OTHERS_CDR_TAG_OFFSET_CONTINUATION   SCM_OTHERS_CDR_EXT_TAG_OFFSET
+#define SCM_OTHERS_CDR_TAG_MASK_CONTINUATION     SCM_OTHERS_CDR_EXT_TAG_MASK
+#define SCM_OTHERS_CDR_VALUE_WIDTH_CONTINUATION  SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
+#define SCM_OTHERS_CDR_VALUE_OFFSET_CONTINUATION SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
+#define SCM_OTHERS_CDR_VALUE_MASK_CONTINUATION   SCM_OTHERS_CDR_NARROW_VALUE_MASK
+
+#define SCM_OTHERS_CDR_TAG_WIDTH_C_POINTER    SCM_OTHERS_CDR_EXT_TAG_WIDTH
+#define SCM_OTHERS_CDR_TAG_OFFSET_C_POINTER   SCM_OTHERS_CDR_EXT_TAG_OFFSET
+#define SCM_OTHERS_CDR_TAG_MASK_C_POINTER     SCM_OTHERS_CDR_EXT_TAG_MASK
+#define SCM_OTHERS_CDR_VALUE_WIDTH_C_POINTER  SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
+#define SCM_OTHERS_CDR_VALUE_OFFSET_C_POINTER SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
+#define SCM_OTHERS_CDR_VALUE_MASK_C_POINTER   SCM_OTHERS_CDR_NARROW_VALUE_MASK
+
+#define SCM_OTHERS_CDR_TAG_WIDTH_RESERVED5    SCM_OTHERS_CDR_EXT_TAG_WIDTH
+#define SCM_OTHERS_CDR_TAG_OFFSET_RESERVED5   SCM_OTHERS_CDR_EXT_TAG_OFFSET
+#define SCM_OTHERS_CDR_TAG_MASK_RESERVED5     SCM_OTHERS_CDR_EXT_TAG_MASK
+#define SCM_OTHERS_CDR_VALUE_WIDTH_RESERVED5  SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
+#define SCM_OTHERS_CDR_VALUE_OFFSET_RESERVED5 SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
+#define SCM_OTHERS_CDR_VALUE_MASK_RESERVED5   SCM_OTHERS_CDR_NARROW_VALUE_MASK
+
+#define SCM_OTHERS_CDR_TAG_WIDTH_RESERVED6    SCM_OTHERS_CDR_EXT_TAG_WIDTH
+#define SCM_OTHERS_CDR_TAG_OFFSET_RESERVED6   SCM_OTHERS_CDR_EXT_TAG_OFFSET
+#define SCM_OTHERS_CDR_TAG_MASK_RESERVED6     SCM_OTHERS_CDR_EXT_TAG_MASK
+#define SCM_OTHERS_CDR_VALUE_WIDTH_RESERVED6  SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
+#define SCM_OTHERS_CDR_VALUE_OFFSET_RESERVED6 SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
+#define SCM_OTHERS_CDR_VALUE_MASK_RESERVED6   SCM_OTHERS_CDR_NARROW_VALUE_MASK
+
+#define SCM_OTHERS_CDR_TAG_WIDTH_FREECELL     SCM_OTHERS_CDR_EXT_TAG_WIDTH
+#define SCM_OTHERS_CDR_TAG_OFFSET_FREECELL    SCM_OTHERS_CDR_EXT_TAG_OFFSET
+#define SCM_OTHERS_CDR_TAG_MASK_FREECELL      SCM_OTHERS_CDR_EXT_TAG_MASK
+#define SCM_OTHERS_CDR_VALUE_WIDTH_FREECELL   SCM_OTHERS_CDR_NARROW_VALUE_WIDTH
+#define SCM_OTHERS_CDR_VALUE_OFFSET_FREECELL  SCM_OTHERS_CDR_NARROW_VALUE_OFFSET
+#define SCM_OTHERS_CDR_VALUE_MASK_FREECELL    SCM_OTHERS_CDR_NARROW_VALUE_MASK
+#endif /* YAMAKEN */
+
+
 #endif /* __SIGSCMTYPE_COMPACT_H */

Modified: branches/r5rs/sigscheme/test-compact.c
===================================================================
--- branches/r5rs/sigscheme/test-compact.c	2005-10-21 08:25:57 UTC (rev 1864)
+++ branches/r5rs/sigscheme/test-compact.c	2005-10-22 01:50:08 UTC (rev 1865)
@@ -42,13 +42,54 @@
     return -1;
 }
 
+static void check_entype(void);
 static ScmObj check_int(void);
 
 int main(void)
 {
+    check_entype();
+
     check_int();
 }
 
+static void check_entype(void)
+{
+    ScmObj var;
+
+    SCM_ENTYPE_CONS(var);
+    SCM_ASSERT(SCM_CONSP(var));
+
+    SCM_ENTYPE_CLOSURE(var);
+    SCM_ASSERT(SCM_CLOSUREP(var));
+
+    SCM_ENTYPE_SYMBOL(var);
+    SCM_ASSERT(SCM_SYMBOLP(var));
+
+    SCM_ENTYPE_STRING(var);
+    SCM_ASSERT(SCM_STRINGP(var));
+
+    SCM_ENTYPE_VECTOR(var);
+    SCM_ASSERT(SCM_VECTORP(var));
+
+    SCM_ENTYPE_VALUES(var);
+    SCM_ASSERT(SCM_VALUEPACKETP(var));
+
+    SCM_ENTYPE_FUNC(var);
+    SCM_ASSERT(SCM_FUNCP(var));//
+
+    SCM_ENTYPE_PORT(var);
+    SCM_ASSERT(SCM_PORTP(var));//
+
+    SCM_ENTYPE_CONTINUATION(var);
+    SCM_ASSERT(SCM_CONTINUATIONP(var));//
+
+    SCM_ENTYPE_C_POINTER(var);
+    SCM_ASSERT(SCM_C_POINTERP(var));//
+
+    SCM_ENTYPE_C_FUNCPOINTER(var);
+    SCM_ASSERT(SCM_C_FUNCPOINTERP(var));//
+}
+
 static ScmObj check_int(void)
 {
     ScmObj var;



More information about the uim-commit mailing list