From: Jérémie Astor Date: Thu, 7 May 2020 19:16:23 +0000 (+0200) Subject: :art: Simplify envset X-Git-Tag: nightly~1635 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=bc7850d86781e5adad4563466a0f1b36ef0db646;p=gwion.git :art: Simplify envset --- 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) }