From 6d80ee8b96d23e46841ab0219b0ec70f0142f7a4 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 31 Mar 2014 08:26:33 +0900 Subject: [PATCH] add pic_assert_type --- include/picrin/value.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/picrin/value.h b/include/picrin/value.h index 74bfef10..17155d80 100644 --- a/include/picrin/value.h +++ b/include/picrin/value.h @@ -161,6 +161,11 @@ typedef struct pic_blob pic_blob; static inline enum pic_tt pic_type(pic_value); static inline const char *pic_type_repr(enum pic_tt); +#define pic_assert_type(pic, v, type) \ + if (! pic_##type##_p(v)) { \ + pic_errorf(pic, "expected " #type ", but got ~s", v); \ + } + static inline bool pic_valid_int(double); static inline pic_value pic_nil_value();