diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-11-25 23:25:08 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-11-25 23:25:08 +0100 |
commit | 6f6be38ad8de91edc3fede2a651cd811233eb565 (patch) | |
tree | c631701dc947ddbf1bdd99e4322a402f878ea50e | |
parent | b8b8133c9dbf425eb167239112bceec9c298b442 (diff) | |
parent | 7395b97daf529cab1065f107c924bed310a8ad75 (diff) |
Merge commit '7395b97d' into wireguard-next-tmp7-1
-rw-r--r-- | filter/config.Y | 21 | ||||
-rw-r--r-- | filter/f-inst.h | 2 | ||||
-rw-r--r-- | filter/f-util.c | 7 |
3 files changed, 11 insertions, 19 deletions
diff --git a/filter/config.Y b/filter/config.Y index 0840b5bc..0e0df2fc 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -1024,12 +1024,12 @@ static_attr: term_dot_method: term '.' { f_method_call_start($1); } method_name_cont { f_method_call_end(); $$ = $4; }; method_name_cont: CF_SYM_METHOD_BARE { - $$ = f_dispatch_method($1, FM.object, NULL); + $$ = f_dispatch_method($1, FM.object, NULL, 1); } | CF_SYM_METHOD_ARGS { f_method_call_args(); } '(' var_list ')' { - $$ = f_dispatch_method($1, FM.object, $4); + $$ = f_dispatch_method($1, FM.object, $4, 1); } ; @@ -1068,19 +1068,10 @@ term: | '-' '-' EMPTY '-' '-' { $$ = f_const_empty(T_ECLIST); } | '-' '-' '-' EMPTY '-' '-' '-' { $$ = f_const_empty(T_LCLIST); } | '-' '-' '-' '-' EMPTY '-' '-' '-' '-' { $$ = f_const_empty(T_TLVLIST); } - | PREPEND '(' term ',' term ')' { $$ = f_new_inst(FI_PATH_PREPEND, $3, $5); } - | ADD '(' term ',' term ')' { - $$ = f_dispatch_method_x("add", $3->type, $3, $5); - cf_warn("add(x,y) function is deprecated, please use x.add(y)"); - } - | DELETE '(' term ',' term ')' { - $$ = f_dispatch_method_x("delete", $3->type, $3, $5); - cf_warn("delete(x,y) function is deprecated, please use x.delete(y)"); - } - | FILTER '(' term ',' term ')' { - $$ = f_dispatch_method_x("filter", $3->type, $3, $5); - cf_warn("filter(x,y) function is deprecated, please use x.filter(y)"); - } + | PREPEND '(' term ',' term ')' { $$ = f_dispatch_method_x("prepend", $3->type, $3, $5); } + | ADD '(' term ',' term ')' { $$ = f_dispatch_method_x("add", $3->type, $3, $5); } + | DELETE '(' term ',' term ')' { $$ = f_dispatch_method_x("delete", $3->type, $3, $5); } + | FILTER '(' term ',' term ')' { $$ = f_dispatch_method_x("filter", $3->type, $3, $5); } | ROA_CHECK '(' rtable ')' { $$ = f_new_inst(FI_ROA_CHECK_IMPLICIT, $3); } | ROA_CHECK '(' rtable ',' term ',' term ')' { $$ = f_new_inst(FI_ROA_CHECK_EXPLICIT, $5, $7, $3); } diff --git a/filter/f-inst.h b/filter/f-inst.h index e8147e26..2bde6378 100644 --- a/filter/f-inst.h +++ b/filter/f-inst.h @@ -106,7 +106,7 @@ void f_add_lines(const struct f_line_item *what, struct filter_iterator *fit); struct filter *f_new_where(struct f_inst *); -struct f_inst *f_dispatch_method(struct symbol *sym, struct f_inst *obj, struct f_inst *args); +struct f_inst *f_dispatch_method(struct symbol *sym, struct f_inst *obj, struct f_inst *args, int skip); struct f_inst *f_dispatch_method_x(const char *name, enum f_type t, struct f_inst *obj, struct f_inst *args); struct f_inst *f_for_cycle(struct symbol *var, struct f_inst *term, struct f_inst *block); struct f_inst *f_print(struct f_inst *vars, int flush, enum filter_return fret); diff --git a/filter/f-util.c b/filter/f-util.c index 768ee83b..d589927a 100644 --- a/filter/f-util.c +++ b/filter/f-util.c @@ -72,7 +72,7 @@ f_match_signature_err(const struct f_method *dsc, struct f_inst *args, int *pos, } struct f_inst * -f_dispatch_method(struct symbol *sym, struct f_inst *obj, struct f_inst *args) +f_dispatch_method(struct symbol *sym, struct f_inst *obj, struct f_inst *args, int skip) { /* Find match */ for (const struct f_method *dsc = sym->method; dsc; dsc = dsc->next) @@ -123,7 +123,8 @@ f_dispatch_method(struct symbol *sym, struct f_inst *obj, struct f_inst *args) /* There is at least one method */ ASSERT(best_pos >= 0 && best_count > 0); - /* TODO: Here fix best_pos */ + /* Update best_pos for printing */ + best_pos = best_pos - skip + 1; if (!best_got) cf_error("Cannot infer type of argument %d of '%s', please assign it to a variable", best_pos, sym->name); @@ -149,7 +150,7 @@ f_dispatch_method_x(const char *name, enum f_type t, struct f_inst *obj, struct if (!sym) cf_error("Cannot dispatch method '%s'", name); - return f_dispatch_method(sym, obj, args); + return f_dispatch_method(sym, obj, args, 0); } |