From 0ed4627209cd7a0313700e7593227920f703fa4c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Wed, 22 Jul 2020 21:36:15 +0200 Subject: [PATCH] :art: Improve scan1_union_def --- src/parse/scan1.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 16da2425..4f286873 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -351,7 +351,7 @@ ANN m_bool scan1_type_def(const Env env, const Type_Def tdef) { return !is_fptr(env->gwion, tdef->type) ? scan1_cdef(env, tdef->type->e->def) : GW_OK; } -ANN m_bool scan1_union_def_action(const Env env, const Union_Def udef, +ANN static m_bool scan1_union_def_action(const Env env, const Union_Def udef, const Decl_List l) { const Exp_Decl decl = l->self->d.exp_decl; SET_FLAG(decl.td, valid | udef->flag); @@ -362,12 +362,7 @@ ANN m_bool scan1_union_def_action(const Env env, const Union_Def udef, SET_FLAG(decl.td, member); else if(GET_FLAG(udef, static)) SET_FLAG(decl.td, static); - if(udef->tmpl && udef->tmpl->call) - CHECK_BB(template_push_types(env, udef->tmpl)) - const m_bool ret = scan1_exp(env, l->self); - if(udef->tmpl && udef->tmpl->call) - nspc_pop_type(env->gwion->mp, env->curr); - CHECK_BB(ret) + CHECK_BB(scan1_exp(env, l->self)) Var_Decl_List list = decl.list; do ADD_REF(list->self->value) @@ -378,13 +373,21 @@ ANN m_bool scan1_union_def_action(const Env env, const Union_Def udef, return GW_OK; } -ANN m_bool scan1_union_def_inner(const Env env, const Union_Def udef) { - Decl_List l = udef->l; +ANN static inline m_bool scan1_union_def_inner_loop(const Env env, const Union_Def udef, Decl_List l) { do CHECK_BB(scan1_union_def_action(env, udef, l)) while((l = l->next)); return GW_OK; } +ANN static m_bool scan1_union_def_inner(const Env env, const Union_Def udef) { + if(udef->tmpl && udef->tmpl->call) + CHECK_BB(template_push_types(env, udef->tmpl)) + const m_bool ret = scan1_union_def_inner_loop(env, udef, udef->l); + if(udef->tmpl && udef->tmpl->call) + nspc_pop_type(env->gwion->mp, env->curr); + return ret; +} + ANN m_bool scan1_union_def(const Env env, const Union_Def udef) { if(tmpl_base(udef->tmpl)) return GW_OK; -- 2.43.0