diff options
author | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-09-14 19:30:39 +0100 |
---|---|---|
committer | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-09-14 19:30:39 +0100 |
commit | dae2422fd18487c89dd79dc54eb4345861ab7bdc (patch) | |
tree | 14f046128de9c35a57e3574a3a4365095b680d4f /builtin.c | |
parent | f98e3e6c26b3b53701e1e6c2ff98ab6227cde3b8 (diff) | |
parent | 37cfc912c1f384d177162f8aa706452754d2c6ab (diff) |
Merge branch 'libjq'
Conflicts:
Makefile.am
configure.ac
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 21 |
1 files changed, 2 insertions, 19 deletions
@@ -1,32 +1,15 @@ #include <math.h> #include <stdlib.h> #include <string.h> +#include <assert.h> #include "builtin.h" #include "compile.h" #include "jq_parser.h" +#include "bytecode.h" #include "locfile.h" -#include "jv_aux.h" -#include "jv_file.h" #include "jv_unicode.h" - -typedef jv (*func_1)(jv); -typedef jv (*func_2)(jv,jv); -typedef jv (*func_3)(jv,jv,jv); -typedef jv (*func_4)(jv,jv,jv,jv); -typedef jv (*func_5)(jv,jv,jv,jv,jv); -jv cfunction_invoke(struct cfunction* function, jv input[]) { - switch (function->nargs) { - case 1: return ((func_1)function->fptr)(input[0]); - case 2: return ((func_2)function->fptr)(input[0], input[1]); - case 3: return ((func_3)function->fptr)(input[0], input[1], input[2]); - case 4: return ((func_4)function->fptr)(input[0], input[1], input[2], input[3]); - case 5: return ((func_5)function->fptr)(input[0], input[1], input[2], input[3], input[4]); - default: return jv_invalid_with_msg(jv_string("Function takes too many arguments")); - } -} - static jv type_error(jv bad, const char* msg) { jv err = jv_invalid_with_msg(jv_string_fmt("%s %s", jv_kind_name(jv_get_kind(bad)), |