From: Jérémie Astor Date: Sat, 19 Jun 2021 19:32:14 +0000 (+0200) Subject: :art: create base func type X-Git-Tag: nightly~578 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=c790d8c948f4c0eb2274a51ec6ae8a5c53d6b2e0;p=gwion.git :art: create base func type --- diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 932329a8..1e0e648c 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -324,16 +324,28 @@ ANN static Type func_type(const Env env, const Func func) { return t; } +ANN static void func_no_overload(const Env env, const Func f, const Value v) { + const Type t = v->type; + value_addref(v); + nspc_add_value_front(env->curr, f->def->base->xid, v); + + const Type newt = type_copy(env->gwion->mp, t); + t->info->parent = newt; + newt->name = s_name(f->def->base->xid); + newt->info->func = f; + nspc_add_type_front(env->curr, f->def->base->xid, newt); + newt->info->value = v; +} + ANN2(1, 2) static Value func_value(const Env env, const Func f, const Value overload) { const Type t = func_type(env, f); const Value v = t->info->value = new_value(env->gwion->mp, t, t->name); valuefrom(env, v->from, f->def->base->pos); CHECK_OO(scan2_func_assign(env, f->def, f, v)); - if (!overload) { - value_addref(v); - nspc_add_value_front(env->curr, f->def->base->xid, v); - } else if (overload->d.func_ref) { + if (!overload) + func_no_overload(env, f, v); + else if (overload->d.func_ref) { f->next = overload->d.func_ref->next; overload->d.func_ref->next = f; }