From c790d8c948f4c0eb2274a51ec6ae8a5c53d6b2e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sat, 19 Jun 2021 21:32:14 +0200 Subject: [PATCH] :art: create base func type --- src/parse/scan2.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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; } -- 2.43.0