summaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorStephen Dolan <mu@netsoc.tcd.ie>2012-12-10 22:30:09 +0000
committerStephen Dolan <mu@netsoc.tcd.ie>2012-12-10 22:30:09 +0000
commit34ff993059310e362db0cc41bce43670e09e10ac (patch)
tree6959a3d6bbb875df069e4f8b3d080de428bb18ee /builtin.c
parentb660bd2be669765c4070b1d8c1f9026e05abdbeb (diff)
error() function
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/builtin.c b/builtin.c
index b572dfaf..f046e91a 100644
--- a/builtin.c
+++ b/builtin.c
@@ -41,7 +41,6 @@ static jv type_error2(jv bad1, jv bad2, const char* msg) {
return err;
}
-
static jv f_plus(jv input, jv a, jv b) {
jv_free(input);
if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {
@@ -297,6 +296,13 @@ static jv f_type(jv input) {
return out;
}
+static jv f_error(jv input, jv msg) {
+ jv_free(input);
+ msg = f_tostring(msg);
+ return jv_invalid_with_msg(msg);
+}
+
+
static struct cfunction function_list[] = {
{(cfunction_ptr)f_plus, "_plus", 3},
{(cfunction_ptr)f_minus, "_minus", 3},
@@ -322,6 +328,7 @@ static struct cfunction function_list[] = {
{(cfunction_ptr)f_max, "max", 1},
{(cfunction_ptr)f_min_by_impl, "_min_by_impl", 2},
{(cfunction_ptr)f_max_by_impl, "_max_by_impl", 2},
+ {(cfunction_ptr)f_error, "error", 2},
};
static struct symbol_table cbuiltins =