From a0bd2e9ee28d698e8fc98d7527999e3452e63cf0 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Tue, 28 May 2019 22:04:06 +0200 Subject: [PATCH] :art: Improve emit_op --- src/parse/operator.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) 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; } -- 2.43.0