From fd937b619b9063bef56bb727e1132685c4fdbd0f Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Mon, 26 Feb 2024 21:42:39 +0100 Subject: [PATCH] :fire: more clean --- src/env/envset.c | 2 ++ src/parse/func_resolve_tmpl.c | 9 ++++++--- src/parse/scan1.c | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/env/envset.c b/src/env/envset.c index 98cabce9..8c1de2e8 100644 --- a/src/env/envset.c +++ b/src/env/envset.c @@ -8,6 +8,8 @@ ANN static void check(struct EnvSet *es, const Type t) { es->_ctx = es->env->context; es->_filename = es->env->name; + if(!type_global(es->env, t)) // why need value? + es->env->name = t->info->value->from->filename; const Vector v = &es->env->scope->class_stack; Type owner = t->info->value->from->owner_class; for (vtype i = vector_size(v) + 1; owner && --i;) { diff --git a/src/parse/func_resolve_tmpl.c b/src/parse/func_resolve_tmpl.c index 1813d564..567dda33 100644 --- a/src/parse/func_resolve_tmpl.c +++ b/src/parse/func_resolve_tmpl.c @@ -147,14 +147,16 @@ ANN static Func find_tmpl(const Env env, const Value v, Exp_Call *const exp, const m_str tmpl_name) { const TmplArg_List types = exp->tmpl->call; const Func former = env->func; + const m_uint scope = env->scope->depth; struct EnvSet es = {.env = env, .data = env, .func = (_envset_func)check_cdef, - .scope = env->scope->depth, + .scope = scope, .flag = tflag_check}; struct ResolverArgs ra = { .v = v, .e = exp, .tmpl_name = tmpl_name, .types = types}; - CHECK_O(envset_pushf(&es, v)); + CHECK_O(envset_pushv(&es, v)); + (void)env_push(env, v->from->owner_class, v->from->owner); const Tmpl *tmpl = v->from->owner_class && v->from->owner_class->info->cdef ? get_tmpl(v->from->owner_class) : NULL; if(tmpl) @@ -164,7 +166,8 @@ ANN static Func find_tmpl(const Env env, const Value v, Exp_Call *const exp, : fptr_match(env, &ra); if(tmpl) nspc_pop_type(env->gwion->mp, env->curr); - envset_popf(&es, v); + env_pop(env, scope); + envset_pop(&es, v->from->owner_class); env->func = former; return m_func; } diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 6474f936..d30cdfc8 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -603,7 +603,8 @@ ANN static bool scan1_stmt_return(const Env env, const Stmt_Exp stmt) { } ANN static bool scan1_stmt_pp(const Env env, const Stmt_PP stmt) { - if (stmt->pp_type == ae_pp_include) env->name = stmt->data; + if (stmt->pp_type == ae_pp_include) + env->name = stmt->data; if (stmt->pp_type == ae_pp_pragma && !strcmp(stmt->data, "packed")) { if(env->class_def && !tflag(env->class_def, tflag_union)) set_tflag(env->class_def, tflag_packed); else ERR_B(stmt_self(stmt)->loc, "`packed` pragma outside of {G+}class{0} or {G+}struct{0} declaration"); -- 2.43.0