From: fennecdjay Date: Fri, 5 Jul 2019 15:13:30 +0000 (+0200) Subject: :art: Improve op X-Git-Tag: nightly~2348^2~43 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=11dda7f1fb5af8c8da207c41dfee57bfc1903a86;p=gwion.git :art: Improve op --- diff --git a/include/operator.h b/include/operator.h index 4ce20240..a54b8d10 100644 --- a/include/operator.h +++ b/include/operator.h @@ -25,5 +25,4 @@ ANN Type op_check(const Env, struct Op_Import*); ANN m_bool op_emit(const Emitter, const struct Op_Import*); ANN m_bool operator_set_func(const struct Op_Import*); ANN void free_op_map(Map map, struct Gwion_* gwion); -ANN m_bool env_add_op(const Env, const struct Op_Import*); #endif diff --git a/src/lib/import.c b/src/lib/import.c index 37cc506d..15c8bb3a 100644 --- a/src/lib/import.c +++ b/src/lib/import.c @@ -483,7 +483,7 @@ ANN2(1,2) static int import_op(const Gwi gwi, const DL_Oper* op, const Type ret = get_type(env, op->ret); const struct Op_Import opi = { lhs, rhs, ret, op->ck, op->em, (uintptr_t)f, gwi->loc, op->op }; - return env_add_op(env, &opi); + return add_op(gwi->gwion, &opi); } diff --git a/src/oo/env.c b/src/oo/env.c index 65d823d4..2550d820 100644 --- a/src/oo/env.c +++ b/src/oo/env.c @@ -116,9 +116,3 @@ ANN m_bool type_engine_check_prog(const Env env, const Ast ast) { unload_context(ctx, env); return ret; } - -ANN m_bool env_add_op(const Env env, const struct Op_Import* opi) { - if(!env->curr->info->op_map.ptr) - map_init(&env->curr->info->op_map); - return add_op(env->gwion, opi); -} diff --git a/src/parse/operator.c b/src/parse/operator.c index eb24ba42..c73f5142 100644 --- a/src/parse/operator.c +++ b/src/parse/operator.c @@ -116,6 +116,8 @@ ANN m_bool add_op(const Gwion gwion, const struct Op_Import* opi) { struct OpChecker ock = { gwion->env, &n->info->op_map, opi, 0 }; CHECK_BB(op_exist(&ock, n)) } while((n = n->parent)); + if(!gwion->env->curr->info->op_map.ptr) + map_init(&gwion->env->curr->info->op_map); struct OpChecker ock = { gwion->env, &gwion->env->curr->info->op_map, opi, 0 }; const Vector v = op_vector(gwion->mp, &ock); const M_Operator* mo = new_mo(gwion->mp, opi); diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 25b536af..576ac8a9 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -412,7 +412,7 @@ ANN static m_bool scan2_func_def_op(const Env env, const Func_Def f) { const Type r = GET_FLAG(f, unary) ? f->base->args->var_decl->value->type : f->base->args->next ? f->base->args->next->var_decl->value->type : NULL; struct Op_Import opi = { .op=op, .lhs=l, .rhs=r, .ret=f->base->ret_type, .pos=f->pos }; - CHECK_BB(env_add_op(env, &opi)) + CHECK_BB(add_op(env->gwion, &opi)) return GW_OK; }