return GW_OK;
}
+ANN static inline m_bool tmpl_valid(const Env env, const Func_Def fdef) {
+ return safe_fflag(fdef->base->func, fflag_valid) ||
+ check_traverse_fdef(env, fdef) > 0;
+}
+
+ANN static Func ensure_tmpl(const Env env, const Func_Def fdef, const Exp_Call *exp) {
+ if(!tmpl_valid(env, fdef))
+ return NULL;
+ const Func f = fdef->base->func;
+ const Func next = f->next;
+ f->next = NULL;
+ const Func func = find_func_match(env, f, exp->args);
+ f->next = next;
+ if(func)
+ set_fflag(func, fflag_tmpl | fflag_valid);
+ return func;
+}
-ANN static inline Func fptr_ensure(const Env env, struct ResolverArgs* ra, const Fptr_Def fptr ) {
+ANN static inline Func ensure_fptr(const Env env, struct ResolverArgs* ra, const Fptr_Def fptr) {
CHECK_BO(traverse_fptr_def(env, fptr))
return find_func_match(env, fptr->base->func, ra->e->args);
}
return exists->info->func;
const Func_Def base = v->d.func_ref ? v->d.func_ref->def : ra->e->func->info->type->info->func->def;
const Tmpl tmpl = { .list=base->base->tmpl->list, .call=ra->types };
- CHECK_BO(template_push_types(env, &tmpl))
- Func m_func = NULL;
+ CHECK_BO(template_push_types(env, &tmpl));
Func_Base *const fbase = cpy_func_base(env->gwion->mp, base->base);
fbase->xid = sym;
fbase->tmpl->base = 0;
fbase->tmpl->call = cpy_type_list(env->gwion->mp, ra->types);
const Fptr_Def fptr = new_fptr_def(env->gwion->mp, fbase);
- const Func func = fptr_ensure(env, ra, fptr);
- if(func)
- nspc_add_type_front(v->from->owner, sym, actual_type(env->gwion, func->value_ref->type));
+ const Func m_func = ensure_fptr(env, ra, fptr);
+ if(m_func)
+ nspc_add_type_front(v->from->owner, sym, actual_type(env->gwion, m_func->value_ref->type));
if(fptr->type)
type_remref(fptr->type, env->gwion);
free_fptr_def(env->gwion->mp, fptr);
return m_func;
}
-ANN static inline m_bool tmpl_valid(const Env env, const Func_Def fdef) {
- return safe_fflag(fdef->base->func, fflag_valid) ||
- check_traverse_fdef(env, fdef) > 0;
-}
-
-ANN static Func ensure_tmpl(const Env env, const Func_Def fdef, const Exp_Call *exp) {
- if(!tmpl_valid(env, fdef))
- return NULL;
- const Func f = fdef->base->func;
- const Func next = f->next;
- f->next = NULL;
- const Func func = find_func_match(env, f, exp->args);
- f->next = next;
- if(func)
- set_fflag(func, fflag_tmpl | fflag_valid);
- return func;
-}
-
ANN static Func tmpl_exists(const Env env, struct ResolverArgs* ra, const Value exists) {
if(env->func == exists->d.func_ref)
return find_func_match(env, env->func, ra->e->args) ? env->func : NULL;