[uim-commit] r2583 - in branches/r5rs: . sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Wed Dec 14 17:06:04 PST 2005
Author: yamaken
Date: 2005-12-14 17:06:01 -0800 (Wed, 14 Dec 2005)
New Revision: 2583
Added:
branches/r5rs/sigscheme/storage-fatty.h
Modified:
branches/r5rs/Makefile.am
branches/r5rs/sigscheme/config.h
branches/r5rs/sigscheme/sigscheme.h
branches/r5rs/sigscheme/sigschemeinternal.h
branches/r5rs/sigscheme/storage-gc.c
Log:
* This commit introduces the storage abstraction layer and
storage-fatty.h as an implementation
* sigscheme/config.h
- (SCM_USE_STORAGE_ABSTRACTION_LAYER): New macro
* sigscheme/sigscheme.h
- (SCM_CAR, SCM_CDR, SCM_CAAR, SCM_CADR, SCM_CDAR, SCM_CDDR): New
macro for SCM_USE_STORAGE_ABSTRACTION_LAYER
- (enum ScmObjType, enum ScmFuncTypeCode, enum ScmReductionState,
enum ScmReturnType, enum ScmPortFlag, struct ScmEvalState_,
ScmEvalState, SCM_MAKE_BOOL, SCM_SYNTAXP, SCM_PROCEDUREP,
SCM_NULLP, SCM_FALSEP, SCM_NFALSEP, SCM_EOFP): Copied from
sigschemetype.h for SCM_USE_STORAGE_ABSTRACTION_LAYER
- include storage-fatty.h or storage-compact.h when
SCM_USE_STORAGE_ABSTRACTION_LAYER
- (SCM_MAKE_INT, SCM_MAKE_CONS, SCM_MAKE_SYMBOL, SCM_MAKE_CHAR,
SCM_MAKE_STRING, SCM_MAKE_STRING_COPYING,
SCM_MAKE_IMMUTABLE_STRING, SCM_MAKE_IMMUTABLE_STRING_COPYING,
SCM_MAKE_FUNC, SCM_MAKE_CLOSURE, SCM_MAKE_VECTOR, SCM_MAKE_PORT,
SCM_MAKE_CONTINUATION, SCM_MAKE_C_POINTER, SCM_MAKE_C_FUNCPOINTER,
SCM_MAKE_VALUEPACKET, SCM_TYPE, SCM_INTP, SCM_INT_VALUE,
SCM_INT_SET_VALUE, SCM_CONSP, SCM_CONS_CAR, SCM_CONS_CDR,
SCM_CONS_SET_CAR, SCM_CONS_SET_CDR, SCM_SYMBOLP, SCM_SYMBOL_NAME,
SCM_SYMBOL_VCELL, SCM_SYMBOL_SET_NAME, SCM_SYMBOL_SET_VCELL,
SCM_CHARP, SCM_CHAR_VALUE, SCM_CHAR_SET_VALUE, SCM_STRINGP,
SCM_STRING_STR, SCM_STRING_LEN, SCM_STRING_SET_STR,
SCM_STRING_SET_LEN, SCM_STRING_MUTABLEP, SCM_STRING_SET_MUTABLE,
SCM_STRING_SET_IMMUTABLE, SCM_FUNCP, SCM_FUNC_TYPECODE,
SCM_FUNC_CFUNC, SCM_FUNC_SET_TYPECODE, SCM_FUNC_SET_CFUNC,
SCM_CLOSUREP, SCM_CLOSURE_EXP, SCM_CLOSURE_SET_EXP,
SCM_CLOSURE_ENV, SCM_CLOSURE_SET_ENV, SCM_VECTORP, SCM_VECTOR_VEC,
SCM_VECTOR_LEN, SCM_VECTOR_SET_VEC, SCM_VECTOR_SET_LEN,
SCM_VECTOR_VALID_INDEXP, SCM_PORTP, SCM_PORT_FLAG, SCM_PORT_IMPL,
SCM_PORT_SET_FLAG, SCM_PORT_SET_IMPL, SCM_CONTINUATIONP,
SCM_CONTINUATION_OPAQUE, SCM_CONTINUATION_TAG,
SCM_CONTINUATION_SET_OPAQUE, SCM_CONTINUATION_SET_TAG,
SCM_VALUEPACKETP, SCM_VALUEPACKET_VALUES, SCM_CONSTANTP,
SCM_C_POINTERP, SCM_C_POINTER_VALUE, SCM_C_POINTER_SET_VALUE,
SCM_C_FUNCPOINTERP, SCM_C_FUNCPOINTER_VALUE,
SCM_C_FUNCPOINTER_SET_VALUE, SCM_INTERACTION_ENV, SCM_R5RS_ENV,
SCM_NULL_ENV, SCM_ENVP, SCM_INVALID_REF, SCM_REF_CAR, SCM_REF_CDR,
SCM_REF_OFF_HEAP, SCM_DEREF, SCM_SET, SCM_INVALID, SCM_NULL,
SCM_TRUE, SCM_FALSE, SCM_EOF, SCM_UNBOUND, SCM_UNDEF, SCM_EQ
SCM_SYM_QUOTE, SCM_SYM_QUASIQUOTE, SCM_SYM_UNQUOTE,
SCM_SYM_UNQUOTE_SPLICING): New macro for
SCM_USE_STORAGE_ABSTRACTION_LAYER
- (SCM_ASSERT_TYPE, SCM_AS_INT, SCM_AS_CONS, SCM_AS_SYMBOL,
SCM_AS_CHAR, SCM_AS_STRING, SCM_AS_FUNC, SCM_AS_CLOSURE,
SCM_AS_VECTOR, SCM_AS_PORT, SCM_AS_CONTINUATION,
SCM_AS_VALUEPACKET, SCM_AS_C_POINTER, SCM_AS_C_FUNCPOINTER): New
macro copied from the equivalent definition for each macro of
sigschemetype.h
* sigscheme/storage-fatty.h
- New file (copied from sigschemetype.h)
- (ScmCell, ScmObj, ScmRef, ScmFuncType, enum ScmStrMutationType,
struct ScmCell_): Copied from sigschemetype.h
- (SCM_ENTYPE, SCM_MARK, SCM_STRING_MUTATION_TYPE_MASK,
SCM_STRING_STR_VALUE_MASK, SCM_STRING_MUTATION_TYPE,
SCM_VECTOR_CREF, SCM_VECTOR_SET_CREF, SCM_VECTOR_REF,
SCM_VECTOR_SET_REF, SCM_VECTOR_CHECK_IDX, SigScm_null,
SigScm_true, SigScm_false, SigScm_eof, SigScm_unbound,
SigScm_undef, Scm_sym_quote, Scm_sym_quasiquote, Scm_sym_unquote,
Scm_sym_unquote_splicing, ): Copied from sigschemetype.h
- (SCM_SAL_MAKE_INT, SCM_SAL_MAKE_CONS, SCM_SAL_MAKE_SYMBOL,
SCM_SAL_MAKE_CHAR, SCM_SAL_MAKE_STRING,
SCM_SAL_MAKE_STRING_COPYING, SCM_SAL_MAKE_IMMUTABLE_STRING,
SCM_SAL_MAKE_IMMUTABLE_STRING_COPYING, SCM_SAL_MAKE_FUNC,
SCM_SAL_MAKE_CLOSURE, SCM_SAL_MAKE_VECTOR, SCM_SAL_MAKE_PORT,
SCM_SAL_MAKE_CONTINUATION, SCM_SAL_MAKE_C_POINTER,
SCM_SAL_MAKE_C_FUNCPOINTER, SCM_SAL_MAKE_VALUEPACKET): New macro
- (SCM_SAL_STRING_MUTABLEP, SCM_SAL_VECTOR_VALID_INDEXP): New macro
- (SCM_SAL_TYPE, SCM_SAL_INTP, SCM_SAL_ENTYPE_INT,
SCM_SAL_INT_VALUE, SCM_SAL_INT_SET_VALUE, SCM_SAL_CONSP,
SCM_SAL_ENTYPE_CONS, SCM_SAL_CONS_CAR, SCM_SAL_CONS_CDR,
SCM_SAL_CONS_SET_CAR, SCM_SAL_CONS_SET_CDR, SCM_SAL_SYMBOLP,
SCM_SAL_ENTYPE_SYMBOL, SCM_SAL_SYMBOL_NAME,
SCM_SAL_SYMBOL_SET_NAME, SCM_SAL_SYMBOL_VCELL,
SCM_SAL_SYMBOL_SET_VCELL, SCM_SAL_CHARP, SCM_SAL_ENTYPE_CHAR,
SCM_SAL_CHAR_VALUE, SCM_SAL_CHAR_SET_VALUE, SCM_SAL_STRINGP,
SCM_SAL_ENTYPE_STRING, SCM_SAL_STRING_STR, SCM_SAL_STRING_SET_STR,
SCM_SAL_STRING_LEN, SCM_SAL_STRING_SET_LEN,
SCM_SAL_STRING_SET_MUTABLE, SCM_SAL_STRING_SET_IMMUTABLE,
SCM_SAL_FUNCP, SCM_SAL_ENTYPE_FUNC, SCM_SAL_FUNC_TYPECODE,
SCM_SAL_FUNC_SET_TYPECODE, SCM_SAL_FUNC_CFUNC,
SCM_SAL_FUNC_SET_CFUNC, SCM_SAL_CLOSUREP, SCM_SAL_ENTYPE_CLOSURE,
SCM_SAL_CLOSURE_EXP, SCM_SAL_CLOSURE_SET_EXP, SCM_SAL_CLOSURE_ENV,
SCM_SAL_CLOSURE_SET_ENV, SCM_SAL_VECTORP, SCM_SAL_ENTYPE_VECTOR,
SCM_SAL_VECTOR_VEC, SCM_SAL_VECTOR_SET_VEC, SCM_SAL_VECTOR_LEN,
SCM_SAL_VECTOR_SET_LEN, SCM_SAL_PORTP, SCM_SAL_ENTYPE_PORT,
SCM_SAL_PORT_FLAG, SCM_SAL_PORT_SET_FLAG, SCM_SAL_PORT_IMPL,
SCM_SAL_PORT_SET_IMPL, SCM_SAL_CONTINUATIONP,
SCM_SAL_ENTYPE_CONTINUATION, SCM_SAL_CONTINUATION_OPAQUE,
SCM_SAL_CONTINUATION_SET_OPAQUE, SCM_SAL_CONTINUATION_TAG,
SCM_SAL_CONTINUATION_SET_TAG, SCM_SAL_VALUEPACKETP,
SCM_SAL_NULLVALUESP, SCM_SAL_ENTYPE_VALUEPACKET,
SCM_SAL_VALUEPACKET_VALUES, SCM_SAL_VALUECONS_CAR,
SCM_SAL_VALUECONS_CDR, SCM_SAL_VALUEPACKET_SET_VALUES,
SCM_SAL_CONSTANTP, SCM_SAL_C_POINTERP, SCM_SAL_ENTYPE_C_POINTER,
SCM_SAL_C_POINTER_VALUE, SCM_SAL_C_POINTER_SET_VALUE,
SCM_SAL_C_FUNCPOINTERP, SCM_SAL_ENTYPE_C_FUNCPOINTER,
SCM_SAL_C_FUNCPOINTER_VALUE, SCM_SAL_C_FUNCPOINTER_SET_VALUE,
SCM_SAL_INTERACTION_ENV, SCM_SAL_R5RS_ENV, SCM_SAL_NULL_ENV,
SCM_SAL_ENVP, SCM_SAL_INVALID_REF, SCM_SAL_REF_CAR,
SCM_SAL_REF_CDR, SCM_SAL_REF_OFF_HEAP, SCM_SAL_DEREF, SCM_SAL_SET,
SCM_SAL_INVALID, SCM_SAL_NULL, SCM_SAL_TRUE, SCM_SAL_FALSE,
SCM_SAL_EOF, SCM_SAL_UNBOUND, SCM_SAL_UNDEF, SCM_SAL_EQ,
SCM_SAL_SYM_QUOTE, SCM_SAL_SYM_QUASIQUOTE, SCM_SAL_SYM_UNQUOTE,
SCM_SAL_SYM_UNQUOTE_SPLICING): New macro copied from the
equivalent definition for each macro of sigschemetype.h
- (SCM_SAL_FREECELLP, SCM_SAL_AS_FREECELL, SCM_SAL_FREECELL_CAR,
SCM_SAL_FREECELL_CDR, SCM_SAL_ENTYPE_FREECELL,
SCM_SAL_FREECELL_SET_CAR, SCM_SAL_FREECELL_SET_CDR): New macro
copied from the equivalent definition for each macro of
sigschemeinternal.h
- (SCM_UNMARKER, SCM_MARKER): Copied from storage-gc.c
- (SCM_SAL_IS_MARKED, SCM_SAL_IS_UNMARKED, SCM_SAL_DO_MARK,
SCM_SAL_DO_UNMARK): New macro copied from the equivalent
definition for each macro of storage-gc.c
* sigscheme/sigschemeinternal.h
- (SCM_ENTYPE_INT, SCM_ENTYPE_CONS, SCM_ENTYPE_SYMBOL,
SCM_ENTYPE_CHAR, SCM_ENTYPE_STRING, SCM_ENTYPE_FUNC,
SCM_ENTYPE_CLOSURE, SCM_ENTYPE_VECTOR, SCM_ENTYPE_PORT,
SCM_ENTYPE_CONTINUATION, SCM_ENTYPE_C_POINTER,
SCM_ENTYPE_C_FUNCPOINTER, SCM_ENTYPE_VALUEPACKET, SCM_NULLVALUESP,
SCM_VALUECONS_CAR, SCM_VALUECONS_CDR, SCM_VALUEPACKET_SET_VALUES,
SCM_ENTYPE_FREECELL, SCM_AS_FREECELL, SCM_FREECELLP,
SCM_FREECELL_CAR, SCM_FREECELL_CDR, SCM_FREECELL_SET_CAR,
SCM_FREECELL_SET_CDR, SCM_IS_MARKED, SCM_IS_UNMARKED, SCM_DO_MARK,
SCM_DO_UNMARK): New macro for SCM_USE_STORAGE_ABSTRACTION_LAYER
* sigscheme/storage-gc.c
- (SCM_UNMARKER, SCM_MARKER, SCM_IS_MARKED, SCM_IS_UNMARKED,
SCM_DO_MARK, SCM_DO_UNMARK): Disable when
!SCM_USE_STORAGE_ABSTRACTION_LAYER
* Makefile.am
- (EXTRA_DIST): Add storage-fatty.h
Modified: branches/r5rs/Makefile.am
===================================================================
--- branches/r5rs/Makefile.am 2005-12-14 20:27:12 UTC (rev 2582)
+++ branches/r5rs/Makefile.am 2005-12-15 01:06:01 UTC (rev 2583)
@@ -2,7 +2,8 @@
SUBDIRS = m4 doc sigscheme replace uim scm gtk qt xim helper po tables test fep examples pixmaps
EXTRA_DIST = README.ja INSTALL.ja test.sh.in uim.spec.in \
intltool-extract.in intltool-merge.in intltool-update.in \
- uim.pc.in ChangeLog.old uim.desktop autogen.sh RELEASING
+ uim.pc.in ChangeLog.old uim.desktop autogen.sh RELEASING \
+ storage-fatty.h
DISTCLEANFILES = uim.pc intltool-extract intltool-merge intltool-update po/.intltool-merge-cache
Modified: branches/r5rs/sigscheme/config.h
===================================================================
--- branches/r5rs/sigscheme/config.h 2005-12-14 20:27:12 UTC (rev 2582)
+++ branches/r5rs/sigscheme/config.h 2005-12-15 01:06:01 UTC (rev 2583)
@@ -85,6 +85,7 @@
#define SCM_OBJ_COMPACT 0 /* object representation compaction (experimental) */
#define SCM_GCC4_READY_GC 1 /* use experimental gcc4-ready stack protection */
+#define SCM_USE_STORAGE_ABSTRACTION_LAYER 1 /* use the experimental code organization */
/*===========================================================================
Tunings
Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h 2005-12-14 20:27:12 UTC (rev 2582)
+++ branches/r5rs/sigscheme/sigscheme.h 2005-12-15 01:06:01 UTC (rev 2583)
@@ -99,6 +99,14 @@
#define SCM_SYMBOL_BOUNDP(sym) (!SCM_EQ(SCM_SYMBOL_VCELL(sym), SCM_UNBOUND))
#define SCM_CONS(kar, kdr) (Scm_NewCons((kar), (kdr)))
+#if SCM_USE_STORAGE_ABSTRACTION_LAYER
+#define SCM_CAR(kons) (SCM_CONS_CAR(kons))
+#define SCM_CDR(kons) (SCM_CONS_CDR(kons))
+#define SCM_CAAR(kons) (SCM_CAR(SCM_CAR(kons)))
+#define SCM_CADR(kons) (SCM_CAR(SCM_CDR(kons)))
+#define SCM_CDAR(kons) (SCM_CDR(SCM_CAR(kons)))
+#define SCM_CDDR(kons) (SCM_CDR(SCM_CDR(kons)))
+#endif /* SCM_USE_STORAGE_ABSTRACTION_LAYER */
#define SCM_LIST_1(elm0) \
(SCM_CONS((elm0), SCM_NULL))
@@ -193,18 +201,9 @@
#define SCM_WRITESS_TO_PORT(port, obj) ((*Scm_writess_func)(port, obj))
-/*=======================================
- Struct Declarations
-=======================================*/
-typedef void (*ScmCFunc)(void);
-
-/* type declaration */
-#if SCM_OBJ_COMPACT
-#include "sigschemetype-compact.h"
-#else
-#include "sigschemetype.h"
-#endif
-
+/*============================================================================
+ Type Definitions
+============================================================================*/
enum ScmDebugCategory {
SCM_DBG_NONE = 0,
SCM_DBG_ERRMSG = 1 << 0, /* the "Error: foo bar" style msgs */
@@ -225,7 +224,309 @@
SCM_DBG_OTHER = 1 << 30 /* all other messages */
};
+#if SCM_USE_STORAGE_ABSTRACTION_LAYER
+enum ScmObjType {
+ ScmInt = 0,
+ ScmCons = 1,
+ ScmSymbol = 2,
+ ScmChar = 3,
+ ScmString = 4,
+ ScmFunc = 5,
+ ScmClosure = 6,
+ ScmVector = 7,
+ ScmPort = 8,
+ ScmContinuation = 9,
+ ScmConstant = 10,
+ ScmValuePacket = 11,
+ ScmFreeCell = 12,
+
+ ScmCPointer = 20,
+ ScmCFuncPointer = 21
+};
+
+/*
+ * Function types:
+ *
+ * Function objects must tag themselves with proper information so
+ * that the evaluator can correctly invoke them. See doc/invocation
+ * for details.
+ */
+enum ScmFuncTypeCode {
+ SCM_FUNCTYPE_MAND_BITS = 4,
+ SCM_FUNCTYPE_MAND_MASK = (1 << SCM_FUNCTYPE_MAND_BITS)-1,
+#define SCM_FUNCTYPE_MAND_MAX 5
+ /* SCM_FUNCTYPE_MAND_MAX = 5, */
+ SCM_FUNCTYPE_SYNTAX = 1 << SCM_FUNCTYPE_MAND_BITS,
+
+ SCM_FUNCTYPE_FIXED = 0 << (SCM_FUNCTYPE_MAND_BITS+1),
+ SCM_FUNCTYPE_VARIADIC = 1 << (SCM_FUNCTYPE_MAND_BITS+1),
+ SCM_FUNCTYPE_TAIL_REC = 1 << (SCM_FUNCTYPE_MAND_BITS+2),
+
+ SCM_FUNCTYPE_ODDBALL = 1 << (SCM_FUNCTYPE_MAND_BITS+10),
+
+ /* Compound types. */
+ SCM_PROCEDURE_FIXED = SCM_FUNCTYPE_FIXED,
+ SCM_PROCEDURE_FIXED_TAIL_REC = SCM_FUNCTYPE_TAIL_REC,
+ SCM_PROCEDURE_VARIADIC = SCM_FUNCTYPE_VARIADIC,
+ SCM_PROCEDURE_VARIADIC_TAIL_REC = SCM_FUNCTYPE_VARIADIC | SCM_FUNCTYPE_TAIL_REC,
+
+ SCM_SYNTAX_FIXED = SCM_PROCEDURE_FIXED | SCM_FUNCTYPE_SYNTAX,
+ SCM_SYNTAX_FIXED_TAIL_REC = SCM_PROCEDURE_FIXED_TAIL_REC | SCM_FUNCTYPE_SYNTAX,
+ SCM_SYNTAX_VARIADIC = SCM_PROCEDURE_VARIADIC | SCM_FUNCTYPE_SYNTAX,
+ SCM_SYNTAX_VARIADIC_TAIL_REC = SCM_PROCEDURE_VARIADIC_TAIL_REC | SCM_FUNCTYPE_SYNTAX,
+
+ /* Special type. */
+ SCM_REDUCTION_OPERATOR = SCM_FUNCTYPE_ODDBALL
+};
+
+/* Where we are in a reduction process. */
+enum ScmReductionState {
+ SCM_REDUCE_0, /* No argument was given. */
+ SCM_REDUCE_1, /* Only 1 argument was given. */
+ SCM_REDUCE_PARTWAY, /* We have more arguments pending. */
+ SCM_REDUCE_LAST, /* The callee must finalize. */
+ SCM_REDUCE_STOP /* Callee wants to stop. */
+};
+
+enum ScmReturnType {
+ SCM_RETTYPE_AS_IS = 0,
+ SCM_RETTYPE_NEED_EVAL = 1
+};
+
+enum ScmPortFlag {
+ SCM_PORTFLAG_NONE = 0,
+ SCM_PORTFLAG_OUTPUT = 1 << 0,
+ SCM_PORTFLAG_INPUT = 1 << 1,
+ SCM_PORTFLAG_LIVE_OUTPUT = 1 << 2,
+ SCM_PORTFLAG_LIVE_INPUT = 1 << 3,
+
+ SCM_PORTFLAG_DIR_MASK = (SCM_PORTFLAG_OUTPUT | SCM_PORTFLAG_INPUT),
+ SCM_PORTFLAG_ALIVENESS_MASK = (SCM_PORTFLAG_LIVE_OUTPUT
+ | SCM_PORTFLAG_LIVE_INPUT)
+};
+
+typedef void (*ScmCFunc)(void);
+
+#if SCM_OBJ_COMPACT
+#include "storage-compact.h"
+#else /* SCM_OBJ_COMPACT */
+#include "storage-fatty.h"
+#endif /* SCM_OBJ_COMPACT */
+/*
+ * A storage implementation defines following types.
+ *
+ * typedef <hidden> ScmCell;
+ * typedef <hidden> ScmObj;
+ * typedef <hidden> ScmRef;
+ *
+ * typedef ScmObj (*ScmFuncType)();
+ */
+
+/* The evaluator's state */
+typedef struct ScmEvalState_ ScmEvalState;
+struct ScmEvalState_ {
+ ScmObj env;
+ enum ScmReturnType ret_type;
+};
+
/*=======================================
+ Object Creators
+=======================================*/
+#define SCM_MAKE_BOOL(x) ((x) ? SCM_TRUE : SCM_FALSE)
+/* FIXME: define arguments */
+#define SCM_MAKE_INT SCM_SAL_MAKE_INT
+#define SCM_MAKE_CONS SCM_SAL_MAKE_CONS
+#define SCM_MAKE_SYMBOL SCM_SAL_MAKE_SYMBOL
+#define SCM_MAKE_CHAR SCM_SAL_MAKE_CHAR
+#define SCM_MAKE_STRING SCM_SAL_MAKE_STRING
+#define SCM_MAKE_STRING_COPYING SCM_SAL_MAKE_STRING_COPYING
+#define SCM_MAKE_IMMUTABLE_STRING SCM_SAL_MAKE_IMMUTABLE_STRING
+#define SCM_MAKE_IMMUTABLE_STRING_COPYING SCM_SAL_MAKE_IMMUTABLE_STRING_COPYING
+#define SCM_MAKE_FUNC SCM_SAL_MAKE_FUNC
+#define SCM_MAKE_CLOSURE SCM_SAL_MAKE_CLOSURE
+#define SCM_MAKE_VECTOR SCM_SAL_MAKE_VECTOR
+#define SCM_MAKE_PORT SCM_SAL_MAKE_PORT
+#define SCM_MAKE_CONTINUATION SCM_SAL_MAKE_CONTINUATION
+#if SCM_USE_NONSTD_FEATURES
+#define SCM_MAKE_C_POINTER SCM_SAL_MAKE_C_POINTER
+#define SCM_MAKE_C_FUNCPOINTER SCM_SAL_MAKE_C_FUNCPOINTER
+#endif /* SCM_USE_NONSTD_FEATURES */
+#define SCM_MAKE_VALUEPACKET SCM_SAL_MAKE_VALUEPACKET
+
+/*=======================================
+ Object Accessors
+=======================================*/
+/* ScmObj Global Attribute */
+#define SCM_TYPE(o) SCM_SAL_TYPE(o)
+
+/* Type Confirmation */
+#if SCM_ACCESSOR_ASSERT
+#define SCM_ASSERT_TYPE(cond, o) (SCM_ASSERT(cond), (o))
+#else /* SCM_ACCESSOR_ASSERT */
+#define SCM_ASSERT_TYPE(cond, o) (o)
+#endif /* SCM_ACCESSOR_ASSERT */
+#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)))
+#define SCM_AS_CHAR(o) (SCM_ASSERT_TYPE(SCM_CHARP(o), (o)))
+#define SCM_AS_STRING(o) (SCM_ASSERT_TYPE(SCM_STRINGP(o), (o)))
+#define SCM_AS_FUNC(o) (SCM_ASSERT_TYPE(SCM_FUNCP(o), (o)))
+#define SCM_AS_CLOSURE(o) (SCM_ASSERT_TYPE(SCM_CLOSUREP(o), (o)))
+#define SCM_AS_VECTOR(o) (SCM_ASSERT_TYPE(SCM_VECTORP(o), (o)))
+#define SCM_AS_PORT(o) (SCM_ASSERT_TYPE(SCM_PORTP(o), (o)))
+#define SCM_AS_CONTINUATION(o) (SCM_ASSERT_TYPE(SCM_CONTINUATIONP(o), (o)))
+#define SCM_AS_VALUEPACKET(o) (SCM_ASSERT_TYPE(SCM_VALUEPACKETP(o), (o)))
+#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_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))
+
+#define SCM_CONSP(o) SCM_SAL_CONSP(o)
+#define SCM_CONS_CAR(o) SCM_SAL_CONS_CAR(o)
+#define SCM_CONS_CDR(o) SCM_SAL_CONS_CDR(o)
+#define SCM_CONS_SET_CAR(o, kar) SCM_SAL_CONS_SET_CAR((o), (kar))
+#define SCM_CONS_SET_CDR(o, kdr) SCM_SAL_CONS_SET_CDR((o), (kdr))
+
+#define SCM_SYMBOLP(o) SCM_SAL_SYMBOLP(o)
+#define SCM_SYMBOL_NAME(o) SCM_SAL_SYMBOL_NAME(o)
+#define SCM_SYMBOL_VCELL(o) SCM_SAL_SYMBOL_VCELL(o)
+#define SCM_SYMBOL_SET_NAME(o, name) SCM_SAL_SYMBOL_SET_NAME((o), (name))
+#define SCM_SYMBOL_SET_VCELL(o, val) SCM_SAL_SYMBOL_SET_VCELL((o), (val))
+
+#define SCM_CHARP(o) SCM_SAL_CHARP(o)
+#define SCM_CHAR_VALUE(o) SCM_SAL_CHAR_VALUE(o)
+#define SCM_CHAR_SET_VALUE(o, val) SCM_SAL_CHAR_SET_VALUE((o), (val))
+
+#define SCM_STRINGP(o) SCM_SAL_STRINGP(o)
+#define SCM_STRING_STR(o) SCM_SAL_STRING_STR(o)
+#define SCM_STRING_LEN(o) SCM_SAL_STRING_LEN(o)
+#define SCM_STRING_SET_STR(o, str) SCM_SAL_STRING_SET_STR((o), (str))
+#define SCM_STRING_SET_LEN(o, len) SCM_SAL_STRING_SET_LEN((o), (len))
+#define SCM_STRING_MUTABLEP(o) SCM_SAL_STRING_MUTABLEP(o)
+#define SCM_STRING_SET_MUTABLE(o) SCM_SAL_STRING_SET_MUTABLE(o)
+#define SCM_STRING_SET_IMMUTABLE(o) SCM_SAL_STRING_SET_IMMUTABLE(o)
+
+#define SCM_FUNCP(o) SCM_SAL_FUNCP(o)
+#define SCM_FUNC_TYPECODE(o) SCM_SAL_FUNC_TYPECODE(o)
+#define SCM_FUNC_CFUNC(o) SCM_SAL_FUNC_CFUNC(o)
+#define SCM_FUNC_SET_TYPECODE(o, type) SCM_SAL_FUNC_SET_TYPECODE((o), (type))
+#define SCM_FUNC_SET_CFUNC(o, func) SCM_SAL_FUNC_SET_CFUNC((o), (func))
+#define SCM_SYNTAXP(o) (SCM_FUNCP(o) \
+ && (SCM_FUNC_TYPECODE(o) & SCM_FUNCTYPE_SYNTAX))
+#define SCM_PROCEDUREP(o) ((SCM_FUNCP(o) \
+ && !(SCM_FUNC_TYPECODE(o) & SCM_FUNCTYPE_SYNTAX)) \
+ || SCM_CLOSUREP(o) \
+ || SCM_CONTINUATIONP(o))
+
+#define SCM_CLOSUREP(o) SCM_SAL_CLOSUREP(o)
+#define SCM_CLOSURE_EXP(o) SCM_SAL_CLOSURE_EXP(o)
+#define SCM_CLOSURE_SET_EXP(o, exp) SCM_SAL_CLOSURE_SET_EXP((o), (exp))
+#define SCM_CLOSURE_ENV(o) SCM_SAL_CLOSURE_ENV(o)
+#define SCM_CLOSURE_SET_ENV(o, env) SCM_SAL_CLOSURE_SET_ENV((o), (env))
+
+#define SCM_VECTORP(o) SCM_SAL_VECTORP(o)
+#define SCM_VECTOR_VEC(o) SCM_SAL_VECTOR_VEC(o)
+#define SCM_VECTOR_LEN(o) SCM_SAL_VECTOR_LEN(o)
+#define SCM_VECTOR_SET_VEC(o, vec) SCM_SAL_VECTOR_SET_VEC((o), (vec))
+#define SCM_VECTOR_SET_LEN(o, len) SCM_SAL_VECTOR_SET_LEN((o), (len))
+#define SCM_VECTOR_VALID_INDEXP(o, i) SCM_SAL_VECTOR_VALID_INDEXP((o), (i))
+
+#define SCM_PORTP(o) SCM_SAL_PORTP(o)
+#define SCM_PORT_FLAG(o) SCM_SAL_PORT_FLAG(o)
+#define SCM_PORT_IMPL(o) SCM_SAL_PORT_IMPL(o)
+#define SCM_PORT_SET_FLAG(o, flag) SCM_SAL_PORT_SET_FLAG((o), (flag))
+#define SCM_PORT_SET_IMPL(o, impl) SCM_SAL_PORT_SET_IMPL((o), (impl))
+
+#define SCM_CONTINUATIONP(o) SCM_SAL_CONTINUATIONP(o)
+#define SCM_CONTINUATION_OPAQUE(o) SCM_SAL_CONTINUATION_OPAQUE(o)
+#define SCM_CONTINUATION_TAG(o) SCM_SAL_CONTINUATION_TAG(o)
+#define SCM_CONTINUATION_SET_OPAQUE(o, val) \
+ SCM_SAL_CONTINUATION_SET_OPAQUE((o), (val))
+#define SCM_CONTINUATION_SET_TAG(o, val) \
+ SCM_SAL_CONTINUATION_SET_TAG((o), (val))
+
+#define SCM_VALUEPACKETP(o) SCM_SAL_VALUEPACKETP(o)
+#define SCM_VALUEPACKET_VALUES(o) SCM_SAL_VALUEPACKET_VALUES(o)
+
+#define SCM_CONSTANTP(o) SCM_SAL_CONSTANTP(o)
+
+#define SCM_C_POINTERP(o) SCM_SAL_C_POINTERP(o)
+#define SCM_C_POINTER_VALUE(o) SCM_SAL_C_POINTER_VALUE(o)
+#define SCM_C_POINTER_SET_VALUE(o, ptr) SCM_SAL_C_POINTER_SET_VALUE((o), (ptr))
+
+#define SCM_C_FUNCPOINTERP(o) SCM_SAL_C_FUNCPOINTERP(o)
+#define SCM_C_FUNCPOINTER_VALUE(o) SCM_SAL_C_FUNCPOINTER_VALUE(o)
+#define SCM_C_FUNCPOINTER_SET_VALUE(o, funcptr) \
+ SCM_SAL_C_FUNCPOINTER_SET_VALUE((o), (funcptr))
+
+/*============================================================================
+ Environment Specifiers
+============================================================================*/
+#define SCM_INTERACTION_ENV SCM_SAL_INTERACTION_ENV
+/*
+ * Current implementation cannot handle scheme-report-environment and
+ * null-environment properly. Be careful to use these environemnts.
+ */
+#define SCM_R5RS_ENV SCM_SAL_R5RS_ENV
+#define SCM_NULL_ENV SCM_SAL_NULL_ENV
+
+#define SCM_ENVP(env) SCM_SAL_ENVP(env)
+
+/*============================================================================
+ Abstract ScmObj Reference For Storage-Representation Independent Efficient
+ List Operations
+============================================================================*/
+#define SCM_INVALID_REF SCM_SAL_INVALID_REF
+
+#define SCM_REF_CAR(kons) (SCM_SAL_REF_CAR(kons))
+#define SCM_REF_CDR(kons) (SCM_SAL_REF_CDR(kons))
+#define SCM_REF_OFF_HEAP(obj) (SCM_SAL_REF_OFF_HEAP(obj))
+
+/* SCM_DEREF(ref) is not permitted to be used as lvalue */
+#define SCM_DEREF(ref) (SCM_SAL_DEREF(ref))
+
+/* RFC: Is there a better name? */
+#define SCM_SET(ref, obj) (SCM_SAL_SET((ref), (obj)))
+
+/*============================================================================
+ Special Constants and Predicates
+============================================================================*/
+#define SCM_INVALID SCM_SAL_INVALID
+#define SCM_NULL SCM_SAL_NULL
+#define SCM_TRUE SCM_SAL_TRUE
+#define SCM_FALSE SCM_SAL_FALSE
+#define SCM_EOF SCM_SAL_EOF
+#define SCM_UNBOUND SCM_SAL_UNBOUND
+#define SCM_UNDEF SCM_SAL_UNDEF
+
+#define SCM_EQ(a, b) (SCM_SAL_EQ((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))
+
+/*============================================================================
+ Predefined Symbols
+============================================================================*/
+/* for list construction */
+#define SCM_SYM_QUOTE SCM_SAL_SYM_QUOTE
+#define SCM_SYM_QUASIQUOTE SCM_SAL_SYM_QUASIQUOTE
+#define SCM_SYM_UNQUOTE SCM_SAL_SYM_UNQUOTE
+#define SCM_SYM_UNQUOTE_SPLICING SCM_SAL_SYM_UNQUOTE_SPLICING
+
+#else /* SCM_USE_STORAGE_ABSTRACTION_LAYER */
+
+/* type declaration */
+#if SCM_OBJ_COMPACT
+#include "sigschemetype-compact.h"
+#else
+#include "sigschemetype.h"
+#endif
+#endif /* SCM_USE_STORAGE_ABSTRACTION_LAYER */
+
+/*=======================================
Variable Declarations
=======================================*/
/* storage-gc.c */
Modified: branches/r5rs/sigscheme/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/sigschemeinternal.h 2005-12-14 20:27:12 UTC (rev 2582)
+++ branches/r5rs/sigscheme/sigschemeinternal.h 2005-12-15 01:06:01 UTC (rev 2583)
@@ -92,6 +92,47 @@
#define TRACE_FRAME_OBJ CAR
#define TRACE_FRAME_ENV CDR
+#if SCM_USE_STORAGE_ABSTRACTION_LAYER
+#define SCM_ENTYPE_INT(o) (SCM_SAL_ENTYPE_INT(o))
+#define SCM_ENTYPE_CONS(o) (SCM_SAL_ENTYPE_CONS(o))
+#define SCM_ENTYPE_SYMBOL(o) (SCM_SAL_ENTYPE_SYMBOL(o))
+#define SCM_ENTYPE_CHAR(o) (SCM_SAL_ENTYPE_CHAR(o))
+#define SCM_ENTYPE_STRING(o) (SCM_SAL_ENTYPE_STRING(o))
+#define SCM_ENTYPE_FUNC(o) (SCM_SAL_ENTYPE_FUNC(o))
+#define SCM_ENTYPE_CLOSURE(o) (SCM_SAL_ENTYPE_CLOSURE(o))
+#define SCM_ENTYPE_VECTOR(o) (SCM_SAL_ENTYPE_VECTOR(o))
+#define SCM_ENTYPE_PORT(o) (SCM_SAL_ENTYPE_PORT(o))
+#define SCM_ENTYPE_CONTINUATION(o) (SCM_SAL_ENTYPE_CONTINUATION(o))
+#define SCM_ENTYPE_C_POINTER(o) (SCM_SAL_ENTYPE_C_POINTER(o))
+#define SCM_ENTYPE_C_FUNCPOINTER(o) (SCM_SAL_ENTYPE_C_FUNCPOINTER(o))
+
+#define SCM_ENTYPE_VALUEPACKET(o) (SCM_SAL_ENTYPE_VALUEPACKET(o))
+#if SCM_USE_VALUECONS
+#define SCM_NULLVALUESP(o) (SCM_SAL_NULLVALUESP(o))
+#define SCM_VALUECONS_CAR(o) (SCM_SAL_VALUECONS_CAR(o))
+#define SCM_VALUECONS_CDR(o) (SCM_SAL_VALUECONS_CDR(o))
+#else /* SCM_USE_VALUECONS */
+#define SCM_VALUEPACKET_SET_VALUES(o, vals) \
+ (SCM_SAL_VALUEPACKET_SET_VALUES((o), (vals)))
+#endif /* SCM_USE_VALUECONS */
+
+#define SCM_ENTYPE_FREECELL(o) (SCM_SAL_ENTYPE_FREECELL(o))
+#define SCM_AS_FREECELL(o) (SCM_SAL_AS_FREECELL(o))
+
+#define SCM_FREECELLP(o) (SCM_SAL_FREECELLP(o))
+#define SCM_FREECELL_CAR(o) (SCM_SAL_FREECELL_CAR(o))
+#define SCM_FREECELL_CDR(o) (SCM_SAL_FREECELL_CDR(o))
+#define SCM_FREECELL_SET_CAR(o, kar) (SCM_SAL_FREECELL_SET_CAR((o), (kar)))
+#define SCM_FREECELL_SET_CDR(o, kdr) (SCM_SAL_FREECELL_SET_CDR((o), (kdr)))
+
+/* FIXME: rename appropriately */
+#define SCM_IS_MARKED(o) (SCM_SAL_IS_MARKED(o))
+#define SCM_IS_UNMARKED(o) (SCM_SAL_IS_UNMARKED(o))
+#define SCM_DO_MARK(o) (SCM_SAL_DO_MARK(o))
+#define SCM_DO_UNMARK(o) (SCM_SAL_DO_UNMARK(o))
+
+#else /* SCM_USE_STORAGE_ABSTRACTION_LAYER */
+
/* FreeCell Handling Macros */
#if SCM_OBJ_COMPACT
#define SCM_FREECELLP(a) (SCM_CONSP(a))
@@ -110,6 +151,7 @@
#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
+#endif /* SCM_USE_STORAGE_ABSTRACTION_LAYER */
/* Prefix-less Abbreviation Names For Convenient Internal Use */
#define SYM_QUOTE SCM_SYM_QUOTE
Copied: branches/r5rs/sigscheme/storage-fatty.h (from rev 2582, branches/r5rs/sigscheme/sigschemetype.h)
===================================================================
--- branches/r5rs/sigscheme/sigschemetype.h 2005-12-14 20:27:12 UTC (rev 2582)
+++ branches/r5rs/sigscheme/storage-fatty.h 2005-12-15 01:06:01 UTC (rev 2583)
@@ -0,0 +1,383 @@
+/*===========================================================================
+ * FileName : storage-fatty.h
+ * About : Storage abstraction (fatty representation)
+ *
+ * Copyright (C) 2005 by Kazuki Ohta (mover at hct.zaq.ne.jp)
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of authors nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+===========================================================================*/
+#ifndef __STORAGE_FATTY_H
+#define __STORAGE_FATTY_H
+
+/*
+ * Internal representation defined in this file MUST NOT directly touched by
+ * libsscm users. Use abstract public APIs defined in sigscheme.h.
+ */
+
+/*=======================================
+ System Include
+=======================================*/
+#include <stddef.h>
+
+/*=======================================
+ Local Include
+=======================================*/
+
+/*=======================================
+ Type Declarations
+=======================================*/
+typedef struct ScmCell_ ScmCell;
+typedef ScmCell *ScmObj;
+typedef ScmObj *ScmRef;
+
+typedef ScmObj (*ScmFuncType)();
+
+/*=======================================
+ Struct Declarations
+=======================================*/
+enum ScmStrMutationType {
+ SCM_STR_IMMUTABLE = 0,
+ SCM_STR_MUTABLE = 1
+};
+
+/* Scheme Object */
+struct ScmCell_ {
+ enum ScmObjType type;
+ int gcmark;
+
+ union {
+ struct {
+ int value;
+ } int_value;
+
+ struct {
+ ScmObj car;
+ ScmObj cdr;
+ } cons;
+
+ struct {
+ char *sym_name;
+ ScmObj v_cell;
+ } symbol;
+
+ struct {
+ int value;
+ } ch;
+
+ struct {
+ char *str;
+ int len;
+ } string;
+
+ struct {
+ enum ScmFuncTypeCode type;
+ ScmFuncType func;
+ } func;
+
+ struct ScmClosure {
+ ScmObj exp;
+ ScmObj env;
+ } closure;
+
+ struct ScmVector {
+ ScmObj *vec;
+ int len;
+ } vector;
+
+ struct ScmPort {
+ enum ScmPortFlag flag;
+ ScmCharPort *impl;
+ } port;
+
+ struct ScmContinuation {
+ void *opaque;
+ int tag;
+ } continuation;
+
+#if !SCM_USE_VALUECONS
+ struct ScmValuePacket {
+ ScmObj values;
+ } value_pack;
+#endif
+
+ struct ScmCPointer {
+ void *data;
+ } c_pointer;
+
+ struct ScmCFuncPointer {
+ ScmCFunc func;
+ } c_func_pointer;
+ } obj;
+};
+
+/*=======================================
+ Object Creators
+=======================================*/
+#define SCM_SAL_MAKE_INT Scm_NewInt
+#define SCM_SAL_MAKE_CONS Scm_NewCons
+#define SCM_SAL_MAKE_SYMBOL Scm_NewSymbol
+#define SCM_SAL_MAKE_CHAR Scm_NewChar
+#define SCM_SAL_MAKE_STRING Scm_NewMutableString
+#define SCM_SAL_MAKE_STRING_COPYING Scm_NewMutableStringCopying
+#define SCM_SAL_MAKE_IMMUTABLE_STRING Scm_NewImmutableString
+#define SCM_SAL_MAKE_IMMUTABLE_STRING_COPYING Scm_NewImmutableStringCopying
+#define SCM_SAL_MAKE_FUNC Scm_NewFunc
+#define SCM_SAL_MAKE_CLOSURE Scm_NewClosure
+#define SCM_SAL_MAKE_VECTOR Scm_NewVector
+#define SCM_SAL_MAKE_PORT Scm_NewPort
+#define SCM_SAL_MAKE_CONTINUATION Scm_NewContinuation
+#if SCM_USE_NONSTD_FEATURES
+#define SCM_SAL_MAKE_C_POINTER Scm_NewCPointer
+#define SCM_SAL_MAKE_C_FUNCPOINTER Scm_NewCFuncPointer
+#endif /* SCM_USE_NONSTD_FEATURES */
+#if SCM_USE_VALUECONS
+#define SCM_SAL_MAKE_VALUEPACKET(vals) (NULLP(vals) ? SigScm_null_values : \
+ (SCM_ENTYPE_VALUEPACKET(vals), (vals)))
+#else /* SCM_USE_VALUECONS */
+#define SCM_SAL_MAKE_VALUEPACKET(vals) (Scm_NewValuePacket(vals))
+#endif /* SCM_USE_VALUECONS */
+
+/*=======================================
+ Accessors For Scheme Objects
+=======================================*/
+/* ScmObj Global Attribute */
+#define SCM_SAL_TYPE(o) ((o)->type)
+#define SCM_ENTYPE(a, objtype) ((a)->type = (objtype))
+#define SCM_MARK(a) ((a)->gcmark)
+
+/* Real Accessors */
+#define SCM_SAL_INTP(a) (SCM_TYPE(a) == ScmInt)
+#define SCM_SAL_ENTYPE_INT(a) (SCM_ENTYPE((a), ScmInt))
+#define SCM_SAL_INT_VALUE(a) (SCM_AS_INT(a)->obj.int_value.value)
+#define SCM_SAL_INT_SET_VALUE(a, val) (SCM_INT_VALUE(a) = (val))
+
+#define SCM_SAL_CONSP(a) (SCM_TYPE(a) == ScmCons)
+#define SCM_SAL_ENTYPE_CONS(a) (SCM_ENTYPE((a), ScmCons))
+#if SCM_DEBUG
+/* don't use as lvalue */
+#define SCM_SAL_CONS_CAR(a) (SCM_AS_CONS(a)->obj.cons.car + 0)
+#define SCM_SAL_CONS_CDR(a) (SCM_AS_CONS(a)->obj.cons.cdr + 0)
+#else /* SCM_DEBUG */
+#define SCM_SAL_CONS_CAR(a) (SCM_AS_CONS(a)->obj.cons.car)
+#define SCM_SAL_CONS_CDR(a) (SCM_AS_CONS(a)->obj.cons.cdr)
+#endif /* SCM_DEBUG */
+#define SCM_SAL_CONS_SET_CAR(a, kar) (SCM_AS_CONS(a)->obj.cons.car = (kar))
+#define SCM_SAL_CONS_SET_CDR(a, kdr) (SCM_AS_CONS(a)->obj.cons.cdr = (kdr))
+
+#define SCM_SAL_SYMBOLP(a) (SCM_TYPE(a) == ScmSymbol)
+#define SCM_SAL_ENTYPE_SYMBOL(a) (SCM_ENTYPE((a), ScmSymbol))
+#define SCM_SAL_SYMBOL_NAME(a) (SCM_AS_SYMBOL(a)->obj.symbol.sym_name)
+#define SCM_SAL_SYMBOL_SET_NAME(a, name) (SCM_SYMBOL_NAME(a) = (name))
+#define SCM_SAL_SYMBOL_VCELL(a) (SCM_AS_SYMBOL(a)->obj.symbol.v_cell)
+#define SCM_SAL_SYMBOL_SET_VCELL(a, vcell) (SCM_SYMBOL_VCELL(a) = (vcell))
+
+#define SCM_SAL_CHARP(a) (SCM_TYPE(a) == ScmChar)
+#define SCM_SAL_ENTYPE_CHAR(a) (SCM_ENTYPE((a), ScmChar))
+#define SCM_SAL_CHAR_VALUE(a) (SCM_AS_CHAR(a)->obj.ch.value)
+#define SCM_SAL_CHAR_SET_VALUE(a, val) (SCM_CHAR_VALUE(a) = (val))
+
+/* String Object uses tagged pointer for packing mutation type.
+ * LSB of ScmCell.obj.string.str is used to represent mutation type
+ * (mutable or immutable). */
+#define SCM_STRING_MUTATION_TYPE_MASK 0x1
+#define SCM_STRING_STR_VALUE_MASK ~SCM_STRING_MUTATION_TYPE_MASK
+#define SCM_SAL_STRINGP(a) (SCM_TYPE(a) == ScmString)
+#define SCM_SAL_ENTYPE_STRING(a) (SCM_ENTYPE((a), ScmString))
+#define SCM_SAL_STRING_STR(a) ((char*)(((unsigned int)(SCM_AS_STRING(a)->obj.string.str)) & SCM_STRING_STR_VALUE_MASK))
+#define SCM_SAL_STRING_SET_STR(a, val) (SCM_AS_STRING(a)->obj.string.str = \
+ ((char*)((((unsigned int)(SCM_STRING_STR(a))) & SCM_STRING_MUTATION_TYPE_MASK) \
+ | ((unsigned int)(val)))))
+#define SCM_SAL_STRING_LEN(a) (SCM_AS_STRING(a)->obj.string.len)
+#define SCM_SAL_STRING_SET_LEN(a, len) (SCM_STRING_LEN(a) = (len))
+#define SCM_STRING_MUTATION_TYPE(a) ((enum ScmStrMutationType)(((unsigned int)SCM_AS_STRING(a)->obj.string.str) \
+ & SCM_STRING_MUTATION_TYPE_MASK))
+#define SCM_SAL_STRING_MUTABLEP(o) \
+ (SCM_STRING_MUTATION_TYPE(o) == SCM_STR_MUTABLE)
+#define SCM_SAL_STRING_SET_MUTABLE(a) (SCM_AS_STRING(a)->obj.string.str = (char*)(((unsigned int)(SCM_AS_STRING(a)->obj.string.str)) \
+ | SCM_STR_MUTABLE))
+#define SCM_SAL_STRING_SET_IMMUTABLE(a) (SCM_AS_STRING(a)->obj.string.str = (char*)(((unsigned int)(SCM_AS_STRING(a)->obj.string.str)) \
+ | SCM_STR_IMMUTABLE))
+
+#define SCM_SAL_FUNCP(a) (SCM_TYPE(a) == ScmFunc)
+#define SCM_SAL_ENTYPE_FUNC(a) (SCM_ENTYPE((a), ScmFunc))
+#define SCM_SAL_FUNC_TYPECODE(a) (SCM_AS_FUNC(a)->obj.func.type)
+#define SCM_SAL_FUNC_SET_TYPECODE(a, type) (SCM_FUNC_TYPECODE(a) = (type))
+#define SCM_SAL_FUNC_CFUNC(a) (SCM_AS_FUNC(a)->obj.func.func)
+#define SCM_SAL_FUNC_SET_CFUNC(a, func) (SCM_FUNC_CFUNC(a) = (ScmFuncType)(func))
+
+#define SCM_SAL_CLOSUREP(a) (SCM_TYPE(a) == ScmClosure)
+#define SCM_SAL_ENTYPE_CLOSURE(a) (SCM_ENTYPE((a), ScmClosure))
+#define SCM_SAL_CLOSURE_EXP(a) (SCM_AS_CLOSURE(a)->obj.closure.exp)
+#define SCM_SAL_CLOSURE_SET_EXP(a, exp) (SCM_CLOSURE_EXP(a) = (exp))
+#define SCM_SAL_CLOSURE_ENV(a) (SCM_AS_CLOSURE(a)->obj.closure.env)
+#define SCM_SAL_CLOSURE_SET_ENV(a, env) (SCM_CLOSURE_ENV(a) = (env))
+
+#define SCM_SAL_VECTORP(a) (SCM_TYPE(a) == ScmVector)
+#define SCM_SAL_ENTYPE_VECTOR(a) (SCM_ENTYPE((a), ScmVector))
+#define SCM_SAL_VECTOR_VEC(a) (SCM_AS_VECTOR(a)->obj.vector.vec)
+#define SCM_SAL_VECTOR_SET_VEC(a, vec) (SCM_VECTOR_VEC(a) = (vec))
+#define SCM_SAL_VECTOR_LEN(a) (SCM_AS_VECTOR(a)->obj.vector.len)
+#define SCM_SAL_VECTOR_SET_LEN(a, len) (SCM_VECTOR_LEN(a) = (len))
+#define SCM_SAL_VECTOR_VALID_INDEXP(o, i) (0 <= (i) && (i) < SCM_VECTOR_LEN(o))
+/* backward compatibility */
+#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_VECTOR_CHECK_IDX(a, idx) ()
+
+#define SCM_SAL_PORTP(a) (SCM_TYPE(a) == ScmPort)
+#define SCM_SAL_ENTYPE_PORT(a) (SCM_ENTYPE((a), ScmPort))
+#define SCM_SAL_PORT_FLAG(a) (SCM_AS_PORT(a)->obj.port.flag)
+#define SCM_SAL_PORT_SET_FLAG(a, flag) (SCM_PORT_FLAG(a) = (flag))
+#define SCM_SAL_PORT_IMPL(a) (SCM_AS_PORT(a)->obj.port.impl)
+#define SCM_SAL_PORT_SET_IMPL(a, impl) (SCM_PORT_IMPL(a) = (impl))
+
+#define SCM_SAL_CONTINUATIONP(a) (SCM_TYPE(a) == ScmContinuation)
+#define SCM_SAL_ENTYPE_CONTINUATION(a) (SCM_ENTYPE((a), ScmContinuation))
+#define SCM_SAL_CONTINUATION_OPAQUE(a) (SCM_AS_CONTINUATION(a)->obj.continuation.opaque)
+#define SCM_SAL_CONTINUATION_SET_OPAQUE(a, val) (SCM_CONTINUATION_OPAQUE(a) = (val))
+#define SCM_SAL_CONTINUATION_TAG(a) (SCM_AS_CONTINUATION(a)->obj.continuation.tag)
+#define SCM_SAL_CONTINUATION_SET_TAG(a, val) (SCM_CONTINUATION_TAG(a) = (val))
+
+#if SCM_USE_VALUECONS
+/* to modify a VALUECONS, rewrite its type to cons by SCM_ENTYPE_CONS(vcons) */
+#define SCM_SAL_VALUEPACKETP(a) (SCM_TYPE(a) == ScmValuePacket)
+#define SCM_SAL_NULLVALUESP(a) (EQ((a), SigScm_null_values))
+#define SCM_SAL_ENTYPE_VALUEPACKET(a) (SCM_ENTYPE((a), ScmValuePacket))
+#define SCM_SAL_VALUEPACKET_VALUES(a) ((SCM_NULLVALUESP(a)) ? SCM_NULL : \
+ (SCM_ENTYPE_CONS(a), (a)))
+#define SCM_SAL_VALUECONS_CAR(a) (SCM_AS_VALUEPACKET(a)->obj.cons.car)
+#define SCM_SAL_VALUECONS_CDR(a) (SCM_AS_VALUEPACKET(a)->obj.cons.cdr)
+#else /* SCM_USE_VALUECONS */
+#define SCM_SAL_VALUEPACKETP(a) (SCM_TYPE(a) == ScmValuePacket)
+#define SCM_SAL_ENTYPE_VALUEPACKET(a) (SCM_ENTYPE((a), ScmValuePacket))
+#define SCM_SAL_VALUEPACKET_VALUES(a) (SCM_AS_VALUEPACKET(a)->obj.value_pack.values)
+#define SCM_SAL_VALUEPACKET_SET_VALUES(a, v) (SCM_VALUEPACKET_VALUES(a) = (v))
+#endif /* SCM_USE_VALUECONS */
+
+/*============================================================================
+ Special Constants (such as SCM_NULL)
+============================================================================*/
+#define SCM_SAL_CONSTANTP(a) (SCM_TYPE(a) == ScmConstant)
+
+/*============================================================================
+ C Pointer Object
+============================================================================*/
+#define SCM_SAL_C_POINTERP(a) (SCM_TYPE(a) == ScmCPointer)
+#define SCM_SAL_ENTYPE_C_POINTER(a) (SCM_ENTYPE((a), ScmCPointer))
+#define SCM_SAL_C_POINTER_VALUE(a) (SCM_AS_C_POINTER(a)->obj.c_pointer.data)
+#define SCM_SAL_C_POINTER_SET_VALUE(a, ptr) (SCM_C_POINTER_VALUE(a) = (ptr))
+
+#define SCM_SAL_C_FUNCPOINTERP(a) (SCM_TYPE(a) == ScmCFuncPointer)
+#define SCM_SAL_ENTYPE_C_FUNCPOINTER(a) (SCM_ENTYPE((a), ScmCFuncPointer))
+#define SCM_SAL_C_FUNCPOINTER_VALUE(a) (SCM_AS_C_FUNCPOINTER(a)->obj.c_func_pointer.func)
+#define SCM_SAL_C_FUNCPOINTER_SET_VALUE(a, funcptr) (SCM_C_FUNCPOINTER_VALUE(a) = (funcptr))
+
+/*============================================================================
+ GC Related Operations
+============================================================================*/
+#define SCM_SAL_FREECELLP(a) (SCM_TYPE(a) == ScmFreeCell)
+#define SCM_SAL_AS_FREECELL(a) (SCM_ASSERT_TYPE(SCM_FREECELLP(a), (a)))
+#define SCM_SAL_FREECELL_CAR(a) (SCM_AS_FREECELL(a)->obj.cons.car)
+#define SCM_SAL_FREECELL_CDR(a) (SCM_AS_FREECELL(a)->obj.cons.cdr)
+#define SCM_SAL_ENTYPE_FREECELL(a) (SCM_ENTYPE((a), ScmFreeCell))
+#define SCM_SAL_FREECELL_SET_CAR(a, car) (SCM_FREECELL_CAR(a) = (car))
+#define SCM_SAL_FREECELL_SET_CDR(a, cdr) (SCM_FREECELL_CDR(a) = (cdr))
+
+#define SCM_UNMARKER 0
+#define SCM_MARKER (SCM_UNMARKER + 1)
+#define SCM_SAL_IS_MARKED(o) (SCM_MARK(o) == SCM_MARKER)
+#define SCM_SAL_IS_UNMARKED(o) (!SCM_IS_MARKED(o))
+#define SCM_SAL_DO_MARK(o) (SCM_MARK(o) = SCM_MARKER)
+#define SCM_SAL_DO_UNMARK(o) (SCM_MARK(o) = SCM_UNMARKER)
+
+/*============================================================================
+ Environment Specifiers
+============================================================================*/
+#define SCM_SAL_INTERACTION_ENV SCM_NULL
+/*
+ * Current implementation cannot handle scheme-report-environment and
+ * null-environment properly. Be careful to use these environemnts.
+ */
+#define SCM_SAL_R5RS_ENV SCM_INTERACTION_ENV
+#define SCM_SAL_NULL_ENV SCM_INTERACTION_ENV
+
+#define SCM_SAL_ENVP(env) (NULLP(env) || CONSP(env))
+
+/*============================================================================
+ Abstract ScmObj Reference For Storage-Representation Independent Efficient
+ List Operations
+============================================================================*/
+#define SCM_SAL_INVALID_REF NULL
+
+#define SCM_SAL_REF_CAR(kons) (&SCM_AS_CONS(kons)->obj.cons.car)
+#define SCM_SAL_REF_CDR(kons) (&SCM_AS_CONS(kons)->obj.cons.cdr)
+#define SCM_SAL_REF_OFF_HEAP(obj) (&(obj))
+
+/* SCM_DEREF(ref) is not permitted to be used as lvalue */
+#if SCM_DEBUG
+#define SCM_SAL_DEREF(ref) (*(ref) + 0)
+#else /* SCM_DEBUG */
+#define SCM_SAL_DEREF(ref) (*(ref))
+#endif /* SCM_DEBUG */
+
+/* RFC: Is there a better name? */
+#define SCM_SAL_SET(ref, obj) (*(ref) = (obj))
+
+/*============================================================================
+ Special Constants and Predicates
+============================================================================*/
+#define SCM_SAL_INVALID NULL
+#define SCM_SAL_NULL SigScm_null
+#define SCM_SAL_TRUE SigScm_true
+#define SCM_SAL_FALSE SigScm_false
+#define SCM_SAL_EOF SigScm_eof
+#define SCM_SAL_UNBOUND SigScm_unbound
+#define SCM_SAL_UNDEF SigScm_undef
+
+#define SCM_SAL_EQ(a, b) ((a) == (b))
+
+/* storage.c */
+extern ScmObj SigScm_null, SigScm_true, SigScm_false, SigScm_eof;
+extern ScmObj SigScm_unbound, SigScm_undef;
+
+/*============================================================================
+ Predefined Symbols
+============================================================================*/
+/* for list construction */
+#define SCM_SAL_SYM_QUOTE Scm_sym_quote
+#define SCM_SAL_SYM_QUASIQUOTE Scm_sym_quasiquote
+#define SCM_SAL_SYM_UNQUOTE Scm_sym_unquote
+#define SCM_SAL_SYM_UNQUOTE_SPLICING Scm_sym_unquote_splicing
+
+/* sigscheme.c */
+extern ScmObj Scm_sym_quote, Scm_sym_quasiquote;
+extern ScmObj Scm_sym_unquote, Scm_sym_unquote_splicing;
+
+#endif /* __STORAGE_FATTY_H */
Modified: branches/r5rs/sigscheme/storage-gc.c
===================================================================
--- branches/r5rs/sigscheme/storage-gc.c 2005-12-14 20:27:12 UTC (rev 2582)
+++ branches/r5rs/sigscheme/storage-gc.c 2005-12-15 01:06:01 UTC (rev 2583)
@@ -79,14 +79,14 @@
/*=======================================
File Local Macro Declarations
=======================================*/
-#if !SCM_OBJ_COMPACT
+#if (!SCM_OBJ_COMPACT && !SCM_USE_STORAGE_ABSTRACTION_LAYER)
#define SCM_UNMARKER 0
#define SCM_MARKER (SCM_UNMARKER + 1)
#define SCM_IS_MARKED(a) (SCM_MARK(a) == SCM_MARKER)
#define SCM_IS_UNMARKED(a) (!SCM_IS_MARKED(a))
#define SCM_DO_MARK(a) (SCM_MARK(a) = SCM_MARKER)
#define SCM_DO_UNMARK(a) (SCM_MARK(a) = SCM_UNMARKER)
-#endif /* !SCM_OBJ_COMPACT */
+#endif
/*=======================================
Variable Declarations
More information about the uim-commit
mailing list