summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Dolan <mu@netsoc.tcd.ie>2012-09-17 23:06:48 +0100
committerStephen Dolan <mu@netsoc.tcd.ie>2012-09-17 23:06:48 +0100
commit7d8d97933fda9e3a35eb850da6274fef9884a710 (patch)
treefa3229c5f86b32db7832f7827ed58b97e65225ce
parentf13865d7a11d1aa6322a28e46eaaa463d823f44e (diff)
Builtin function 'type'.
-rw-r--r--c/builtin.c6
1 files changed, 6 insertions, 0 deletions
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])};