From bc7850d86781e5adad4563466a0f1b36ef0db646 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Thu, 7 May 2020 21:16:23 +0200 Subject: [PATCH] :art: Simplify envset --- src/emit/emit.c | 8 ++++---- src/lib/func.c | 2 +- src/parse/check.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 94668df2..579445d6 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -848,7 +848,7 @@ ANN m_bool traverse_dot_tmpl(const Emitter emit, const struct dottmpl_ *dt) { envset_push(&es, dt->owner_class); (void)emit_push(emit, dt->owner_class, dt->owner); const m_bool ret = traverse_emit_func_def(emit, dt->def); - if(dt->owner_class && dt->owner_class->e->owner_class) + if(es.run) envset_pop(&es, dt->owner_class->e->owner_class); emit_pop(emit, scope); return ret; @@ -889,7 +889,7 @@ ANN static m_bool emit_template_code(const Emitter emit, const Func f) { envset_push(&es, v->from->owner_class); (void)emit_push(emit, v->from->owner_class, v->from->owner); const m_bool ret = emit_func_def(emit, f->def); - if(v->from->owner_class && v->from->owner_class->e->owner_class) + if(es.run) envset_pop(&es, v->from->owner_class->e->owner_class); emit_pop(emit, scope); return ret > 0 ? push_func_code(emit, f) : GW_ERROR; @@ -1218,8 +1218,8 @@ ANN static m_bool emit_exp_lambda(const Emitter emit, const Exp_Lambda * lambda) if(lambda->owner) envset_push(&es, lambda->owner); const m_bool ret = emit_lambda(emit, lambda); - if(lambda->owner) - envset_push(&es, lambda->owner); + if(es.run) + envset_pop(&es, lambda->owner); return ret; } diff --git a/src/lib/func.c b/src/lib/func.c index 23df474a..c977bf6a 100644 --- a/src/lib/func.c +++ b/src/lib/func.c @@ -172,7 +172,7 @@ ANN2(1,3,4) m_bool check_lambda(const Env env, const Type owner, if((l->owner = owner)) envset_push(&es, owner); const m_bool ret = _check_lambda(env, l, def); - if(owner && es.run) + if(es.run) envset_pop(&es, owner); if(ret < 0) return GW_ERROR; diff --git a/src/parse/check.c b/src/parse/check.c index 6c8cefae..3d9329f0 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -556,7 +556,7 @@ ANN static Func _find_template_match(const Env env, const Value v, const Exp_Cal } } free_mstr(env->gwion->mp, tmpl_name); - if(v->from->owner_class && v->from->owner_class->e->owner_class && es.run) + if(es.run) envset_pop(&es, v->from->owner_class->e->owner_class); env_pop(env, scope); env->func = former; @@ -663,8 +663,8 @@ ANN static Type check_predefined(const Env env, Exp_Call *exp, const Value v, co envset_push(&es, v->from->owner_class); (void)env_push(env, v->from->owner_class, v->from->owner); const m_bool ret = traverse_func_def(env, func->def); - if(v->from->owner_class && v->from->owner_class->e->owner_class && es.run) - envset_push(&es, v->from->owner_class); + if(es.run) + envset_pop(&es, v->from->owner_class); env_pop(env, scope); CHECK_BO(ret) } -- 2.43.0