diff --git a/filter/config.Y b/filter/config.Y index da96d9e8..dc4d75ed 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -876,12 +876,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); } ; @@ -918,19 +918,10 @@ term: | '-' EMPTY '-' { $$ = f_const_empty(T_CLIST); } | '-' '-' EMPTY '-' '-' { $$ = f_const_empty(T_ECLIST); } | '-' '-' '-' EMPTY '-' '-' '-' { $$ = f_const_empty(T_LCLIST); } - | 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); }