From: fennecdjay Date: Wed, 11 Nov 2020 19:58:29 +0000 (+0100) Subject: :art: move functions closer to each other X-Git-Tag: nightly~1169 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=23fe64d6d3311f75dd98bd64c119227649c82f4f;p=gwion.git :art: move functions closer to each other --- diff --git a/src/parse/func_resolve_tmpl.c b/src/parse/func_resolve_tmpl.c index 3bf2e1aa..d8cf0c7d 100644 --- a/src/parse/func_resolve_tmpl.c +++ b/src/parse/func_resolve_tmpl.c @@ -43,19 +43,6 @@ ANN static inline m_bool tmpl_valid(const Env env, const Func_Def fdef) { 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 fptr_match(const Env env, struct ResolverArgs* ra) { const Value v = ra->v; const Exp_Call *exp = ra->e; @@ -86,10 +73,17 @@ ANN static Func fptr_match(const Env env, struct ResolverArgs* ra) { return m_func; } -ANN static Func tmpl_exists(const Env env, struct ResolverArgs* ra, const Value exists) { - if(env->func == exists->d.func_ref && find_func_match(env, env->func, ra->e->args)) - return env->func; - return ensure_tmpl(env, exists->d.func_ref->def, ra->e); +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 create_tmpl(const Env env, struct ResolverArgs* ra, const m_uint i) { @@ -107,6 +101,12 @@ ANN static Func create_tmpl(const Env env, struct ResolverArgs* ra, const m_uint return func; } +ANN static Func tmpl_exists(const Env env, struct ResolverArgs* ra, const Value exists) { + if(env->func == exists->d.func_ref && find_func_match(env, env->func, ra->e->args)) + return env->func; + return ensure_tmpl(env, exists->d.func_ref->def, ra->e); +} + ANN static Func func_match(const Env env, struct ResolverArgs* ra) { for(m_uint i = 0; i < ra->v->from->offset + 1; ++i) { const Value exists = template_get_ready(env, ra->v, ra->tmpl_name, i);