aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-10-10 01:58:59 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-10-14 17:48:17 +0200
commit617e82a88719c44fff3753aaabedb3114823a034 (patch)
treeaf24c3a9f89e521c67eaaa56e67e4a80abef60ba
parent5192dc1ff23dae8644480a89ada8ff420ebb674a (diff)
downloadsparse-617e82a88719c44fff3753aaabedb3114823a034.tar.gz
builtin: add generic .args method
The arity of builtin functions can be retrieved from their prototype. So, create a generic .args method, doing the evaluation of all arguments present in the prototype. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--builtin.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/builtin.c b/builtin.c
index 26b612dc..0d4cb12c 100644
--- a/builtin.c
+++ b/builtin.c
@@ -83,6 +83,13 @@ error:
return 0;
}
+static int args_prototype(struct expression *expr)
+{
+ struct symbol *fntype = expr->fn->ctype->ctype.base_type;
+ int n = symbol_list_size(fntype->arguments);
+ return eval_args(expr, n);
+}
+
static int args_triadic(struct expression *expr)
{
return eval_args(expr, 3);