From 669ab6c9a99addaf3b9d8e0994fe30d4af88cffa Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Mon, 26 Feb 2024 22:12:17 +0100 Subject: [PATCH] :fire: cleaning again --- src/parse/func_resolve_tmpl.c | 14 +++++--------- src/parse/scan1.c | 1 + src/parse/scanx.c | 16 +++++++--------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/parse/func_resolve_tmpl.c b/src/parse/func_resolve_tmpl.c index 567dda33..ce8bacdc 100644 --- a/src/parse/func_resolve_tmpl.c +++ b/src/parse/func_resolve_tmpl.c @@ -153,21 +153,19 @@ ANN static Func find_tmpl(const Env env, const Value v, Exp_Call *const exp, .func = (_envset_func)check_cdef, .scope = scope, .flag = tflag_check}; - struct ResolverArgs ra = { - .v = v, .e = exp, .tmpl_name = tmpl_name, .types = types}; - CHECK_O(envset_pushv(&es, v)); - (void)env_push(env, v->from->owner_class, v->from->owner); + envset_pushf(&es, v);//); const Tmpl *tmpl = v->from->owner_class && v->from->owner_class->info->cdef ? get_tmpl(v->from->owner_class) : NULL; if(tmpl) (void)template_push_types(env, tmpl); + struct ResolverArgs ra = { + .v = v, .e = exp, .tmpl_name = tmpl_name, .types = types}; const bool is_clos = isa(exp->func->type, env->gwion->type[et_closure]); const Func m_func = !is_clos ? func_match(env, &ra) : fptr_match(env, &ra); if(tmpl) nspc_pop_type(env->gwion->mp, env->curr); - env_pop(env, scope); - envset_pop(&es, v->from->owner_class); + envset_popf(&es, v); env->func = former; return m_func; } @@ -191,14 +189,12 @@ ANN static Func _find_template_match(const Env env, const Value v, TmplArg arg = *mp_vector_at(tl, TmplArg, i); if(unlikely(spec->td)) { if(unlikely(arg.type == tmplarg_td)) - ERR_O(exp_self(exp)->loc, "expected contant, not type"); - // check argument in call exp + ERR_O(exp_self(exp)->loc, "expected constant, not type"); continue; } else { if(unlikely(arg.type == tmplarg_exp)) { ERR_O(exp_self(exp)->loc, "expected type, not constant"); - // check argument in call exp? continue; } DECL_O(const Type, t, = known_type(env, arg.d.td)); diff --git a/src/parse/scan1.c b/src/parse/scan1.c index d30cdfc8..df89730f 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -271,6 +271,7 @@ ANN static inline bool bool ok = true; for(m_uint i = 0; i < l->len; i++) { Stmt* stmt = mp_vector_at(l, Stmt, i); + if(stmt->poison) continue; if(!scan1_stmt_match_case(env, &stmt->d.stmt_match)) POISON_NODE(ok, env, stmt); } diff --git a/src/parse/scanx.c b/src/parse/scanx.c index ccafa9e8..41f5d310 100644 --- a/src/parse/scanx.c +++ b/src/parse/scanx.c @@ -17,24 +17,22 @@ ANN static inline bool _body(const Env env, Ast ast, const _envset_func f) { return ok; } -ANN static inline int actual(const Tmpl *tmpl) { - return tmpl->call && tmpl->call != (TmplArg_List)1 && tmpl->list; -} - -ANN static inline bool tmpl_push(const Env env, const Tmpl *tmpl) { - return actual(tmpl) ? template_push_types(env, tmpl) : true; +ANN static inline void _push(const Env env, const Class_Def c) { + env_push_type(env, c->base.type); + if (c->base.tmpl) + template_push_types(env, c->base.tmpl); } ANN static inline void _pop(const Env env, const Class_Def c, const m_uint s) { - if (c->base.tmpl && actual(c->base.tmpl)) + if (c->base.tmpl) nspc_pop_type(env->gwion->mp, env->curr); env_pop(env, s); } ANN bool scanx_body(const Env env, const Class_Def c, const _envset_func f, void *d) { - const m_int scope = env_push_type(env, c->base.type); - if(c->base.tmpl) CHECK_B(tmpl_push(env, c->base.tmpl)); + const m_int scope = env->scope->depth; + _push(env, c); const bool ret = _body(d, c->body, f); _pop(env, c, scope); return ret; -- 2.43.0