From 03feccb303cfcee7f1d4fec53299537bcfcff3a5 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Mon, 12 Feb 2024 14:17:40 +0100 Subject: [PATCH] :fire: boolify add_op --- include/operator.h | 2 +- src/import/import_oper.c | 4 ++-- src/lib/dict.c | 2 +- src/parse/operator.c | 16 ++++++++-------- src/parse/scan0.c | 8 ++++---- src/parse/scan2.c | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/operator.h b/include/operator.h index 1cebd8a4..648d3c74 100644 --- a/include/operator.h +++ b/include/operator.h @@ -77,7 +77,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 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 *); diff --git a/src/import/import_oper.c b/src/import/import_oper.c index b88e6f67..1c6a3bdc 100644 --- a/src/import/import_oper.c +++ b/src/import/import_oper.c @@ -42,9 +42,9 @@ static int import_op(const Gwi gwi, struct OperCK *const op, const f_instr f) { .data = (uintptr_t)f, .loc = gwi->loc, .op = op->sym}; - const m_bool b = add_op(gwi->gwion, &opi); + const bool b = add_op(gwi->gwion, &opi); op->effect.ptr = NULL; - return b; + return b ? GW_OK : GW_ERROR; } ANN2(1) diff --git a/src/lib/dict.c b/src/lib/dict.c index 098769d0..40dc7501 100644 --- a/src/lib/dict.c +++ b/src/lib/dict.c @@ -604,7 +604,7 @@ static OP_CHECK(opck_dict_scan) { .func = &opfunc, .data = (uintptr_t)f, .op = insert_symbol("@func_check")}; - CHECK_BN(add_op(env->gwion, &opi)); + CHECK_ON(add_op(env->gwion, &opi)); } return ret > 0 ? t : NULL; diff --git a/src/parse/operator.c b/src/parse/operator.c index ffeddd1d..1e4b82b7 100644 --- a/src/parse/operator.c +++ b/src/parse/operator.c @@ -124,29 +124,29 @@ op_vector(const struct OpChecker *ock) { return create; } -ANN static m_bool _op_exist(const struct OpChecker *ock, const Nspc n) { +ANN static bool _op_exist(const struct OpChecker *ock, const Nspc n) { const m_int idx = map_index(&n->operators->map, (vtype)ock->opi->op); if (idx == -1 || !operator_find2((Vector)&VVAL(ock->map, idx), ock->opi->lhs, ock->opi->rhs)) - return GW_OK; + return true; env_err(ock->env, ock->opi->loc, _("operator '%s', for type '%s' and '%s' already imported"), s_name(ock->opi->op), type_name(ock->opi->lhs), type_name(ock->opi->rhs)); - return GW_ERROR; + return false; } -ANN static m_bool op_exist(const struct OpChecker *ock, const Nspc n) { - return n->operators->map.ptr ? _op_exist(ock, n) : GW_OK; +ANN static bool op_exist(const struct OpChecker *ock, const Nspc n) { + return n->operators->map.ptr ? _op_exist(ock, n) : true; } -ANN m_bool add_op(const Gwion gwion, const struct Op_Import *opi) { +ANN bool add_op(const Gwion gwion, const struct Op_Import *opi) { Nspc n = gwion->env->curr; do { if (n->operators) { struct OpChecker ock = { .env = gwion->env, .map = &n->operators->map, .opi = opi}; - CHECK_BB(op_exist(&ock, n)); + CHECK_B(op_exist(&ock, n)); } } while ((n = n->parent)); if (!gwion->env->curr->operators) @@ -158,7 +158,7 @@ ANN m_bool add_op(const Gwion gwion, const struct Op_Import *opi) { const Vector v = op_vector(&ock); const M_Operator *mo = new_mo(gwion->mp, opi); vector_add(v, (vtype)mo); - return GW_OK; + return true; } ANN static inline Type op_parent(const Env env, const Type t) { diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 0e08fed7..2262cc71 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -176,7 +176,7 @@ ANN static bool typedef_complex(const Env env, const Type_Def tdef, ANN bool scan0_type_def(const Env env, const Type_Def tdef) { CHECK_B(scan0_defined(env, tdef->tag)); CHECK_B(env_access(env, tdef->ext->flag, tdef->ext->tag.loc)); - DECL_OB(const Type, base, = known_type(env, tdef->ext)); + DECL_B(const Type, base, = known_type(env, tdef->ext)); bool global = false; CHECK_B(scan0_global(env, tdef->ext->flag, tdef->ext->tag.loc, &global)); if (!tdef->ext->types && (!tdef->ext->array || !tdef->ext->array->exp)) @@ -311,7 +311,7 @@ ANN static inline void cdef_flag(const Class_Def cdef, const Type t) { } ANN static Type get_parent_base(const Env env, Type_Decl *td) { - DECL_OO(const Type, t, = known_type(env, td)); + DECL_O(const Type, t, = known_type(env, td)); Type owner = env->class_def; while (owner) { if (t == owner) @@ -361,7 +361,7 @@ ANN static bool find_traits(const Env env, ID_List traits, const loc_t loc) { ANN static Type scan0_class_def_init(const Env env, const Class_Def cdef) { CHECK_O(scan0_defined(env, cdef->base.tag)); - DECL_OO(const Type, parent, = cdef_parent(env, cdef)); + DECL_O(const Type, parent, = cdef_parent(env, cdef)); if(GET_FLAG(cdef, global) && isa(parent, env->gwion->type[et_closure]) < 0 && !type_global(env, parent)) { gwerr_basic(_("parent type is not global"), NULL, NULL, env->name, cdef->base.ext ? cdef->base.ext->tag.loc : cdef->base.tag.loc, 0); declared_here(parent->info->value); @@ -461,7 +461,7 @@ ANN bool scan0_func_def(const Env env, const Func_Def fdef) { } ANN static bool scan0_extend_def(const Env env, const Extend_Def xdef) { - DECL_OB(const Type, t, = known_type(env, xdef->td)); + DECL_B(const Type, t, = known_type(env, xdef->td)); bool ok = true; if(type_global(env, t)) { for(uint32_t i = 0; i < xdef->traits->len; i++) { diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 0298aa1f..881a3a71 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -407,7 +407,7 @@ ANN static m_bool scan2_func_def_op(const Env env, const Func_Def f) { .data = (uintptr_t)f->base->func, .func = &opfunc}; func_operator(f, &opi); - CHECK_BB(add_op(env->gwion, &opi)); + CHECK_B(add_op(env->gwion, &opi)); operator_set_func(&opi); return GW_OK; } -- 2.43.0