From: Jérémie Astor Date: Sun, 12 Jul 2020 17:19:41 +0000 (+0200) Subject: :art: Fptr reference X-Git-Tag: nightly~1442 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=aa7183f923c1642f3db2a5af7aaa91297431409f;p=gwion.git :art: Fptr reference --- diff --git a/src/clean.c b/src/clean.c index 361bcfd1..23798f02 100644 --- a/src/clean.c +++ b/src/clean.c @@ -315,6 +315,8 @@ ANN static void clean_union_def(Clean *a, Union_Def b) { ANN static void clean_fptr_def(Clean *a, Fptr_Def b) { clean_func_base(a, b->base); + if(b->type) + REM_REF(b->type, a->gwion) } ANN static void clean_type_def(Clean *a, Type_Def b) { diff --git a/src/import/fdef.c b/src/import/fdef.c index 10af875a..34140c18 100644 --- a/src/import/fdef.c +++ b/src/import/fdef.c @@ -121,6 +121,8 @@ ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) { SET_FLAG(fptr->base->func, builtin); const Type t = ret > 0 ? fptr->type : NULL; free_fptr_def(gwi->gwion->mp, fptr); + if(fptr->type) + REM_REF(fptr->type, gwi->gwion) ck_end(gwi); return t; } diff --git a/src/parse/check.c b/src/parse/check.c index ad2deb49..2b7123f9 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -586,6 +586,8 @@ ANN static Func _find_template_match(const Env env, const Value v, const Exp_Cal nspc_add_type_front(v->from->owner, sym, actual_type(env->gwion, m_func->value_ref->type)); } free_fptr_def(env->gwion->mp, fptr); + if(fptr->type) + REM_REF(fptr->type, env->gwion) } } } else { diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 5f2b6c59..969388c7 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -88,6 +88,7 @@ ANN m_bool scan0_fptr_def(const Env env, const Fptr_Def fptr) { SET_FLAG(fptr->value, func); add_type(env, t->e->owner, t); mk_class(env, t); + ADD_REF(t); return GW_OK; }