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);
}
;
| '-' 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); }
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);
}
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)
/* 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);
if (!sym)
cf_error("Cannot dispatch method '%s'", name);
- return f_dispatch_method(sym, obj, args);
+ return f_dispatch_method(sym, obj, args, 0);
}