From 1e4ff3276abb461c74cc4371dd6b3126ff0c4dad Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Wed, 30 Oct 2013 15:37:33 +0900 Subject: [PATCH] add pic_type_repr --- include/picrin/value.h | 1 + src/value.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/picrin/value.h b/include/picrin/value.h index 65fe0688..2191336b 100644 --- a/include/picrin/value.h +++ b/include/picrin/value.h @@ -77,6 +77,7 @@ struct pic_port; #define pic_vec_ptr(o) ((struct pic_vector *)(o).u.data) enum pic_tt pic_type(pic_value); +const char *pic_type_repr(enum pic_tt); pic_value pic_nil_value(); pic_value pic_true_value(); diff --git a/src/value.c b/src/value.c index 8aaa60d2..33a9a874 100644 --- a/src/value.c +++ b/src/value.c @@ -30,6 +30,28 @@ pic_type(pic_value v) abort(); } +const char * +pic_type_repr(enum pic_tt tt) +{ + static const char *reprs[13] = { + "nil", + "boolean", + "float", + "int", + "symbol", + "eof", + "undef", + "pair", + "string", + "vector", + "proc", + "port", + "env" + }; + + return reprs[tt]; +} + pic_value pic_nil_value() {