From: fennecdjay Date: Tue, 28 May 2019 20:04:06 +0000 (+0200) Subject: :art: Improve emit_op X-Git-Tag: nightly~2445^2~4 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=a0bd2e9ee28d698e8fc98d7527999e3452e63cf0;p=gwion.git :art: Improve emit_op --- diff --git a/src/parse/operator.c b/src/parse/operator.c index a29062bb..f765fcf1 100644 --- a/src/parse/operator.c +++ b/src/parse/operator.c @@ -211,22 +211,24 @@ ANN static Nspc get_nspc(const struct Op_Import* opi) { } ANN m_bool op_emit(const Emitter emit, const struct Op_Import* opi) { - const Nspc nspc = get_nspc(opi); - Type l = opi->lhs; + Nspc nspc = get_nspc(opi); do { - Type r = opi->rhs; + Type l = opi->lhs; do { - if(!nspc->info->op_map.ptr) - continue; - const Vector v = (Vector)map_get(&nspc->info->op_map, (vtype)opi->op); - const M_Operator* mo = operator_find(v, l, r); - if(mo) { - if(mo->em) - return mo->em(emit, (void*)opi->data); - return handle_instr(emit, mo); - } - } while(r && (r = op_parent(emit->env, r))); - } while(l && (l = op_parent(emit->env, l))); + Type r = opi->rhs; + do { + if(!nspc->info->op_map.ptr) + continue; + const Vector v = (Vector)map_get(&nspc->info->op_map, (vtype)opi->op); + const M_Operator* mo = operator_find(v, l, r); + if(mo) { + if(mo->em) + return mo->em(emit, (void*)opi->data); + return handle_instr(emit, mo); + } + } while(r && (r = op_parent(emit->env, r))); + } while(l && (l = op_parent(emit->env, l))); + } while((nspc = nspc->parent)); // probably deserves err_msg here return GW_ERROR; }