diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2022-03-01 02:04:35 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2022-06-27 21:13:31 +0200 |
commit | 4c0c507b1fabbdab557d66eb9d90a2d3c8009880 (patch) | |
tree | 0dd48bda43648b60748235504afbd2c6fa771e16 /filter/config.Y | |
parent | beb5f78ada79ac90f31f2c4923302c74d9ab38bf (diff) |
Filter: Clean up function call instruction
Pass instructions of function call arguments as vararg arguments to
FI_CALL instruction constructor and move necessary magic from parser
code to interpreter / instruction code.
Diffstat (limited to 'filter/config.Y')
-rw-r--r-- | filter/config.Y | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/filter/config.Y b/filter/config.Y index 8916ea97..0ab32a57 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -700,27 +700,22 @@ var_list: /* EMPTY */ { $$ = NULL; } | var_list ',' term { $$ = $3; $$->next = $1; } function_call: - CF_SYM_KNOWN '(' var_list ')' { + CF_SYM_KNOWN '(' var_list ')' + { if ($1->class != SYM_FUNCTION) cf_error("You can't call something which is not a function. Really."); - struct f_inst *fc = f_new_inst(FI_CALL, $1); - uint args = 0; + /* Revert the var_list */ + struct f_inst *args = NULL; while ($3) { - args++; - struct f_inst *tmp = $3->next; - $3->next = fc; + struct f_inst *tmp = $3; + $3 = $3->next; - fc = $3; - $3 = tmp; + tmp->next = args; + args = tmp; } - if (args != $1->function->args) - cf_error("Function call '%s' got %u arguments, need %u arguments.", - $1->name, args, $1->function->args); - - $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_VOID }); - $$->next = fc; + $$ = f_new_inst(FI_CALL, args, $1); } ; |