From 1df67a51275b44c0af99b0b8f2b401348d72ee98 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Wed, 7 Jul 2021 02:29:53 +0200 Subject: [PATCH] :art: op_get --- include/operator.h | 1 + include/plug.h | 4 ++-- plug | 2 +- src/parse/operator.c | 25 +++++++++++++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/include/operator.h b/include/operator.h index 72996780..cda04f19 100644 --- a/include/operator.h +++ b/include/operator.h @@ -78,6 +78,7 @@ struct TemplateScan { ANN void op_cpy(const Env env, const struct Op_Import *opi); ANN m_bool add_op(const Gwion gwion, const struct Op_Import *); +ANN void* op_get(const Env env, struct Op_Import *opi); 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 *); diff --git a/include/plug.h b/include/plug.h index 07b2e53f..adb913bc 100644 --- a/include/plug.h +++ b/include/plug.h @@ -17,9 +17,9 @@ ANN m_bool plugin_ini(struct Gwion_ *gwion, const m_str iname); #define GWDEPEND_NAME gwdepend #define GWMODINI(a) \ ANN2(1) \ - void *GWMODINI_NAME(const struct Gwion_ *gwion NUSED, const Vector args NUSED) + void *GWMODINI_NAME(struct Gwion_ *const gwion NUSED, const Vector args NUSED) #define GWMODEND(a) \ - ANN void GWMODEND_NAME(const struct Gwion_ *gwion NUSED, void *self NUSED) + ANN void GWMODEND_NAME(struct Gwion_ *const gwion NUSED, void *self NUSED) #define GWDRIVER(a) ANN void GWDRIVER_NAME(DriverData *d) #define GWDEPEND ANN m_str const *GWDEPEND_NAME(void) diff --git a/plug b/plug index b2c146f2..ab56ae76 160000 --- a/plug +++ b/plug @@ -1 +1 @@ -Subproject commit b2c146f2a2d9789a45e00ce90d998ebec6f005ed +Subproject commit ab56ae7687294f6fbaf1d4089412219c3ffcd8de diff --git a/src/parse/operator.c b/src/parse/operator.c index f0080020..525b1f40 100644 --- a/src/parse/operator.c +++ b/src/parse/operator.c @@ -260,6 +260,31 @@ ANN static Type op_check_tmpl(const Env env, struct Op_Import *opi) { return NULL; } +ANN void* op_get(const Env env, struct Op_Import *opi) { + for (int i = 0; i < 2; ++i) { + Nspc nspc = env->curr; + do { + Type l = opi->lhs; + if (!nspc->info->op_map.ptr) continue; + const Map map = &nspc->info->op_map; + do { + Type r = opi->rhs; + do { + const m_int idx = map_index(map, (vtype)opi->op); + if(idx != -1) { + M_Operator *const mo = !i + ? operator_find2((Vector)&VVAL(map, idx), l, r) + : operator_find((Vector)&VVAL(map, idx), l, r); + if (mo) + return mo; + } + } while (r && (r = op_parent(env, r))); + } while (l && (l = op_parent(env, l))); + } while ((nspc = nspc->parent)); + } + return NULL; +} + ANN Type op_check(const Env env, struct Op_Import *opi) { for (int i = 0; i < 2; ++i) { Nspc nspc = env->curr; -- 2.43.0