From eaf022b48a5c2ed5a8ba793981faf714b88c6097 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Sat, 12 Oct 2019 18:31:17 +0200 Subject: [PATCH] :art: Improve mk_type_list --- src/parse/check.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/parse/check.c b/src/parse/check.c index b9c6bf23..edb47ebe 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -416,19 +416,22 @@ static ANN Type check_exp_array(const Env env, const Exp_Array* array) { return at_depth(env, array->array); } -ANN static Type_List mk_type_list(const Env env, const Type type) { - struct Vector_ v; - vector_init(&v); - vector_add(&v, (vtype)insert_symbol(type->name)); - Nspc nspc = type->e->owner; -// TODO: simplify this - while(nspc && nspc != env->curr && nspc != env->global_nspc) { +ANN static void fill_tl_vector(const Env env, Nspc nspc, const Vector v) { + while(nspc->parent) { const Type t = nspc_lookup_type0(nspc->parent, insert_symbol(nspc->name)); if(!t) break; - vector_add(&v, (vtype)insert_symbol(t->name)); + vector_add(v, (vtype)insert_symbol(t->name)); nspc = nspc->parent; } +} + +ANN static Type_List mk_type_list(const Env env, const Type type) { + struct Vector_ v; + vector_init(&v); + vector_add(&v, (vtype)insert_symbol(type->name)); + if(type->e->owner) + fill_tl_vector(env, type->e->owner, &v); ID_List id = NULL; for(m_uint i = 0 ; i < vector_size(&v); ++i) id = prepend_id_list(env->gwion->mp, (Symbol)vector_at(&v, i), id, new_loc(env->gwion->mp, __LINE__)); @@ -456,7 +459,7 @@ ANN static m_bool func_match_inner(const Env env, const Exp e, const Type t, } return match ? 1 : -1; } -#include "context.h" + ANN2(1,2) static Func find_func_match_actual(const Env env, Func func, const Exp args, const m_bool implicit, const m_bool specific) { do { -- 2.43.0