[uim-commit] r2880 - branches/r5rs/sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Tue Jan 10 03:51:26 PST 2006
Author: yamaken
Date: 2006-01-10 03:51:22 -0800 (Tue, 10 Jan 2006)
New Revision: 2880
Modified:
branches/r5rs/sigscheme/operations.c
branches/r5rs/sigscheme/sigscheme.c
branches/r5rs/sigscheme/sigscheme.h
branches/r5rs/sigscheme/storage-compact.h
branches/r5rs/sigscheme/storage-fatty.h
branches/r5rs/sigscheme/write.c
Log:
* sigscheme/sigscheme.h
- (enum ScmObjType):
* Add ScmRational, ScmReal, ScmComplex
* Sort by majority to make immediate number encoding optimal
- (SCM_HAS_IMMEDIATE_INT, SCM_HAS_IMMEDIATE_CHAR): Removed
- (SCM_HAS_CHAR, SCM_HAS_INT, SCM_HAS_RATIONAL, SCM_HAS_REAL,
SCM_HAS_COMPLEX, SCM_HAS_STRING, SCM_HAS_VECTOR,
SCM_HAS_IMMEDIATE_CHAR_ONLY, SCM_HAS_IMMEDIATE_NUMBER_ONLY,
SCM_HAS_IMMEDIATE_INT_ONLY, SCM_HAS_IMMEDIATE_RATIONAL_ONLY,
SCM_HAS_IMMEDIATE_REAL_ONLY, SCM_HAS_IMMEDIATE_COMPLEX_ONLY,
SCM_CHAR_BITS, SCM_CHAR_MAX, SCM_CHAR_MIN, SCM_INT_BITS,
SCM_INT_MAX, SCM_INT_MIN, SCM_STRLEN_BITS, SCM_STRLEN_MAX,
SCM_STRLEN_MIN, SCM_VECLEN_BITS, SCM_VECLEN_MAX, SCM_VECLEN_MIN,
SCM_AS_NUMBER, SCM_NUMBERP): New macro
* sigscheme/storage-fatty.h
- (SCM_SAL_HAS_IMMEDIATE_INT, SCM_SAL_HAS_IMMEDIATE_CHAR): Removed
- (SCM_SAL_HAS_CHAR, SCM_SAL_HAS_RATIONAL, SCM_SAL_HAS_REAL,
SCM_SAL_HAS_COMPLEX, SCM_SAL_HAS_STRING, SCM_SAL_HAS_VECTOR,
SCM_SAL_HAS_IMMEDIATE_CHAR_ONLY,
SCM_SAL_HAS_IMMEDIATE_NUMBER_ONLY, SCM_SAL_HAS_IMMEDIATE_INT_ONLY,
SCM_SAL_HAS_IMMEDIATE_RATIONAL_ONLY,
SCM_SAL_HAS_IMMEDIATE_REAL_ONLY,
SCM_SAL_HAS_IMMEDIATE_COMPLEX_ONLY, SCM_SAL_CHAR_BITS,
SCM_SAL_CHAR_MAX, SCM_SAL_INT_BITS, SCM_SAL_INT_MAX,
SCM_SAL_INT_MIN, SCM_SAL_STRLEN_BITS, SCM_SAL_STRLEN_MAX,
SCM_SAL_VECLEN_BITS, SCM_SAL_VECLEN_MAX, SCM_SAL_NUMBERP): New
macro
* sigscheme/storage-compact.h
- (SCM_SAL_HAS_IMMEDIATE_INT, SCM_SAL_HAS_IMMEDIATE_CHAR): Removed
- (SCM_SAL_HAS_CHAR, SCM_SAL_HAS_RATIONAL, SCM_SAL_HAS_REAL,
SCM_SAL_HAS_COMPLEX, SCM_SAL_HAS_STRING, SCM_SAL_HAS_VECTOR,
SCM_SAL_HAS_IMMEDIATE_CHAR_ONLY,
SCM_SAL_HAS_IMMEDIATE_NUMBER_ONLY, SCM_SAL_HAS_IMMEDIATE_INT_ONLY,
SCM_SAL_HAS_IMMEDIATE_RATIONAL_ONLY,
SCM_SAL_HAS_IMMEDIATE_REAL_ONLY,
SCM_SAL_HAS_IMMEDIATE_COMPLEX_ONLY, SCM_SAL_CHAR_BITS,
SCM_SAL_CHAR_MAX, SCM_SAL_INT_BITS, SCM_SAL_INT_MAX,
SCM_SAL_INT_MIN, SCM_SAL_STRLEN_BITS, SCM_SAL_STRLEN_MAX,
SCM_SAL_VECLEN_BITS, SCM_SAL_VECLEN_MAX, SCM_SAL_NUMBERP): New
macro
* sigscheme/sigscheme.c
- (scm_initialize_internal):
* Provide immediate-char-only when SCM_HAS_IMMEDIATE_CHAR_ONLY
* Provide immediate-number-only when SCM_HAS_IMMEDIATE_NUMBER_ONLY
* sigscheme/operations.c
- (scm_p_eqvp, scm_p_equalp, scm_p_memv, scm_p_assv,
scm_p_charequalp): Follow the reorganization of object
representation info macros
* sigscheme/write.c
- (write_obj):
* Remove useless ScmFreeCell handling
* Add false assertion
Modified: branches/r5rs/sigscheme/operations.c
===================================================================
--- branches/r5rs/sigscheme/operations.c 2006-01-10 09:19:24 UTC (rev 2879)
+++ branches/r5rs/sigscheme/operations.c 2006-01-10 11:51:22 UTC (rev 2880)
@@ -88,7 +88,7 @@
ScmObj
scm_p_eqvp(ScmObj obj1, ScmObj obj2)
{
-#if (!SCM_HAS_IMMEDIATE_INT || !SCM_HAS_IMMEDIATE_CHAR)
+#if (!(SCM_HAS_IMMEDIATE_NUMBER_ONLY && SCM_HAS_IMMEDIATE_CHAR_ONLY))
enum ScmObjType type;
#endif
DECLARE_FUNCTION("eqv?", procedure_fixed_2);
@@ -96,7 +96,7 @@
if (EQ(obj1, obj2))
return SCM_TRUE;
-#if (!SCM_HAS_IMMEDIATE_INT || !SCM_HAS_IMMEDIATE_CHAR)
+#if (!(SCM_HAS_IMMEDIATE_NUMBER_ONLY && SCM_HAS_IMMEDIATE_CHAR_ONLY))
type = SCM_TYPE(obj1);
/* different type */
@@ -105,12 +105,12 @@
/* same type */
switch (type) {
-#if !SCM_HAS_IMMEDIATE_INT
+#if !SCM_HAS_IMMEDIATE_INT_ONLY
case ScmInt:
return MAKE_BOOL(SCM_INT_VALUE(obj1) == SCM_INT_VALUE(obj2));
#endif
-#if !SCM_HAS_IMMEDIATE_CHAR
+#if !SCM_HAS_IMMEDIATE_CHAR_ONLY
case ScmChar:
return MAKE_BOOL(SCM_CHAR_VALUE(obj1) == SCM_CHAR_VALUE(obj2));
#endif
@@ -118,7 +118,7 @@
default:
break;
}
-#endif /* (!SCM_HAS_IMMEDIATE_INT || !SCM_HAS_IMMEDIATE_CHAR) */
+#endif /* (!(SCM_HAS_IMMEDIATE_NUMBER_ONLY && SCM_HAS_IMMEDIATE_CHAR_ONLY)) */
return SCM_FALSE;
}
@@ -142,12 +142,12 @@
/* same type */
switch (type) {
-#if !SCM_HAS_IMMEDIATE_INT
+#if !SCM_HAS_IMMEDIATE_INT_ONLY
case ScmInt:
return MAKE_BOOL(SCM_INT_VALUE(obj1) == SCM_INT_VALUE(obj2));
#endif
-#if !SCM_HAS_IMMEDIATE_CHAR
+#if !SCM_HAS_IMMEDIATE_CHAR_ONLY
case ScmChar:
return MAKE_BOOL(SCM_CHAR_VALUE(obj1) == SCM_CHAR_VALUE(obj2));
#endif
@@ -990,7 +990,7 @@
{
DECLARE_FUNCTION("memv", procedure_fixed_2);
-#if (SCM_HAS_IMMEDIATE_INT && SCM_HAS_IMMEDIATE_CHAR)
+#if (SCM_HAS_IMMEDIATE_NUMBER_ONLY && SCM_HAS_IMMEDIATE_CHAR_ONLY)
MEMBER_BODY(obj, lst, EQ);
#else
MEMBER_BODY(obj, lst, EQVP);
@@ -1034,7 +1034,7 @@
{
DECLARE_FUNCTION("assv", procedure_fixed_2);
-#if (SCM_HAS_IMMEDIATE_INT && SCM_HAS_IMMEDIATE_CHAR)
+#if (SCM_HAS_IMMEDIATE_NUMBER_ONLY && SCM_HAS_IMMEDIATE_CHAR_ONLY)
ASSOC_BODY(obj, alist, EQ);
#else
ASSOC_BODY(obj, alist, EQVP);
@@ -1101,7 +1101,7 @@
ENSURE_CHAR(ch1);
ENSURE_CHAR(ch2);
-#if SCM_HAS_IMMEDIATE_CHAR
+#if SCM_HAS_IMMEDIATE_CHAR_ONLY
return MAKE_BOOL(EQ(ch1, ch2));
#else
return MAKE_BOOL(SCM_CHAR_VALUE(ch1) == SCM_CHAR_VALUE(ch2));
Modified: branches/r5rs/sigscheme/sigscheme.c
===================================================================
--- branches/r5rs/sigscheme/sigscheme.c 2006-01-10 09:19:24 UTC (rev 2879)
+++ branches/r5rs/sigscheme/sigscheme.c 2006-01-10 11:51:22 UTC (rev 2880)
@@ -196,6 +196,12 @@
#if SCM_USE_NULL_CAPABLE_STRING
scm_provide(CONST_STRING("null-capable-string"));
#endif
+#if SCM_HAS_IMMEDIATE_CHAR_ONLY
+ scm_provide(CONST_STRING("immediate-char-only"));
+#endif
+#if SCM_HAS_IMMEDIATE_NUMBER_ONLY
+ scm_provide(CONST_STRING("immediate-number-only"));
+#endif
scm_initialized = scm_true;
}
Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h 2006-01-10 09:19:24 UTC (rev 2879)
+++ branches/r5rs/sigscheme/sigscheme.h 2006-01-10 11:51:22 UTC (rev 2880)
@@ -269,22 +269,28 @@
};
enum ScmObjType {
- ScmInt = 0,
- ScmCons = 1,
- ScmSymbol = 2,
- ScmChar = 3,
+ /* sorted by majority to make immediate number encoding optimal */
+ ScmCons = 0,
+ ScmInt = 1,
+ ScmChar = 2,
+ ScmSymbol = 3,
+
ScmString = 4,
ScmFunc = 5,
ScmClosure = 6,
ScmVector = 7,
- ScmPort = 8,
- ScmContinuation = 9,
- ScmConstant = 10,
- ScmValuePacket = 11,
- ScmFreeCell = 12,
- ScmCPointer = 20,
- ScmCFuncPointer = 21
+ ScmRational = 8,
+ ScmReal = 9,
+ ScmComplex = 10,
+ ScmConstant = 11,
+ ScmContinuation = 12,
+ ScmValuePacket = 13,
+ ScmPort = 14,
+ ScmFreeCell = 15,
+
+ ScmCFuncPointer = 30,
+ ScmCPointer = 31
};
/*
@@ -379,10 +385,43 @@
enum ScmReturnType ret_type;
};
-/* object representation information for optimization */
-#define SCM_HAS_IMMEDIATE_INT SCM_SAL_HAS_IMMEDIATE_INT
-#define SCM_HAS_IMMEDIATE_CHAR SCM_SAL_HAS_IMMEDIATE_CHAR
+/*=======================================
+ Object Representation Information
+=======================================*/
+#define SCM_HAS_CHAR SCM_SAL_HAS_CHAR
+#define SCM_HAS_INT 1
+#define SCM_HAS_RATIONAL SCM_SAL_HAS_RATIONAL
+#define SCM_HAS_REAL SCM_SAL_HAS_REAL
+#define SCM_HAS_COMPLEX SCM_SAL_HAS_COMPLEX
+#define SCM_HAS_STRING SCM_SAL_HAS_STRING
+#define SCM_HAS_VECTOR SCM_SAL_HAS_VECTOR
+/* for optimization */
+#define SCM_HAS_IMMEDIATE_CHAR_ONLY SCM_SAL_HAS_IMMEDIATE_CHAR
+#define SCM_HAS_IMMEDIATE_NUMBER_ONLY SCM_SAL_HAS_IMMEDIATE_NUMBER_ONLY
+#define SCM_HAS_IMMEDIATE_INT_ONLY SCM_SAL_HAS_IMMEDIATE_INT_ONLY
+#define SCM_HAS_IMMEDIATE_RATIONAL_ONLY SCM_SAL_HAS_IMMEDIATE_RATIONAL_ONLY
+#define SCM_HAS_IMMEDIATE_REAL_ONLY SCM_SAL_HAS_IMMEDIATE_REAL_ONLY
+#define SCM_HAS_IMMEDIATE_COMPLEX_ONLY SCM_SAL_HAS_IMMEDIATE_COMPLEX_ONLY
+
+#define SCM_CHAR_BITS SCM_SAL_CHAR_BITS
+#define SCM_CHAR_MAX SCM_SAL_CHAR_MAX
+#define SCM_CHAR_MIN 0
+
+#define SCM_INT_BITS SCM_SAL_INT_BITS
+#define SCM_INT_MAX SCM_SAL_INT_MAX
+#define SCM_INT_MIN SCM_SAL_INT_MIN
+
+/* string length */
+#define SCM_STRLEN_BITS SCM_SAL_STRLEN_BITS
+#define SCM_STRLEN_MAX SCM_SAL_STRLEN_MAX
+#define SCM_STRLEN_MIN 0
+
+/* vector length */
+#define SCM_VECLEN_BITS SCM_SAL_VECLEN_BITS
+#define SCM_VECLEN_MAX SCM_SAL_VECLEN_MAX
+#define SCM_VECLEN_MIN 0
+
/*=======================================
Object Creators
=======================================*/
@@ -431,6 +470,7 @@
#else /* SCM_ACCESSOR_ASSERT */
#define SCM_ASSERT_TYPE(cond, o) (o)
#endif /* SCM_ACCESSOR_ASSERT */
+#define SCM_AS_NUMBER(o) (SCM_ASSERT_TYPE(SCM_NUMBERP(o), (o)))
#define SCM_AS_INT(o) (SCM_ASSERT_TYPE(SCM_INTP(o), (o)))
#define SCM_AS_CONS(o) (SCM_ASSERT_TYPE(SCM_CONSP(o), (o)))
#define SCM_AS_SYMBOL(o) (SCM_ASSERT_TYPE(SCM_SYMBOLP(o), (o)))
@@ -445,6 +485,8 @@
#define SCM_AS_C_POINTER(o) (SCM_ASSERT_TYPE(SCM_C_POINTERP(o), (o)))
#define SCM_AS_C_FUNCPOINTER(o) (SCM_ASSERT_TYPE(SCM_C_FUNCPOINTERP(o), (o)))
+#define SCM_NUMBERP(o) SCM_SAL_NUMBERP(o)
+
#define SCM_INTP(o) SCM_SAL_INTP(o)
#define SCM_INT_VALUE(o) SCM_SAL_INT_VALUE(o)
#define SCM_INT_SET_VALUE(o, val) SCM_SAL_INT_SET_VALUE((o), (val))
Modified: branches/r5rs/sigscheme/storage-compact.h
===================================================================
--- branches/r5rs/sigscheme/storage-compact.h 2006-01-10 09:19:24 UTC (rev 2879)
+++ branches/r5rs/sigscheme/storage-compact.h 2006-01-10 11:51:22 UTC (rev 2880)
@@ -633,10 +633,39 @@
SAL Macros
==============================================================================*/
-/* object representation information for optimization */
-#define SCM_SAL_HAS_IMMEDIATE_INT 1
-#define SCM_SAL_HAS_IMMEDIATE_CHAR 1
+/*=======================================
+ Object Representation Information
+=======================================*/
+#define SCM_SAL_HAS_CHAR 1
+#define SCM_SAL_HAS_RATIONAL 0
+#define SCM_SAL_HAS_REAL 0
+#define SCM_SAL_HAS_COMPLEX 0
+#define SCM_SAL_HAS_STRING 1
+#define SCM_SAL_HAS_VECTOR 1
+/* for optimization */
+#define SCM_SAL_HAS_IMMEDIATE_CHAR_ONLY 1
+#define SCM_SAL_HAS_IMMEDIATE_NUMBER_ONLY 1
+#define SCM_SAL_HAS_IMMEDIATE_INT_ONLY 1
+#define SCM_SAL_HAS_IMMEDIATE_RATIONAL_ONLY 0
+#define SCM_SAL_HAS_IMMEDIATE_REAL_ONLY 0
+#define SCM_SAL_HAS_IMMEDIATE_COMPLEX_ONLY 0
+
+#define SCM_SAL_CHAR_BITS /* FIXME */
+#define SCM_SAL_CHAR_MAX /* FIXME */
+
+#define SCM_SAL_INT_BITS /* FIXME */
+#define SCM_SAL_INT_MAX /* FIXME */
+#define SCM_SAL_INT_MIN /* FIXME */
+
+/* string length */
+#define SCM_SAL_STRLEN_BITS /* FIXME */
+#define SCM_SAL_STRLEN_MAX /* FIXME */
+
+/* vector length */
+#define SCM_SAL_VECLEN_BITS /* FIXME */
+#define SCM_SAL_VECLEN_MAX /* FIXME */
+
/*=======================================
Object Creators
=======================================*/
Modified: branches/r5rs/sigscheme/storage-fatty.h
===================================================================
--- branches/r5rs/sigscheme/storage-fatty.h 2006-01-10 09:19:24 UTC (rev 2879)
+++ branches/r5rs/sigscheme/storage-fatty.h 2006-01-10 11:51:22 UTC (rev 2880)
@@ -42,6 +42,7 @@
/*=======================================
System Include
=======================================*/
+#include <limits.h>
#include <stddef.h>
#include <stdint.h> /* FIXME: make C99-independent */
@@ -136,10 +137,39 @@
} obj;
};
-/* object representation information for optimization */
-#define SCM_SAL_HAS_IMMEDIATE_INT 0
-#define SCM_SAL_HAS_IMMEDIATE_CHAR 0
+/*=======================================
+ Object Representation Information
+=======================================*/
+#define SCM_SAL_HAS_CHAR 1
+#define SCM_SAL_HAS_RATIONAL 0
+#define SCM_SAL_HAS_REAL 0
+#define SCM_SAL_HAS_COMPLEX 0
+#define SCM_SAL_HAS_STRING 1
+#define SCM_SAL_HAS_VECTOR 1
+/* for optimization */
+#define SCM_SAL_HAS_IMMEDIATE_CHAR_ONLY 0
+#define SCM_SAL_HAS_IMMEDIATE_NUMBER_ONLY 0
+#define SCM_SAL_HAS_IMMEDIATE_INT_ONLY 0
+#define SCM_SAL_HAS_IMMEDIATE_RATIONAL_ONLY 0
+#define SCM_SAL_HAS_IMMEDIATE_REAL_ONLY 0
+#define SCM_SAL_HAS_IMMEDIATE_COMPLEX_ONLY 0
+
+#define SCM_SAL_CHAR_BITS SCM_INT_BITS
+#define SCM_SAL_CHAR_MAX SCM_INT_MAX
+
+#define SCM_SAL_INT_BITS (sizeof(int) * CHAR_BIT)
+#define SCM_SAL_INT_MAX INT_MAX
+#define SCM_SAL_INT_MIN INT_MIN
+
+/* string length */
+#define SCM_SAL_STRLEN_BITS SCM_INT_BITS
+#define SCM_SAL_STRLEN_MAX SCM_INT_MAX
+
+/* vector length */
+#define SCM_SAL_VECLEN_BITS SCM_INT_BITS
+#define SCM_SAL_VECLEN_MAX SCM_INT_MAX
+
/*=======================================
Object Creators
=======================================*/
@@ -198,6 +228,8 @@
#define SCM_ENTYPE(o, objtype) ((o)->type = (objtype))
/* Real Accessors */
+#define SCM_SAL_NUMBERP(o) SCM_SAL_INTP(o)
+
#define SCM_SAL_INTP(o) (SCM_TYPE(o) == ScmInt)
#define SCM_SAL_ENTYPE_INT(o) (SCM_ENTYPE((o), ScmInt))
#define SCM_SAL_INT_VALUE(o) (SCM_AS_INT(o)->obj.integer.value)
Modified: branches/r5rs/sigscheme/write.c
===================================================================
--- branches/r5rs/sigscheme/write.c 2006-01-10 09:19:24 UTC (rev 2879)
+++ branches/r5rs/sigscheme/write.c 2006-01-10 11:51:22 UTC (rev 2880)
@@ -239,9 +239,6 @@
case ScmConstant:
write_constant(port, obj, otype);
break;
- case ScmFreeCell:
- ERR("You cannot print ScmFreeCell, may be GC bug.");
- break;
case ScmCPointer:
scm_port_printf(port, "#<c_pointer %p>", SCM_C_POINTER_VALUE(obj));
break;
@@ -249,6 +246,8 @@
scm_port_printf(port, "#<c_func_pointer %p>",
(void *)(uintptr_t)SCM_C_FUNCPOINTER_VALUE(obj));
break;
+ default:
+ SCM_ASSERT(scm_false);
}
}
More information about the uim-commit
mailing list