[uim-commit] r2108 - branches/r5rs/sigscheme
kzk at freedesktop.org
kzk at freedesktop.org
Wed Nov 9 01:02:01 PST 2005
Author: kzk
Date: 2005-11-09 01:01:57 -0800 (Wed, 09 Nov 2005)
New Revision: 2108
Modified:
branches/r5rs/sigscheme/sigschemetype-compact.h
branches/r5rs/sigscheme/test-compact.c
Log:
* sigscheme/sigschemetype-compact.h
- (SCM_CONS_SET_CAR, SCM_CONS_SET_CDR,
SCM_SYMBOL_SET_VCELL, SCM_VALUEPACKET_SET_VALUES): no need to mask
- (SCM_CLOSURE_SET_EXP, SCM_CLOSURE_SET_ENV)
: no need to mask, and fixed typo
* sigscheme/test-compact.c
- add test for Closure
- add test for SCM_DO_MARK and SCM_DO_UNMARK
Modified: branches/r5rs/sigscheme/sigschemetype-compact.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype-compact.h 2005-11-09 08:55:31 UTC (rev 2107)
+++ branches/r5rs/sigscheme/sigschemetype-compact.h 2005-11-09 09:01:57 UTC (rev 2108)
@@ -302,8 +302,8 @@
GC bit Accessor
=======================================*/
#define SCM_GC_BIT(a) (SCM_CAST_UINT(a) & SCM_GCBIT_MASK)
-#define SCM_IS_MARKED(a) (SCM_GC_BIT(a))
-#define SCM_IS_UNMARKED(a) (!SCM_IS_MARKED(a))
+#define SCM_IS_MARKED(a) (SCM_GC_BIT(a))
+#define SCM_IS_UNMARKED(a) (!SCM_IS_MARKED(a))
#define SCM_DO_MARK(a) ((a) = (ScmObj)(SCM_CAST_UINT(a) | SCM_GCBIT_MASK))
#define SCM_DO_UNMARK(a) ((a) = (ScmObj)(SCM_CAST_UINT(a) & ~SCM_GCBIT_MASK))
@@ -427,8 +427,8 @@
=======================================*/
#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_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_CONS_SET_CAR(a, car) (SCM_CAR(a) = (car))
+#define SCM_CONS_SET_CDR(a, cdr) (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)))
@@ -436,12 +436,12 @@
#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_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_CLOSURE_SET_EXP(a, exp) (SCM_CLOSURE_EXP(a) = (exp))
+#define SCM_CLOSURE_SET_ENV(a, env) (SCM_CLOSURE_ENV(a) = (env))
#define SCM_SYMBOL_VCELL(a) (SCM_AS_SYMBOL(a)->car)
#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_VCELL(a, vcell) (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_VALUE_AS_INT(SCM_AS_STRING(a)->car, SCM_TAG_OTHERS_VALUE_OFFSET_STRING))
@@ -460,7 +460,7 @@
#define SCM_MAKE_VALUEPACKET(vals) (Scm_NewValuePacket(vals))
#define SCM_VALUEPACKET_VALUES(a) (SCM_AS_VALUEPACKET(a)->car)
-#define SCM_VALUEPACKET_SET_VALUES(a, v) (SCM_SET_VALUE_AS_OBJ(SCM_VALUEPACKET_VALUES(a), (v)))
+#define SCM_VALUEPACKET_SET_VALUES(a, v) (SCM_VALUEPACKET_VALUES(a) = (v))
#define SCM_FUNC_CFUNC(a) (SCM_WORD_CAST(ScmFuncType, (SCM_AS_FUNC(a)->car)))
#define SCM_FUNC_TYPECODE(a) ((enum ScmFuncTypeCode)SCM_GET_VALUE_AS_INT(SCM_AS_FUNC(a)->cdr, SCM_TAG_OTHERS_VALUE_OFFSET_FUNC))
Modified: branches/r5rs/sigscheme/test-compact.c
===================================================================
--- branches/r5rs/sigscheme/test-compact.c 2005-11-09 08:55:31 UTC (rev 2107)
+++ branches/r5rs/sigscheme/test-compact.c 2005-11-09 09:01:57 UTC (rev 2108)
@@ -35,16 +35,16 @@
#include <stdio.h>
#include <stdlib.h>
+#include "sigscheme.h"
#include "sigschemetype-compact.h"
-typedef void (*ScmCFunc)(void);
-
#define PRINT_SECTION(SECTIONNAME) \
do { \
printf("-------- Check %s --------\n", SECTIONNAME); \
} while (/*CONSTCOND*/ 0)
-#define SCM_ASSERT(cond) \
+#undef SCM_ASSERT
+#define SCM_ASSERT(cond) \
((cond) || die(__FILE__, __LINE__))
#define ASSERT_TYPE(expected, actual, pred) \
@@ -56,6 +56,16 @@
} \
} while(0)
+#define MARK_TEST(obj) \
+ do { \
+ SCM_DO_MARK(obj); \
+ SCM_ASSERT(SCM_IS_MARKED(obj)); \
+ SCM_DO_UNMARK(obj); \
+ SCM_ASSERT(SCM_IS_UNMARKED(obj)); \
+ SCM_DO_MARK(obj); \
+ SCM_ASSERT(SCM_IS_MARKED(obj)); \
+ } while(0);
+
static int die(const char *filename, int line)
{
printf("assertion faled. (file : %s, line : %d)\n", filename, line);
@@ -226,6 +236,8 @@
SCM_ASSERT(SCM_INTP(SCM_CDR(obj)));
SCM_ASSERT(SCM_INT_VALUE(SCM_CDR(obj)) == 2);
+ MARK_TEST(obj);
+
return obj;
}
@@ -249,6 +261,8 @@
SCM_ASSERT(SCM_INTP(SCM_SYMBOL_VCELL(obj)));
SCM_ASSERT(SCM_INT_VALUE(SCM_SYMBOL_VCELL(obj)) == 1);
+ MARK_TEST(obj);
+
return obj;
}
@@ -271,6 +285,8 @@
SCM_ASSERT(SCM_CHAR_VALUE(obj) == val);
SCM_ASSERT(strcmp(SCM_CHAR_VALUE(obj), ch) == 0);
+ MARK_TEST(obj);
+
return obj;
}
@@ -291,6 +307,8 @@
check_type(ScmString, obj);
SCM_ASSERT(strlen(str) == SCM_STRING_LEN(obj));
+ MARK_TEST(obj);
+
return obj;
}
@@ -319,6 +337,8 @@
check_type(ScmFunc, obj);
SCM_ASSERT(SCM_FUNC_CFUNC(obj) == Scm_CheckCons);
+ MARK_TEST(obj);
+
return obj;
}
@@ -335,18 +355,20 @@
SCM_CLOSURE_SET_EXP(obj, exp);
check_type(ScmClosure, obj);
- SCM_ASSERT(SCM_CONSP(SCM_CLOSURE_EXP(obj)));
+ check_type(ScmCons, SCM_CLOSURE_EXP(obj));
SCM_ASSERT(SCM_EQ(SCM_CLOSURE_EXP(obj), exp));
- SCM_ASSERT(SCM_INTP(SCM_CAR(SCM_CLOSURE_EXP(obj))));
- SCM_ASSERT(SCM_INTP(SCM_CDR(SCM_CLOSURE_EXP(obj))));
+ check_type(ScmInt, SCM_CAR(SCM_CLOSURE_EXP(obj)));
+ check_type(ScmInt, SCM_CDR(SCM_CLOSURE_EXP(obj)));
SCM_CLOSURE_SET_ENV(obj, env);
check_type(ScmClosure, obj);
- SCM_ASSERT(SCM_CONSP(SCM_CLOSURE_ENV(obj)));
+ check_type(ScmCons, SCM_CLOSURE_ENV(obj));
SCM_ASSERT(SCM_EQ(SCM_CLOSURE_ENV(obj), env));
- SCM_ASSERT(SCM_INTP(SCM_CAR(SCM_CLOSURE_ENV(obj))));
- SCM_ASSERT(SCM_INTP(SCM_CDR(SCM_CLOSURE_ENV(obj))));
+ check_type(ScmInt, SCM_CAR(SCM_CLOSURE_ENV(obj)));
+ check_type(ScmInt, SCM_CDR(SCM_CLOSURE_ENV(obj)));
+ MARK_TEST(obj);
+
return obj;
}
@@ -378,6 +400,8 @@
SCM_ASSERT(SCM_INTP(SCM_VECTOR_CREF(obj, 0)));
SCM_ASSERT(SCM_INT_VALUE(SCM_VECTOR_CREF(obj, 0)) == 3);
+ MARK_TEST(obj);
+
return obj;
}
@@ -400,6 +424,8 @@
check_type(ScmPort, obj);
SCM_ASSERT(SCM_PORT_IMPL(obj) == port);
+ MARK_TEST(obj);
+
return obj;
}
@@ -426,6 +452,8 @@
check_type(ScmContinuation, obj);
SCM_ASSERT(SCM_CONTINUATION_TAG(obj) == 0);
+ MARK_TEST(obj);
+
return obj;
}
@@ -444,6 +472,8 @@
SCM_ASSERT(SCM_EQ(SCM_VALUEPACKET_VALUES(obj), values));
SCM_ASSERT(SCM_CONSP(SCM_VALUEPACKET_VALUES(obj)));
+ MARK_TEST(obj);
+
return obj;
}
@@ -461,6 +491,8 @@
check_type(ScmCPointer, obj);
SCM_ASSERT(SCM_C_POINTER_VALUE(obj) == data);
+ MARK_TEST(obj);
+
return obj;
}
@@ -482,6 +514,8 @@
check_type(ScmCFuncPointer, obj);
SCM_ASSERT(SCM_C_FUNCPOINTER_VALUE(obj) == (ScmCFunc)test_func);
+ MARK_TEST(obj);
+
return obj;
}
@@ -529,6 +563,7 @@
Scm_CheckSymbol("aiueo");
Scm_CheckChar("a");
Scm_CheckStringCopying("aiueo");
+ Scm_CheckClosure();
Scm_CheckFunc();
Scm_CheckVector(5);
Scm_CheckValuePacket();
More information about the uim-commit
mailing list