From ebacbd123ab9cd937fdddbfa6a6bbb25645c0f33 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 26 Oct 2014 17:29:50 -0700 Subject: * lib.c (type_check): Function moved to header file inline. (throw_mismatch): New function. * lib.h (throw_mismatch): Declared. (type_mismatch): Declaration turned into inline function. --- ChangeLog | 8 ++++++++ lib.c | 6 ++---- lib.h | 8 +++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 87235d7e..b0a235ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-10-26 Kaz Kylheku + + * lib.c (type_check): Function moved to header file inline. + (throw_mismatch): New function. + + * lib.h (throw_mismatch): Declared. + (type_mismatch): Declaration turned into inline function. + 2014-10-25 Kaz Kylheku * hash.c (hash_begin): Use coerce macro instead of raw C cast. diff --git a/lib.c b/lib.c index d74a864d..cc81745c 100644 --- a/lib.c +++ b/lib.c @@ -183,11 +183,9 @@ val typeof(val obj) } } -val type_check(val obj, int typecode) +val throw_mismatch(val obj, type_t t) { - if (type(obj) != typecode) - type_mismatch(lit("~s is not of type ~s"), obj, code2type(typecode), nao); - return t; + type_mismatch(lit("~s is not of type ~s"), obj, code2type(t), nao); } val type_check2(val obj, int t1, int t2) diff --git a/lib.h b/lib.h index 3e62f25b..9a1056d1 100644 --- a/lib.h +++ b/lib.h @@ -414,7 +414,13 @@ extern alloc_bytes_t gc_bytes; val identity(val obj); val typeof(val obj); -val type_check(val obj, int); +val throw_mismatch(val obj, type_t); +INLINE val type_check(val obj, type_t typecode) +{ + if (type(obj) != typecode) + throw_mismatch(obj, typecode); + return t; +} val type_check2(val obj, int, int); val type_check3(val obj, int, int, int); val class_check(val cobj, val class_sym); -- cgit v1.2.3