From 7af88962eea41fd25b483f1e4ef750bfd8a999e8 Mon Sep 17 00:00:00 2001 From: Stephen Dolan Date: Fri, 21 Jun 2013 12:06:28 +0100 Subject: Move cfunction invocation code to the interpreter loop. --- builtin.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'builtin.c') diff --git a/builtin.c b/builtin.c index a2adb1ac..bfad155d 100644 --- a/builtin.c +++ b/builtin.c @@ -3,29 +3,13 @@ #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)), -- cgit v1.2.3 From 298b2a60335569a31ed35a04c0c13cb355c0cb04 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Sun, 16 Jun 2013 08:25:12 -0500 Subject: Add libjq autoconf goo --- builtin.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'builtin.c') diff --git a/builtin.c b/builtin.c index a2adb1ac..3929dafd 100644 --- a/builtin.c +++ b/builtin.c @@ -4,8 +4,6 @@ #include "compile.h" #include "jq_parser.h" #include "locfile.h" -#include "jv_aux.h" -#include "jv_file.h" #include "jv_unicode.h" -- cgit v1.2.3 From 37cfc912c1f384d177162f8aa706452754d2c6ab Mon Sep 17 00:00:00 2001 From: Stephen Dolan Date: Sun, 23 Jun 2013 14:23:07 +0100 Subject: Remove #includes from jv.h --- builtin.c | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin.c') diff --git a/builtin.c b/builtin.c index 826d8c92..7ef64d5a 100644 --- a/builtin.c +++ b/builtin.c @@ -1,5 +1,6 @@ #include #include +#include #include "builtin.h" #include "compile.h" #include "jq_parser.h" -- cgit v1.2.3