From: Jérémie Astor Date: Sun, 16 May 2021 21:26:11 +0000 (+0200) Subject: :art: Clean cdef_parent X-Git-Tag: nightly~643 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=ef8f89b4e0e57340f8ee118875dca4d44930a984;p=gwion.git :art: Clean cdef_parent --- diff --git a/src/emit/emit.c b/src/emit/emit.c index f66d5888..73fdc95c 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -2419,10 +2419,11 @@ ANN /*static */inline m_bool emit_cdef(const Emitter emit, const Type t) { } ANN static m_bool cdef_parent(const Emitter emit, const Class_Def cdef) { - if(cdef->base.tmpl && cdef->base.tmpl->list) + const bool tmpl = !!cdef->base.tmpl; + if(tmpl) CHECK_BB(template_push_types(emit->env, cdef->base.tmpl)); const m_bool ret = emit_parent(emit, cdef); - if(cdef->base.tmpl && cdef->base.tmpl->list) + if(tmpl) nspc_pop_type(emit->gwion->mp, emit->env->curr); return ret; } diff --git a/src/parse/check.c b/src/parse/check.c index 5e6a37f3..39dd52e7 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1532,10 +1532,11 @@ ANN static m_bool check_parent(const Env env, const Class_Def cdef) { } ANN static m_bool cdef_parent(const Env env, const Class_Def cdef) { - if(cdef->base.tmpl && cdef->base.tmpl->list) + const bool tmpl = !!cdef->base.tmpl; + if(tmpl) CHECK_BB(template_push_types(env, cdef->base.tmpl)); const m_bool ret = check_parent(env, cdef); - if(cdef->base.tmpl && cdef->base.tmpl->list) + if(tmpl) nspc_pop_type(env->gwion->mp, env->curr); return ret; } diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 02caef21..43334f1b 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -318,24 +318,25 @@ ANN static inline Type scan0_final(const Env env, Type_Decl *td) { ERR_O(td->pos, _("can't inherit from final parent class '%s'\n."), t->name); } -ANN static Type get_parent(const Env env, const Class_Def cdef) { +ANN static Type cdef_parent(const Env env, const Class_Def cdef) { if(cflag(cdef, cflag_struct)) return env->gwion->type[et_compound]; if(!cdef->base.ext) return env->gwion->type[et_object]; if(tmpl_base(cdef->base.tmpl)) return get_parent_base(env, cdef->base.ext); - if(cdef->base.tmpl) + const bool tmpl = !!cdef->base.tmpl; + if(tmpl) template_push_types(env, cdef->base.tmpl); const Type t = scan0_final(env, cdef->base.ext); - if(cdef->base.tmpl) + if(tmpl) nspc_pop_type(env->gwion->mp, env->curr); return t ?: (Type)GW_ERROR; } ANN static Type scan0_class_def_init(const Env env, const Class_Def cdef) { CHECK_BO(scan0_defined(env, cdef->base.xid, cdef->pos)); - const Type parent = get_parent(env, cdef); + const Type parent = cdef_parent(env, cdef); if(parent == (Type)GW_ERROR) return NULL; const Type t = scan0_type(env, s_name(cdef->base.xid), parent); diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 1bca68e3..2b5cfbe5 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -649,10 +649,11 @@ ANN static m_bool scan1_parent(const Env env, const Class_Def cdef) { } ANN static m_bool cdef_parent(const Env env, const Class_Def cdef) { - if(cdef->base.tmpl && cdef->base.tmpl->list) + const bool tmpl = !!cdef->base.tmpl; + if(tmpl) CHECK_BB(template_push_types(env, cdef->base.tmpl)); const m_bool ret = scan1_parent(env, cdef); - if(cdef->base.tmpl && cdef->base.tmpl->list) + if(tmpl) nspc_pop_type(env->gwion->mp, env->curr); return ret; } diff --git a/src/parse/scan2.c b/src/parse/scan2.c index a123bb1b..1998c93d 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -558,10 +558,11 @@ ANN static m_bool scan2_parent(const Env env, const Class_Def cdef) { } ANN static m_bool cdef_parent(const Env env, const Class_Def cdef) { - if(cdef->base.tmpl && cdef->base.tmpl->list) + const bool tmpl = !!cdef->base.tmpl; + if(tmpl) CHECK_BB(template_push_types(env, cdef->base.tmpl)); const m_bool ret = scan2_parent(env, cdef); - if(cdef->base.tmpl && cdef->base.tmpl->list) + if(tmpl) nspc_pop_type(env->gwion->mp, env->curr); return ret; }