From 7d8d97933fda9e3a35eb850da6274fef9884a710 Mon Sep 17 00:00:00 2001 From: Stephen Dolan Date: Mon, 17 Sep 2012 23:06:48 +0100 Subject: [PATCH] Builtin function 'type'. --- c/builtin.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/c/builtin.c b/c/builtin.c index 86951890..74264f40 100644 --- a/c/builtin.c +++ b/c/builtin.c @@ -137,6 +137,11 @@ static void f_tostring(jv input[], jv output[]) { } } +static void f_type(jv input[], jv output[]) { + output[0] = jv_string(jv_kind_name(jv_get_kind(input[0]))); + jv_free(input[0]); +} + static block j_empty() { return gen_op_block_defn(CLOSURE_CREATE, "empty", gen_op_simple(BACKTRACK)); } @@ -175,6 +180,7 @@ static struct cfunction function_list[] = { {f_tostring, "tostring", CALL_BUILTIN_1_1}, {f_equal, "_equal", CALL_BUILTIN_3_1}, {f_length, "length", CALL_BUILTIN_1_1}, + {f_type, "type", CALL_BUILTIN_1_1}, }; static struct symbol_table builtins = {function_list, sizeof(function_list)/sizeof(function_list[0])};