From 044d499ba567560a40d0c43ef1a1dc94595ce58c Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Thu, 3 Oct 2019 00:44:45 +0200 Subject: [PATCH] :art: Remove get_func --- include/env.h | 1 - src/emit/emit.c | 2 +- src/parse/check.c | 2 +- src/parse/func.c | 14 -------------- src/parse/scan2.c | 2 +- 5 files changed, 3 insertions(+), 18 deletions(-) diff --git a/include/env.h b/include/env.h index 3bba04b3..8f214540 100644 --- a/include/env.h +++ b/include/env.h @@ -49,7 +49,6 @@ ANN void env_add_type(const Env, const Type); ANN Type find_type(const Env, ID_List); ANN m_bool already_defined(const Env env, const Symbol s, const loc_t pos); ANN m_bool type_engine_check_prog(const Env, const Ast); -ANN Func get_func(const Env, const Func_Def); ANN m_bool traverse_func_template(const Env, const Func_Def); ANN ID_List str2list(const Env, const m_str path, m_uint* array_depth); ANN2(1,3) void env_err(const Env, const struct YYLTYPE *pos, const m_str fmt, ...); diff --git a/src/emit/emit.c b/src/emit/emit.c index 58b0460f..192b100f 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1804,7 +1804,7 @@ ANN static m_bool tmpl_rettype(const Emitter emit, const Func_Def fdef) { } ANN static m_bool emit_func_def(const Emitter emit, const Func_Def fdef) { - const Func func = get_func(emit->env, fdef); + const Func func = fdef->base->func; const Func former = emit->env->func; if(tmpl_base(fdef->base->tmpl)) return GW_OK; diff --git a/src/parse/check.c b/src/parse/check.c index 431a4acc..007b0c07 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1353,7 +1353,7 @@ ANN m_bool _check_func_def_tmpl(const Env env, const Func_Def fdef) { } ANN m_bool check_func_def(const Env env, const Func_Def fdef) { - const Func func = get_func(env, fdef); + const Func func = fdef->base->func; assert(func == fdef->base->func); if(tmpl_base(fdef->base->tmpl)) return env->class_def ? check_parent_match(env, fdef) : 1; diff --git a/src/parse/func.c b/src/parse/func.c index a46a218c..1e42b9c2 100644 --- a/src/parse/func.c +++ b/src/parse/func.c @@ -31,20 +31,6 @@ ANN Func new_func(MemPool p, const m_str name, const Func_Def def) { #include "type.h" #include "vm.h" #include "gwion.h" -ANN Func get_func(const Env env, const Func_Def def) { - DECL_OO(Func, f, = def->base->func) - m_str end = strrchr(f->name, '@'); // test end cause some template func do not have @x@env->curr->name - if(end && env->class_def && GET_FLAG(env->class_def, template)) { - ++end; - const size_t len = strlen(f->name) - strlen(end); - const size_t elen = strlen(env->class_def->name); - char c[len + elen + 1]; - memcpy(c, f->name, len); - strcpy(c + len, env->class_def->name); - return nspc_lookup_func0(env->class_def->nspc, insert_symbol(env->gwion->st, c)); - } - return f; -} ANN2(1,2) Symbol func_symbol(const Env env, const m_str nspc, const m_str base, const m_str tmpl, const m_uint i) { diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 9056c245..ea00c452 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -505,7 +505,7 @@ ANN2(1,2) m_bool scan2_fdef(const Env env, const Func_Def f, const Value overloa const m_str name = func_name(env, f, overload ?: NULL); if((m_int)name <= GW_OK) return (m_bool)(m_uint)name; - const Func base = get_func(env, f); + const Func base = f->base->func; if(!base) CHECK_OB(func_create(env, f, overload, name)) else -- 2.43.0