From d7a89ce8bd8177a5b03fa7f7d72bb2c965bd3ec7 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Sat, 17 Feb 2024 16:30:24 +0100 Subject: [PATCH] :art: no more m_bool --- ast | 2 +- include/emit.h | 6 +- include/env/envset.h | 2 +- include/env/type.h | 2 +- include/import.h | 17 +---- include/import/edef.h | 9 ++- include/import/internals.h | 4 +- include/import/item.h | 4 +- include/parse.h | 18 +---- include/partial.h | 2 +- plug | 2 +- scripts/embed.bash | 2 +- src/compile.c | 4 +- src/emit/emit.c | 51 ++++++------- src/env/env_utils.c | 10 +-- src/env/envset.c | 2 +- src/env/func.c | 5 +- src/env/type.c | 12 +-- src/import/import_cdef.c | 8 +- src/import/import_checker.c | 10 +-- src/import/import_enum.c | 23 +++--- src/import/import_fdef.c | 14 ++-- src/import/import_item.c | 19 +++-- src/import/import_prim.c | 4 +- src/import/import_type.c | 2 +- src/import/import_udef.c | 4 +- src/lib/array.c | 23 ++---- src/lib/closure.c | 24 +++--- src/lib/deep_equal.c | 2 +- src/lib/dict.c | 12 +-- src/lib/engine.c | 78 +++++++++---------- src/lib/enum.c | 2 +- src/lib/event.c | 2 +- src/lib/instr.c | 2 +- src/lib/lib_class.c | 6 +- src/lib/lib_gack.c | 6 +- src/lib/locale.c | 2 +- src/lib/modules.c | 36 ++++----- src/lib/object.c | 6 +- src/lib/object_op.c | 18 ++--- src/lib/opfunc.c | 4 +- src/lib/prim.c | 46 ++++++------ src/lib/prim_values.c | 2 +- src/lib/ref.c | 4 +- src/lib/shred.c | 56 +++++++------- src/lib/sift.c | 2 +- src/lib/string.c | 4 +- src/lib/ugen.c | 2 +- src/lib/union.c | 10 +-- src/lib/xork.c | 4 +- src/parse/check.c | 91 +++++++++++------------ src/parse/check_traits.c | 2 +- src/parse/func_resolve_tmpl.c | 9 +-- src/parse/operator.c | 2 +- src/parse/partial.c | 2 +- src/parse/scan0.c | 11 +-- src/parse/scan1.c | 45 +++++------ src/parse/scan2.c | 16 +--- src/parse/template.c | 10 +-- src/pass.c | 2 +- src/plug.c | 2 +- src/vm/gack.c | 5 +- tests/driver/non_driver.c | 2 +- tests/module/get_module.c | 6 +- tests/plug/array.c | 8 +- tests/plug/array_in_var_name.c | 2 +- tests/plug/array_in_var_name_fail.c | 2 +- tests/plug/array_incoherent_in_var_name.c | 2 +- tests/plug/array_invalid_in_var_name.c | 2 +- tests/plug/callback.c | 6 +- tests/plug/class_template.c | 26 +++---- tests/plug/class_template_fail.c | 4 +- tests/plug/class_template_invalid.c | 27 +++---- tests/plug/compile_file.c | 2 +- tests/plug/coverage.c | 24 +++--- tests/plug/deps.c | 2 +- tests/plug/empty_union.c | 2 +- tests/plug/end_class.c | 2 +- tests/plug/enum.c | 6 +- tests/plug/enum_fail.c | 4 +- tests/plug/enum_fail2.c | 4 +- tests/plug/enum_fail3.c | 2 +- tests/plug/extend_array.c | 4 +- tests/plug/fptr.c | 12 +-- tests/plug/fptr_tmpl.c | 6 +- tests/plug/fptr_tmpl_fail.c | 4 +- tests/plug/func_fail.c | 2 +- tests/plug/func_fail2.c | 2 +- tests/plug/func_fail3.c | 2 +- tests/plug/func_fail4.c | 4 +- tests/plug/func_subscript_not_empty.c | 2 +- tests/plug/func_tmpl.c | 2 +- tests/plug/func_tmpl_fail.c | 2 +- tests/plug/func_too_many_arg.c | 2 +- tests/plug/global_func.c | 2 +- tests/plug/global_var.c | 10 +-- tests/plug/invalid_arg.c | 4 +- tests/plug/invalid_array.c | 4 +- tests/plug/invalid_func.c | 4 +- tests/plug/invalid_names.c | 4 +- tests/plug/invalid_names0.c | 4 +- tests/plug/invalid_names1.c | 4 +- tests/plug/invalid_names2.c | 4 +- tests/plug/invalid_names3.c | 4 +- tests/plug/invalid_type1.c | 8 +- tests/plug/invalid_type2.c | 8 +- tests/plug/invalid_type3.c | 8 +- tests/plug/mk_type_array.c | 4 +- tests/plug/not_importing.c | 2 +- tests/plug/pass.c | 2 +- tests/plug/specialid_emit.c | 2 +- tests/plug/static_string.c | 6 +- tests/plug/str2decl.c | 6 +- tests/plug/str2list_fail.c | 6 +- tests/plug/struct.c | 22 +++--- tests/plug/template_arg.c | 4 +- tests/plug/trig.c | 4 +- tests/plug/typedef.c | 6 +- tests/plug/typedef_fail.c | 2 +- tests/plug/typedef_tmpl.c | 4 +- tests/plug/ugen_connect.c | 2 +- tests/plug/union.c | 2 +- tests/plug/union_fail_exp.c | 2 +- tests/plug/union_member.c | 4 +- tests/plug/union_name.c | 2 +- tests/plug/union_tmpl.c | 2 +- tests/plug/union_tmpl_fail.c | 2 +- tests/plug/union_tmpl_fail2.c | 2 +- tests/plug/union_tmpl_fail3.c | 2 +- tests/plug/vm_remove.c | 2 +- util | 2 +- 131 files changed, 525 insertions(+), 604 deletions(-) diff --git a/ast b/ast index f8ed98c9..1292b905 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit f8ed98c97d7b938bb3d116e9428e9b52a3e76450 +Subproject commit 1292b905b96915cdce6627bcfce3490f415c37fa diff --git a/include/emit.h b/include/emit.h index 12d60c01..8be17390 100644 --- a/include/emit.h +++ b/include/emit.h @@ -82,12 +82,12 @@ ANN void* emit_localx(const Emitter emit, const Type t); ANN m_uint emit_local_exp(const Emitter emit, Exp*); ANN bool emit_exp_spork(const Emitter, const Exp_Unary *); -ANN void emit_object_addref(const Emitter emit, const m_int size, +ANN void emit_object_addref(const Emitter emit, const m_uint size, const bool emit_var); -ANN void emit_struct_addref(const Emitter emit, const Type t, const m_int size, +ANN void emit_struct_addref(const Emitter emit, const Type t, const m_uint size, const bool emit_var); ANN static inline void emit_compound_addref(const Emitter emit, const Type t, - const m_int size, + const m_uint size, const bool emit_var) { return !tflag(t, tflag_struct) ? emit_object_addref(emit, size, emit_var) : emit_struct_addref(emit, t, size, emit_var); diff --git a/include/env/envset.h b/include/env/envset.h index 72fc4eba..7aec557b 100644 --- a/include/env/envset.h +++ b/include/env/envset.h @@ -19,7 +19,7 @@ ANN static inline bool envset_pushv(struct EnvSet *es, const Value v) { es->_ctx = es->env->context; es->_filename = es->env->name; CHECK_B(envset_push(es, v->from->owner_class, v->from->owner)); - return GW_OK; + return true; } ANN2(1) void envset_pop(struct EnvSet *, const Type); #endif diff --git a/include/env/type.h b/include/env/type.h index a6e0b06b..62582a2e 100644 --- a/include/env/type.h +++ b/include/env/type.h @@ -66,7 +66,7 @@ FLAG_FUNC(Type, t) ANN2(1, 2) ANEW Type new_type(MemPool, const m_str name, const Type); ANEW ANN Type type_copy(MemPool, const Type type); ANN Value find_value(const Type, const Symbol); -ANN m_bool isa(const Type, const Type) __attribute__((pure)); +ANN bool isa(const Type, const Type) __attribute__((pure)); ANN bool not_reserved(const Env, const Tag); // move me ANN Type array_type(const Env, const Type, const m_uint, const loc_t); ANN Type find_common_anc(const Type, const Type) __attribute__((pure)); diff --git a/include/import.h b/include/import.h index b7714018..31c68545 100644 --- a/include/import.h +++ b/include/import.h @@ -27,7 +27,7 @@ typedef struct Gwi_ *Gwi; #define OP_CHECK(a) ANN Type a(const Env env NUSED, void *data NUSED) #define OP_EMIT(a) ANN bool a(const Emitter emit NUSED, void *data NUSED) #ifdef GWION_BUILTIN -#define GWI_BB(a) \ +#define GWI_B(a) \ { \ gwi_set_loc(gwi, __FILE__, __LINE__); \ (void)(a); \ @@ -37,28 +37,19 @@ typedef struct Gwi_ *Gwi; gwi_set_loc(gwi, __FILE__, __LINE__); \ (void)(a); \ } -#define GWI_OB(a) \ +#define GWI_B(a) \ { \ gwi_set_loc(gwi, __FILE__, __LINE__); \ (void)(a); \ } #define GWION_IMPORT(a) ANN bool gwimport_##a(const Gwi gwi) #else -#define GWI_BB(a) \ - { \ - gwi_set_loc(gwi, (m_str)__FILE__, __LINE__); \ - CHECK_B(a); \ - } #define GWI_B(a) \ { \ gwi_set_loc(gwi, (m_str)__FILE__, __LINE__); \ CHECK_B(a); \ } -#define GWI_OB(a) \ - { \ - gwi_set_loc(gwi, (m_str)__FILE__, __LINE__); \ - CHECK_B(a); \ - } + #define GWION_IMPORT(a) ANN bool gwimport_##a(const Gwi gwi) #endif #define ALLOC_PTR(p, a, b, c) \ @@ -96,7 +87,7 @@ OP_EMIT(opem_new); ANN static inline M_Object new_object_str(const Gwion gwion, const m_str str) { loc_t loc = {}; - DECL_OO(const Type, t, = str2type(gwion, str, loc)); + DECL_O(const Type, t, = str2type(gwion, str, loc)); return new_object(gwion->mp, t); } diff --git a/include/import/edef.h b/include/import/edef.h index b458033b..2d31e53c 100644 --- a/include/import/edef.h +++ b/include/import/edef.h @@ -2,8 +2,9 @@ #define __IMPORT_ENUM __attribute__ ((visibility ("default"))) -ANN m_int gwi_enum_ini(const Gwi gwi, const m_str type); -ANN m_int gwi_enum_add(const Gwi gwi, const m_str name, const m_uint value); -ANN Type gwi_enum_end(const Gwi gwi); -ANN void ck_clean_edef(MemPool, ImportCK *); +ANN bool gwi_enum_ini(const Gwi gwi, const m_str type); +ANN bool gwi_enum_add(const Gwi gwi, const m_str name, const m_uint value); +ANN bool gwi_enum_end(const Gwi gwi); + +ANN void ck_clean_edef(MemPool, ImportCK *); #endif diff --git a/include/import/internals.h b/include/import/internals.h index 45bf1624..83aa0c6e 100644 --- a/include/import/internals.h +++ b/include/import/internals.h @@ -6,7 +6,7 @@ #define GWI_ERR_B(a, ...) \ { \ GWI_ERR((a), ##__VA_ARGS__); \ - return GW_ERROR; \ + return false; \ } #define GWI_ERR_O(a, ...) \ { \ @@ -29,7 +29,7 @@ #define ENV_ERR_B(pos, a, ...) \ { \ env_err(env, pos, (a), ##__VA_ARGS__); \ - return GW_ERROR; \ + return false; \ } #define ENV_ERR_O(pos, a, ...) \ { \ diff --git a/include/import/item.h b/include/import/item.h index 5b197dcc..2c11ffb7 100644 --- a/include/import/item.h +++ b/include/import/item.h @@ -1,8 +1,8 @@ #ifndef __IMPORT_ITEM #define __IMPORT_ITEM -ANN m_int gwi_item_ini(const Gwi gwi, const m_str type, const m_str name); -ANN2(1) m_int gwi_item_end(const Gwi gwi, const ae_flag flag, union value_data); +ANN bool gwi_item_ini(const Gwi gwi, const m_str type, const m_str name); +ANN2(1) bool gwi_item_end(const Gwi gwi, const ae_flag flag, union value_data); #define gwi_item_end(a, b, member, c) \ gwi_item_end(a, (ae_flag)(b), (union value_data) {.member = c}) ANN void ck_clean_item(MemPool, ImportCK *); diff --git a/include/parse.h b/include/parse.h index 96d3a096..3fc734a5 100644 --- a/include/parse.h +++ b/include/parse.h @@ -16,34 +16,24 @@ (node)-> poison = true; \ } while(false) -#undef ERR_b -#define ERR_b(a, b, ...) \ - do { \ - env_err(env, (a), (b), ##__VA_ARGS__); \ - return false; \ - } while(false) - - -#define ERR_OK_NODE(ok, a, b, c, ...) \ +#define ERR_OK_NODE(ok, a, b, c, ...) \ do { \ env_err(env, (b), (c), ##__VA_ARGS__); \ POISON_NODE(ok, env, a); \ } while(false) -#define ERR_OK(ok, a, b, ...) \ +#define ERR_OK(ok, a, b, ...) \ do { \ env_err(env, (a), (b), ##__VA_ARGS__); \ POISON(ok, env); \ } while(false) -#undef ERR_B #define ERR_B(a, b, ...) \ do { \ env_err(env, (a), (b), ##__VA_ARGS__); \ - return GW_ERROR; \ + return false; \ } while(false) -#undef ERR_O #define ERR_O(a, b, ...) \ do { \ env_err(env, (a), (b), ##__VA_ARGS__); \ @@ -157,7 +147,7 @@ static inline bool exp_is_zero(Exp* exp) { ANN static inline bool not_upvalue(const Env env, const Value v) { if (unlikely(is_class(env->gwion, v->type))) return true; return GET_FLAG(v, global) || vflag(v, vflag_fglobal) || - (v->from->owner_class && isa(v->from->owner_class, env->class_def) > 0) || + (v->from->owner_class && isa(v->from->owner_class, env->class_def)) || nspc_lookup_value1(env->curr, insert_symbol(v->name)); } diff --git a/include/partial.h b/include/partial.h index 0590a2a5..0966a81c 100644 --- a/include/partial.h +++ b/include/partial.h @@ -7,7 +7,7 @@ ANN void print_signature(const Func f); ANN static inline bool func_match_inner(const Env env, Exp* e, const Type t, const bool implicit, const bool specific) { - if (specific ? e->type == t : isa(e->type, t) > 0) // match + if (specific ? e->type == t : isa(e->type, t)) // match return true; return !implicit ? false : check_implicit(env, e, t); } diff --git a/plug b/plug index 82b13e3b..402bf847 160000 --- a/plug +++ b/plug @@ -1 +1 @@ -Subproject commit 82b13e3b9c04c292342461b481289f68d428e04e +Subproject commit 402bf847df73f3bec3f3802984726e5d3b766557 diff --git a/scripts/embed.bash b/scripts/embed.bash index 63b17fdb..53b7461c 100644 --- a/scripts/embed.bash +++ b/scripts/embed.bash @@ -36,7 +36,7 @@ has_func() { } plugin() { has_func "gwimport" "$1" "$2" && { - header "extern m_bool gwimport_${2}(const Gwi);" + header "extern bool gwimport_${2}(const Gwi);" echo " plug->plugin = gwimport_${2};" } } diff --git a/src/compile.c b/src/compile.c index bd3b6e9f..9fe42f75 100644 --- a/src/compile.c +++ b/src/compile.c @@ -115,7 +115,7 @@ ANN static inline bool passes(struct Gwion_ *gwion, struct Compiler *c) { for(uint32_t i = 0; i < mp_vector_len(c->values); i++) { const Value v = *mp_vector_at(c->values, Value, i); set_vflag(v, vflag_builtin); - if(isa(v->type, gwion->type[et_class]) > 0) { + if(isa(v->type, gwion->type[et_class])) { const Type t = (Type)v->d.ptr; type_addref(t); mk_class(gwion->env, t, (loc_t) {}); @@ -157,7 +157,7 @@ ANN static m_uint _compile(struct Gwion_ *gwion, struct Compiler *c) { gwion->emit->info->code = NULL; return c->shred->tick->xid; } - return GW_OK; + return true; } ANN static m_uint compile(struct Gwion_ *gwion, struct Compiler *c) { diff --git a/src/emit/emit.c b/src/emit/emit.c index 39a46862..6c9ad64c 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -180,7 +180,8 @@ ANN static bool emit_defers2(const Emitter emit) { ANN static m_int _frame_pop(const Emitter emit) { Frame *frame = emit->code->frame; - DECL_OB(const Local *, l, = (Local *)vector_pop(&frame->stack)); + const Local *l = (Local *)vector_pop(&frame->stack); + if(!l)return -1; frame->curr_offset -= l->type->size; if (l->skip) return _frame_pop(emit); if (!l->is_compound) return _frame_pop(emit); @@ -430,7 +431,7 @@ bool emit_instantiate_object(const Emitter emit, const Type type, is_ref)); return true; } else if (!is_ref) { - if(!tflag(type, tflag_typedef) || isa(type, emit->gwion->type[et_closure]) > 0) { + if(!tflag(type, tflag_typedef) || isa(type, emit->gwion->type[et_closure])) { const Instr instr = emit_add_instr(emit, ObjectInstantiate); instr->m_val2 = (m_uint)type; } // maybe we should instantiate the first actual type @@ -453,7 +454,7 @@ ANN static bool emit_symbol_builtin(const Emitter emit, const Symbol *data) { emit_dotstatic(emit, (m_uint)&v->d.ptr, size, emit_addr); // prevent invalid access to global variables if(!emit_addr && - isa(v->type, emit->gwion->type[et_object]) > 0) + isa(v->type, emit->gwion->type[et_object])) emit_fast_except(emit, v->from, prim_pos(data)); } else { const m_uint size = v->type->size; @@ -502,7 +503,7 @@ ANN static bool _emit_symbol(const Emitter emit, const Symbol *data) { else emit_regpushbase(emit, v->from->offset, size, exp_getvar(prim_exp(data))); if (GET_FLAG(v, late) && !exp_getvar(prim_exp(data)) && - isa(v->type, emit->gwion->type[et_object]) > 0) + isa(v->type, emit->gwion->type[et_object])) emit_fast_except(emit, v->from, prim_pos(data)); return true; } @@ -527,24 +528,24 @@ ANN static inline m_uint exp_size(Exp* e) { return type->size; } -ANN void emit_object_addref(const Emitter emit, const m_int size, +ANN void emit_object_addref(const Emitter emit, const m_uint size, const bool emit_var) { const f_instr exec = !emit_var ? RegAddRef : RegAddRefAddr; const Instr instr = emit_add_instr(emit, exec); instr->m_val = size; } -ANN void emit_struct_addref(const Emitter emit, const Type t, const m_int size, +ANN void emit_struct_addref(const Emitter emit, const Type t, const m_uint size, const bool emit_var) { if(!tflag(t, tflag_release)) return; const Instr instr = emit_add_instr(emit, !emit_var ? StructRegAddRef : StructRegAddRefAddr); instr->m_val2 = (m_uint)t; - instr->m_val = !emit_var ? size : (m_int)-SZ_INT; + instr->m_val = !emit_var ? (m_int)size : (m_int)-SZ_INT; } ANN2(1) -static void emit_exp_addref1(const Emitter emit, Exp* exp, m_int size) { +static void emit_exp_addref1(const Emitter emit, Exp* exp, m_uint size) { const Type t = exp->cast_to ?: exp->type; if (tflag(t, tflag_compound)) emit_compound_addref(emit, exp->type, size, exp_getvar(exp)); @@ -552,7 +553,7 @@ static void emit_exp_addref1(const Emitter emit, Exp* exp, m_int size) { /*ANN2(1) static void emit_exp_addref(const Emitter emit, Exp* exp, - m_int size) { + m_uint size) { do { emit_exp_addref1(emit, exp, size); size += exp_size(exp); @@ -783,7 +784,7 @@ ANN static void emit_gack_type(const Emitter emit, Exp* e) { if (e->exp_type == ae_exp_cast || (e->exp_type == ae_exp_primary && e->d.prim.prim_type == ae_prim_str)) return; - const bool isobj = isa(e->type, emit->gwion->type[et_object]) > 0; + const bool isobj = isa(e->type, emit->gwion->type[et_object]); if (isobj && (tflag(e->type, tflag_ref) || !GET_FLAG(e->type, final))) emit_add_instr(emit, GackType); } @@ -944,11 +945,11 @@ ANN static bool emit_exp_decl_static(const Emitter emit, const Exp_Decl *decl, const bool is_ref, const bool emit_addr) { const Value v = var_decl->value; - if (isa(v->type, emit->gwion->type[et_object]) > 0 && !is_ref) + if (isa(v->type, emit->gwion->type[et_object]) && !is_ref) CHECK_B(decl_static(emit, decl, var_decl, 0)); CHECK_B(emit_dot_static_data(emit, v, !struct_ctor(v) ? emit_addr : 1)); if (tflag(v->type, tflag_struct)) CHECK_B(struct_finish(emit, decl)); - if (isa(v->type, emit->gwion->type[et_object]) > 0 && !is_ref) { + if (isa(v->type, emit->gwion->type[et_object]) && !is_ref) { if(safe_tflag(emit->env->class_def, tflag_struct) && GET_FLAG(emit->env->class_def, global)) emit_object_addref(emit, 0, emit_addr); } @@ -1010,7 +1011,7 @@ ANN static bool emit_exp_decl_non_static(const Emitter emit, const uint emit_var) { const Value v = var_decl->value; const Type type = v->type; - const bool is_obj = isa(type, emit->gwion->type[et_object]) > 0; + const bool is_obj = isa(type, emit->gwion->type[et_object]); const bool emit_addr = (!is_obj || is_ref) ? emit_var : true; if (is_obj && !is_ref && !exp_self(decl)->ref) { if(!decl->args) CHECK_B(emit_instantiate_decl(emit, type, decl->var.td, is_ref)); @@ -1053,7 +1054,7 @@ ANN static bool emit_exp_decl_global(const Emitter emit, const Exp_Decl *decl, const uint is_ref, const bool emit_var) { const Value v = var_decl->value; const Type type = v->type; - const bool is_obj = isa(type, emit->gwion->type[et_object]) > 0; + const bool is_obj = isa(type, emit->gwion->type[et_object]); const bool emit_addr = (!is_obj || is_ref) ? emit_var : true; if (is_obj && !is_ref) { if(!decl->args) CHECK_B(emit_instantiate_decl(emit, type, decl->var.td, is_ref)); @@ -1126,7 +1127,7 @@ ANN static bool emit_decl(const Emitter emit, Exp_Decl *const decl) { } return false; } - if(isa(v->type, emit->gwion->type[et_object]) > 0 && GET_FLAG(v, late) && exp_getuse(exp_self(decl))) + if(isa(v->type, emit->gwion->type[et_object]) && GET_FLAG(v, late) && exp_getuse(exp_self(decl))) emit_add_instr(emit, GWOP_EXCEPT); return true; } @@ -1141,7 +1142,7 @@ ANN /*static */ bool emit_exp_decl(const Emitter emit, Exp_Decl *const decl) { !global ? emit->env->scope->depth : emit_push_global(emit); const bool ret = emit_decl(emit, decl); if (global) emit_pop(emit, scope); - if(emit->status.in_return && GET_FLAG(decl->var.vd.value, late) && isa(t, emit->gwion->type[et_object]) > 0) + if(emit->status.in_return && GET_FLAG(decl->var.vd.value, late) && isa(t, emit->gwion->type[et_object])) emit_add_instr(emit, GWOP_EXCEPT); return ret; } @@ -1628,7 +1629,7 @@ ANN bool emit_exp_call1(const Emitter emit, const Func f, else //if(is_new(f->def))//if(tflag(f->value_ref->type, tflag_ftmpl)) { const Type t = f->value_ref->from->owner_class; -if(t && (!emit->env->curr || isa(t, emit->env->class_def) < 0)) +if(t && (!emit->env->curr || !isa(t, emit->env->class_def))) //!is_new(f->def) || f->value_ref->from->owner_class->array_depth) //if(f->value_ref->from->owner_class->array_depth) CHECK_B(emit_ensure_func(emit, f)); @@ -1856,7 +1857,7 @@ ANN static bool emit_exp_if(const Emitter emit, const Exp_If *exp_if) { Instr instr; struct M_Vector_ v = {}; const m_uint reg = emit_local(emit, emit->gwion->type[et_bool]); - DECL_OB(const Instr, op, = _flow(emit, exp_if->cond, &instr, true)); + DECL_B(const Instr, op, = _flow(emit, exp_if->cond, &instr, true)); if (exp_getvar(exp_self(exp_if))) { exp_setvar(e, 1); exp_setvar(exp_if->else_exp, 1); @@ -1960,8 +1961,8 @@ ANN2(1) /*static */ bool emit_exp(const Emitter emit, /* const */ Exp* e) { } CHECK_B(emit_exp_func[exp->exp_type](emit, &exp->d)); if (exp->cast_to) CHECK_B(emit_implicit_cast(emit, exp, exp->cast_to)); - if (isa(e->type, emit->gwion->type[et_object]) > 0 && - (e->cast_to ? isa(e->cast_to, emit->gwion->type[et_object]) > 0 : 1) && + if (isa(e->type, emit->gwion->type[et_object]) && + (e->cast_to ? isa(e->cast_to, emit->gwion->type[et_object]) : 1) && e->exp_type == ae_exp_decl && GET_FLAG(e->d.exp_decl.var.td, late) && exp_getuse(e) && !exp_getvar(e) && GET_FLAG(e->d.exp_decl.var.vd.value, late)) @@ -1979,7 +1980,7 @@ ANN static bool emit_if(const Emitter emit, const Stmt_If stmt) { if (stmt->cond->exp_type == ae_exp_primary && stmt->cond->d.prim.prim_type == ae_prim_num) return emit_if_const(emit, stmt); - DECL_OB(const Instr, op, = emit_flow(emit, stmt->cond)); + DECL_B(const Instr, op, = emit_flow(emit, stmt->cond)); CHECK_B(scoped_stmt(emit, stmt->if_body)); const Instr op2 = emit_add_instr(emit, Goto); op->m_val = emit_code_size(emit); @@ -2035,10 +2036,10 @@ ANN static bool emit_stmt_return(const Emitter emit, const Stmt_Exp stmt) { } ANN static inline bool emit_jump_index(const Emitter emit, const Vector v, - const m_int n) { + const m_uint n) { vector_add(v, 0); // make room const m_uint sz = vector_size(v); - m_int idx = 1; + m_uint idx = 1; for (m_uint i = sz; --i > 1;) { if (!vector_at(v, i) && ++idx == n) { m_uint *data = v->ptr + OFFSET + i; @@ -2146,7 +2147,7 @@ ANN static bool _emit_stmt_for(const Emitter emit, const Stmt_For stmt, m_uint *action_index) { CHECK_B(emit_stmt(emit, stmt->c1)); const m_uint index = emit_code_size(emit); - DECL_OB(const Instr, op, = emit_flow(emit, stmt->c2->d.stmt_exp.val)); + DECL_B(const Instr, op, = emit_flow(emit, stmt->c2->d.stmt_exp.val)); CHECK_B(scoped_stmt(emit, stmt->body)); *action_index = emit_code_size(emit); if (stmt->c3) { @@ -2179,7 +2180,7 @@ ANN static Instr each_op(const Emitter emit, const Looper *loop) { ANN static inline bool roll(const Emitter emit, Looper*const loop) { const Instr instr = loop->roll(emit, loop); -// DECL_OB(const Instr, instr, = each_op(emit, loop)); // maybe check in check.c +// DECL_B(const Instr, instr, = each_op(emit, loop)); // maybe check in check.c CHECK_B(scoped_stmt(emit, loop->stmt)); instr->m_val = emit_code_size(emit) + 1; // pass after goto return true; diff --git a/src/env/env_utils.c b/src/env/env_utils.c index 478063fb..48e1dcf1 100644 --- a/src/env/env_utils.c +++ b/src/env/env_utils.c @@ -9,20 +9,20 @@ ANN bool env_access(const Env env, const ae_flag flag, const loc_t loc) { if (env->scope->depth) { if (GET(flag, ae_flag_global)) - ERR_b(loc, _("`{G}global{0}` can only be used at %s scope."), + ERR_B(loc, _("`{G}global{0}` can only be used at %s scope."), GET(flag, ae_flag_global) && !env->class_def ? "file" : "class"); } if ((GET(flag, ae_flag_static) || GET(flag, ae_flag_private) || GET(flag, ae_flag_protect)) && (!env->class_def || env->scope->depth)) - ERR_b(loc, _("`{G}static/private/protect{0}` can only be used at class scope.")); + ERR_B(loc, _("`{G}static/private/protect{0}` can only be used at class scope.")); return true; } ANN bool env_storage(const Env env, ae_flag flag, const loc_t loc) { CHECK_B(env_access(env, flag, loc)); if(env->class_def && GET(flag, ae_flag_global)) - ERR_b(loc, _("`{G}global{0}` at class scope only valid for function pointers")); + ERR_B(loc, _("`{G}global{0}` at class scope only valid for function pointers")); return true; } #undef GET @@ -55,7 +55,7 @@ ANN Type find_initial(const Env env, const Symbol xid) { #undef RETURN_TYPE ANN Type find_type(const Env env, Type_Decl *td) { - DECL_OO(Type, type, = find_initial(env, td->tag.sym)); + DECL_O(Type, type, = find_initial(env, td->tag.sym)); while ((td = td->next) && type && type->nspc) { const Nspc nspc = type->nspc; if(!(type = find_in_parent(type, td->tag.sym))) @@ -111,7 +111,7 @@ ANN bool not_reserved(const Env env, const Tag tag) { const Map map = &env->gwion->data->id; for (m_uint i = 0; i < map_size(map); i++) { if (tag.sym == (Symbol)VKEY(map, i)) - ERR_b(tag.loc, _("%s is reserved."), s_name(tag.sym)); + ERR_B(tag.loc, _("%s is reserved."), s_name(tag.sym)); } return true; } diff --git a/src/env/envset.c b/src/env/envset.c index f1c82e9a..994230b7 100644 --- a/src/env/envset.c +++ b/src/env/envset.c @@ -78,7 +78,7 @@ ANN bool envset_run(struct EnvSet *es, const Type t) { es->env->context = t->info->value->from->ctx; es->env->name = t->info->value->from->filename; const bool ret = - t->info->cdef && !(t->tflag & es->flag) ? es->func(es->data, t) : GW_OK; + t->info->cdef && !(t->tflag & es->flag) ? es->func(es->data, t) : true; envset_pop(es, owner_class); return ret; } diff --git a/src/env/func.c b/src/env/func.c index 1df80f62..fba8b6b8 100644 --- a/src/env/func.c +++ b/src/env/func.c @@ -30,8 +30,9 @@ Symbol func_symbol(const Env env, const m_str nspc, const m_str base, const size_t idx_len = num_digit(i); const size_t len = base_len + tmpl_len + nspc_len + idx_len + 2; char name[len + 1]; - CHECK_BO(sprintf(name, "%s%s%s%s@%" UINT_F "@%s", base, !tmpl ? "" : ":[", - !tmpl ? "" : tmpl, !tmpl ? "" : "]", i, nspc)); + if(sprintf(name, "%s%s%s%s@%" UINT_F "@%s", base, !tmpl ? "" : ":[", + !tmpl ? "" : tmpl, !tmpl ? "" : "]", i, nspc) < 1) + return NULL; return insert_symbol(env->gwion->st, name); } diff --git a/src/env/type.c b/src/env/type.c index 889c180a..a30ce4a7 100644 --- a/src/env/type.c +++ b/src/env/type.c @@ -48,14 +48,14 @@ ANN Type type_copy(MemPool p, const Type type) { return a; } -ANN m_bool isa(const restrict Type var, const restrict Type parent) { - return (var == parent) ? GW_OK +ANN bool isa(const restrict Type var, const restrict Type parent) { + return (var == parent) ? true : var->info->parent ? isa(var->info->parent, parent) - : GW_ERROR; + : false; } ANN Type find_common_anc(const restrict Type lhs, const restrict Type rhs) { - return isa(lhs, rhs) > 0 ? rhs : isa(rhs, lhs) > 0 ? lhs : NULL; + return isa(lhs, rhs) ? rhs : isa(rhs, lhs) ? lhs : NULL; } #define describe_find(name, t) \ @@ -136,11 +136,11 @@ ANN m_uint get_depth(const Type type) { } ANN bool is_func(const struct Gwion_ *gwion, const Type t) { - return isa(actual_type(gwion, t), gwion->type[et_function]) > 0; + return isa(actual_type(gwion, t), gwion->type[et_function]); } ANN inline bool is_class(const struct Gwion_ *gwion, const Type t) { -// return isa(t, gwion->type[et_class]) > 0; +// return isa(t, gwion->type[et_class]); return t->info->parent == gwion->type[et_class]; } diff --git a/src/import/import_cdef.c b/src/import/import_cdef.c index 5176bdbc..18c5726f 100644 --- a/src/import/import_cdef.c +++ b/src/import/import_cdef.c @@ -26,7 +26,7 @@ ANN static void mk_dtor(MemPool p, const Type t, const m_uint d) { ANN2(1, 2) static void import_class_ini(const Env env, const Type t) { t->nspc = new_nspc(env->gwion->mp, t->name); t->nspc->parent = env->curr; - if (isa(t, env->gwion->type[et_object]) > 0) inherit(t); + if (isa(t, env->gwion->type[et_object])) inherit(t); env_push_type(env, t); } @@ -80,16 +80,16 @@ ANN2(1, 2) Type gwi_class_ini(const Gwi gwi, const m_str name, const m_str parent) { struct ImportCK ck = {.name = name}; CHECK_O(check_typename_def(gwi, &ck)); - DECL_OO(Type_Decl *, td, = gwi_str2td(gwi, parent ?: "Object")); + DECL_O(Type_Decl *, td, = gwi_str2td(gwi, parent ?: "Object")); Tmpl *tmpl = ck.sl ? new_tmpl(gwi->gwion->mp, ck.sl) : NULL; if (tmpl) CHECK_O(template_push_types(gwi->gwion->env, tmpl)); - DECL_OO(const Type, base, = known_type(gwi->gwion->env, td)); + DECL_O(const Type, base, = known_type(gwi->gwion->env, td)); const TmplArg_List tl = td->types; if (tflag(base, tflag_ntmpl)) td->types = NULL; const Type p = !td->types ? known_type(gwi->gwion->env, td) : NULL; td->types = tl; if (tmpl) nspc_pop_type(gwi->gwion->mp, gwi->gwion->env->curr); - CHECK_OO(p); + CHECK_O(p); const Type t = new_type(gwi->gwion->mp, s_name(ck.sym), p); t->info->cdef = new_class_def(gwi->gwion->mp, 0, MK_TAG(ck.sym, gwi->loc), td, NULL); t->info->cdef->base.tmpl = tmpl; diff --git a/src/import/import_checker.c b/src/import/import_checker.c index 429f4639..6a478873 100644 --- a/src/import/import_checker.c +++ b/src/import/import_checker.c @@ -92,7 +92,7 @@ ANN static bool _tmpl_list(const Gwion gwion, mp_vector_add(gwion->mp, sl, Specialized, spec); return true; } - DECL_OO(const Symbol, sym, = __str2sym(gwion, tdc)); + DECL_O(const Symbol, sym, = __str2sym(gwion, tdc)); // TODO: handle traits? Specialized spec = { .tag = MK_TAG(sym, tdc->loc) }; mp_vector_add(gwion->mp, sl, Specialized, spec); @@ -239,7 +239,7 @@ ANN static Type_Decl *_str2td(const Gwion gwion, struct td_checker *tdc) { td->ref = ref; return td; } - DECL_OO(const Symbol, sym, = __str2sym(gwion, tdc)); + DECL_O(const Symbol, sym, = __str2sym(gwion, tdc)); TmplArg_List tl = td_tmpl(gwion, tdc); struct AC ac = {.str = tdc->str, .loc = tdc->loc}; CHECK_O(ac_run(gwion, &ac)); @@ -266,7 +266,7 @@ ANN static Type_Decl *_str2td(const Gwion gwion, struct td_checker *tdc) { ANN Type_Decl *str2td(const Gwion gwion, const m_str str, const loc_t loc) { struct td_checker tdc = {.str = str, .loc = loc}; - DECL_OO(Type_Decl *, td, = _str2td(gwion, &tdc)); + DECL_O(Type_Decl *, td, = _str2td(gwion, &tdc)); if(*tdc.str) { free_type_decl(gwion->mp, td); GWION_ERR_O(loc, "excedental character '%c' in '%s'", *tdc.str, str); @@ -275,7 +275,7 @@ ANN Type_Decl *str2td(const Gwion gwion, const m_str str, const loc_t loc) { } ANN Type str2type(const Gwion gwion, const m_str str, const loc_t loc) { - DECL_OO(Type_Decl *, td, = str2td(gwion, str, loc)); + DECL_O(Type_Decl *, td, = str2td(gwion, str, loc)); const Type t = known_type(gwion->env, td); free_type_decl(gwion->mp, td); return t; @@ -337,7 +337,7 @@ ANN static bool td_info_run(const Env env, struct td_info *info) { } } } - return GW_OK; + return true; } ANEW ANN m_str type2str(const Gwion gwion, const Type t, diff --git a/src/import/import_enum.c b/src/import/import_enum.c index 61673033..10ae4a53 100644 --- a/src/import/import_enum.c +++ b/src/import/import_enum.c @@ -17,29 +17,29 @@ //! start an enum definition //! \arg the importer //! \arg string defining a primitive type -ANN m_int gwi_enum_ini(const Gwi gwi, const m_str type) { - CHECK_b(ck_ini(gwi, ck_edef)); - CHECK_OB((gwi->ck->xid = gwi_str2sym(gwi, type))); +ANN bool gwi_enum_ini(const Gwi gwi, const m_str type) { + CHECK_B(ck_ini(gwi, ck_edef)); + CHECK_B((gwi->ck->xid = gwi_str2sym(gwi, type))); gwi->ck->tmpl = new_mp_vector(gwi->gwion->mp, EnumValue, 0); - return GW_OK; + return true; } //! add an enum entry //! \arg the importer //! \arg name of the entry -ANN m_int gwi_enum_add(const Gwi gwi, const m_str name, const m_uint i) { +ANN bool gwi_enum_add(const Gwi gwi, const m_str name, const m_uint i) { CHECK_B(ck_ok(gwi, ck_edef)); - DECL_OB(const Symbol, xid, = gwi_str2sym(gwi, name)); + DECL_B(const Symbol, xid, = gwi_str2sym(gwi, name)); const EnumValue ev = { .tag = MK_TAG(xid, gwi->loc), .gwint = { .num = i }, .set = true}; mp_vector_add(gwi->gwion->mp, &gwi->ck->tmpl, EnumValue, ev); - return GW_OK; + return true; } //! finish enum import //! \arg the importer -ANN Type gwi_enum_end(const Gwi gwi) { - CHECK_O(ck_ok(gwi, ck_edef)); - if (!gwi->ck->tmpl->len) GWI_ERR_O("Enum is empty"); +ANN bool gwi_enum_end(const Gwi gwi) { + CHECK_B(ck_ok(gwi, ck_edef)); + if (!gwi->ck->tmpl->len) GWI_ERR_B("Enum is empty"); const Gwion gwion = gwi->gwion; const Enum_Def edef = new_enum_def(gwion->mp, gwi->ck->tmpl, gwi->ck->xid, gwi->loc); @@ -47,8 +47,7 @@ ANN Type gwi_enum_end(const Gwi gwi) { gwi->ck->tmpl = NULL; const bool ret = traverse_enum_def(gwion->env, edef); if (gwi->gwion->data->cdoc) gwfmt_enum_def(gwi->gwfmt, edef); - const Type t = ret ? edef->type : NULL; free_enum_def(gwion->mp, edef); ck_end(gwi); - return t; + return ret; } diff --git a/src/import/import_fdef.c b/src/import/import_fdef.c index 61c71fdf..dd90d5c2 100644 --- a/src/import/import_fdef.c +++ b/src/import/import_fdef.c @@ -18,9 +18,9 @@ ANN2(1, 2, 3) static bool dl_func_init(const Gwi gwi, const restrict m_str t, const restrict m_str n) { - CHECK_b(ck_ini(gwi, ck_fdef)); + CHECK_B(ck_ini(gwi, ck_fdef)); gwi->ck->name = n; - CHECK_b(check_typename_def(gwi, gwi->ck)); + CHECK_B(check_typename_def(gwi, gwi->ck)); CHECK_B((gwi->ck->td = gwi_str2td(gwi, t))); gwi->ck->mpv = new_mp_vector(gwi->gwion->mp, Arg, 0); return true; @@ -84,7 +84,7 @@ ANN bool gwi_func_valid(const Gwi gwi, ImportCK *ck) { } ANN bool gwi_func_end(const Gwi gwi, const f_xfun addr, const ae_flag flag) { - CHECK_b(ck_ok(gwi, ck_fdef)); + CHECK_B(ck_ok(gwi, ck_fdef)); gwi->ck->addr = addr; gwi->ck->flag = flag; const bool ret = gwi_func_valid(gwi, gwi->ck); @@ -94,13 +94,13 @@ ANN bool gwi_func_end(const Gwi gwi, const f_xfun addr, const ae_flag flag) { ANN bool gwi_func_arg(const Gwi gwi, const restrict m_str t, const restrict m_str n) { - CHECK_b(ck_ok(gwi, ck_fdef)); + CHECK_B(ck_ok(gwi, ck_fdef)); DECL_B(Type_Decl *, td, = gwi_str2td(gwi, t)); struct Var_Decl_ var; if(gwi_str2var(gwi, &var, n)) { Arg arg = { .var = MK_VAR(td, var) }; mp_vector_add(gwi->gwion->mp, &gwi->ck->mpv, Arg, arg); - return GW_OK; + return true; } free_type_decl(gwi->gwion->mp, td); return false; @@ -124,7 +124,7 @@ ANN static bool section_fptr(const Gwi gwi, const Fptr_Def fdef) { ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) { CHECK_O(ck_ok(gwi, ck_fdef)); - DECL_OO(const Fptr_Def, fptr, = import_fptr(gwi)); + DECL_O(const Fptr_Def, fptr, = import_fptr(gwi)); fptr->base->flag |= flag; if (gwi->gwion->data->cdoc) { gwfmt_indent(gwi->gwfmt); @@ -134,7 +134,7 @@ ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) { tflag_tmpl) /*&& !fptr->base->tmpl*/) { section_fptr(gwi, fptr); ck_end(gwi); - return (Type)GW_OK; + return (Type)true; } const bool ret = traverse_fptr_def(gwi->gwion->env, fptr); // if (fptr->base->func) // is it needed ? diff --git a/src/import/import_item.c b/src/import/import_item.c index 49098f1e..0d315f25 100644 --- a/src/import/import_item.c +++ b/src/import/import_item.c @@ -10,27 +10,27 @@ #include "import.h" #include "gwi.h" -ANN m_int gwi_item_ini(const Gwi gwi, const restrict m_str type, +ANN bool gwi_item_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) { - CHECK_b(ck_ini(gwi, ck_item)); - if ((gwi->ck->exp = make_exp(gwi, type, name))) return GW_OK; + CHECK_B(ck_ini(gwi, ck_item)); + if ((gwi->ck->exp = make_exp(gwi, type, name))) return true; GWI_ERR_B(_(" ... during var import '%s.%s'."), gwi->gwion->env->name, name) } -ANN static m_int gwi_item_tmpl(const Gwi gwi) { +ANN static bool gwi_item_tmpl(const Gwi gwi) { Stmt_List slist = new_mp_vector(gwi->gwion->mp, Stmt, 1); mp_vector_set(slist, Stmt, 0, MK_STMT_EXP(gwi->loc, gwi->ck->exp)); Section section = MK_SECTION(stmt, stmt_list, slist); gwi_body(gwi, §ion); mp_free2(gwi->gwion->mp, sizeof(ImportCK), gwi->ck); gwi->ck = NULL; - return GW_OK; + return true; } #undef gwi_item_end ANN2(1) -m_int gwi_item_end(const Gwi gwi, const ae_flag flag, union value_data addr) { - CHECK_b(ck_ok(gwi, ck_item)); +bool gwi_item_end(const Gwi gwi, const ae_flag flag, union value_data addr) { + CHECK_B(ck_ok(gwi, ck_item)); const Env env = gwi->gwion->env; gwi->ck->exp->d.exp_decl.var.td->flag = flag; if (gwi->gwion->data->cdoc) { @@ -41,15 +41,14 @@ m_int gwi_item_end(const Gwi gwi, const ae_flag flag, union value_data addr) { } if (env->class_def && tflag(env->class_def, tflag_tmpl)) return gwi_item_tmpl(gwi); - CHECK_b(traverse_exp(env, gwi->ck->exp)); + CHECK_B(traverse_exp(env, gwi->ck->exp)); const Value value = gwi->ck->exp->d.exp_decl.var.vd.value; value->d = addr; set_vflag(value, vflag_builtin); if (!env->class_def) SET_FLAG(value, global); - const m_uint offset = value->from->offset; free_exp(gwi->gwion->mp, gwi->ck->exp); ck_end(gwi); - return offset; + return true; } ANN void ck_clean_item(MemPool mp, ImportCK *ck) { diff --git a/src/import/import_prim.c b/src/import/import_prim.c index 37b3f15c..6fcf2491 100644 --- a/src/import/import_prim.c +++ b/src/import/import_prim.c @@ -146,7 +146,7 @@ static INSTR(bitset) { static OP_EMIT(opem_bitset) { Exp_Binary *bin = data; const Instr instr = emit_add_instr(emit, bitset); - const Type t = isa(bin->rhs->type, emit->gwion->type[et_int]) > 0 + const Type t = isa(bin->rhs->type, emit->gwion->type[et_int]) ? bin->lhs->type : bin->rhs->type; instr->m_val = t->actual_size; @@ -159,7 +159,7 @@ static INSTR(bitcast) { static OP_EMIT(opem_bitcast) { Exp_Cast *cast = data; - const Type t = isa(cast->exp->type, emit->gwion->type[et_int]) > 0 + const Type t = isa(cast->exp->type, emit->gwion->type[et_int]) ? known_type(emit->env, cast->td) : cast->exp->type; const Instr instr = emit_add_instr(emit, bitcast); diff --git a/src/import/import_type.c b/src/import/import_type.c index b304a710..73080355 100644 --- a/src/import/import_type.c +++ b/src/import/import_type.c @@ -38,7 +38,7 @@ Type gwi_mk_type(const Gwi gwi, const m_str name, const m_uint size, gwfmt_sc(gwi->gwfmt); gwfmt_nl(gwi->gwfmt); } - CHECK_OO(gwi_str2sym(gwi, name)); + CHECK_O(gwi_str2sym(gwi, name)); const Type parent = get_parent(gwi, parent_name); const Type t = new_type(gwi->gwion->mp, name, parent); t->size = size; diff --git a/src/import/import_udef.c b/src/import/import_udef.c index 6c35de28..068f9690 100644 --- a/src/import/import_udef.c +++ b/src/import/import_udef.c @@ -16,7 +16,7 @@ // move me ANN Exp* make_exp(const Gwi gwi, const m_str type, const m_str name) { - DECL_OO(Type_Decl *, td, = gwi_str2td(gwi, type)); + DECL_O(Type_Decl *, td, = gwi_str2td(gwi, type)); struct Var_Decl_ vd; if(!gwi_str2var(gwi, &vd, name)) { free_type_decl(gwi->gwion->mp, td); @@ -28,7 +28,7 @@ ANN Exp* make_exp(const Gwi gwi, const m_str type, const m_str name) { ANN bool gwi_union_ini(const Gwi gwi, const m_str name) { CHECK_B(ck_ini(gwi, ck_udef)); gwi->ck->name = name; - CHECK_b(check_typename_def(gwi, gwi->ck)); + CHECK_B(check_typename_def(gwi, gwi->ck)); gwi->ck->mpv = new_mp_vector(gwi->gwion->mp, Variable, 0); return true; } diff --git a/src/lib/array.c b/src/lib/array.c index 91185662..88cc7eb5 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -133,7 +133,7 @@ static MFUN(vm_vector_random) { #define ARRAY_OPCK(a, b, loc) \ const Type l = array_base(a->type); \ const Type r = array_base(b->type); \ - if (isa(r, l) < 0) ERR_N(loc, _("array types do not match.")); + if (!isa(r, l)) ERR_N(loc, _("array types do not match.")); static OP_CHECK(opck_array_at) { const Exp_Binary *bin = (Exp_Binary *)data; @@ -260,7 +260,7 @@ static OP_CHECK(opck_array_cast) { const Type r = array_base(t); if (get_depth(cast->exp->type) != get_depth(t)) return NULL; - if(isa(l, r) > 0) return l; + if(isa(l, r)) return l; Type parent = t; while(parent) { if (tflag(parent, tflag_cdef) && parent->info->cdef->base.ext && parent->info->cdef->base.ext->array) { @@ -305,7 +305,7 @@ static OP_EMIT(opem_array_cast) { const Type l = array_base(cast->exp->type); const Type t = known_type(env, cast->td); const Type r = array_base(t); - if(isa(l, r) < 0) { + if(!isa(l, r)) { const m_uint depth = get_depth(t); const m_uint start = emit_code_size(emit); cast_start(emit, depth); @@ -403,7 +403,7 @@ ANN static inline bool array_do(const Emitter emit, const Array_Sub array, access = emit_add_instr(emit, ArrayAccess); access->m_val = (i+1) * SZ_INT - offset; access->udata.one = offset; - if(i < get_depth(t) || isa(array_base(t), emit->gwion->type[et_object]) > 0) { + if(i < get_depth(t) || isa(array_base(t), emit->gwion->type[et_object])) { const Instr ex = emit_add_instr(emit, GWOP_EXCEPT); ex->m_val = -SZ_INT; } @@ -873,7 +873,7 @@ static OP_CHECK(opck_array_implicit) { const struct Implicit *imp = (struct Implicit *)data; if (imp->t->array_depth != imp->e->type->array_depth) return env->gwion->type[et_error]; - if (isa(array_base(imp->e->type), array_base(imp->t)) < 0) + if (!isa(array_base(imp->e->type), array_base(imp->t))) return env->gwion->type[et_error]; return imp->t; } @@ -888,8 +888,8 @@ static OP_EMIT(opem_array_each_init) { ANN static inline Type foreach_type(const Env env, Exp* exp) { const Type et = exp->type; - DECL_OO(Type, base, = typedef_base(et)); - DECL_OO(const Type, t, = array_base_simple(base)); + DECL_O(Type, base, = typedef_base(et)); + DECL_O(const Type, t, = array_base_simple(base)); if(!tflag(base, tflag_ref)) { const m_uint depth = base->array_depth - 1; return depth ? array_type(env, t, depth, exp->loc) : t; @@ -1077,7 +1077,7 @@ GWION_IMPORT(array) { GWI_B(gwi_oper_end(gwi, "@array_init", NoOp)) gwi_register_freearg(gwi, ArrayAlloc, freearg_array); - return GW_OK; + return true; } INSTR(ArrayStruct) { @@ -1195,13 +1195,6 @@ ANN static bool last_is_zero(Exp* e) { return exp_is_zero(e); } -#undef ERR_B -#define ERR_B(a, b, ...) \ - { \ - env_err(env, (a), (b), ##__VA_ARGS__); \ - return false; \ - } - ANN2(1,2) bool check_array_instance(const Env env, Type_Decl *td, Exp* args) { if (!last_is_zero(td->array->exp)) { if (!args) diff --git a/src/lib/closure.c b/src/lib/closure.c index 89050278..de590c95 100644 --- a/src/lib/closure.c +++ b/src/lib/closure.c @@ -186,7 +186,7 @@ ANN static bool fptr_tmpl_push(const Env env, struct FptrInfo *info) { static bool td_match(const Env env, Type_Decl *id[2]) { DECL_B(const Type, t0, = known_type(env, id[0])); DECL_B(const Type, t1, = known_type(env, id[1])); - if (isa(t0, t1) > 0) return true; + if (isa(t0, t1)) return true; return t1 == env->gwion->type[et_auto]; } @@ -234,7 +234,7 @@ ANN static bool fptr_check(const Env env, struct FptrInfo *info) { // if(!info->lhs->def->base->tmpl != !info->rhs->def->base->tmpl) // return false; if(!info->lhs) - ERR_b(info->exp->loc, + ERR_B(info->exp->loc, _("can't resolve operator")); return true; } @@ -260,7 +260,7 @@ ANN static Type fptr_type(const Env env, struct FptrInfo *info) { info->lhs = v->type->info->func; } } else { - DECL_OO(const Type, t, + DECL_O(const Type, t, = nspc_lookup_type1(nspc, info->lhs->def->base->tag.sym)); info->lhs = actual_type(env->gwion, t)->info->func; } @@ -282,14 +282,14 @@ ANN static bool _check_lambda(const Env env, Exp_Lambda *l, Arg_List bases = fdef->base->args; Arg_List args = l->def->base->args; if (mp_vector_len(bases) != mp_vector_len(args)) - ERR_b(exp_self(l)->loc, _("argument number does not match for lambda")); + ERR_B(exp_self(l)->loc, _("argument number does not match for lambda")); if(l->def->captures) { // here move to arguments for(uint32_t i = 0; i < l->def->captures->len; i++) { Capture *cap = mp_vector_at(l->def->captures, Capture, i); const Value v = nspc_lookup_value1(env->curr, cap->var.tag.sym); - if(!v) ERR_b(cap->var.tag.loc, _("unknown value in capture")); + if(!v) ERR_B(cap->var.tag.loc, _("unknown value in capture")); DECL_B(const Type, t, = upvalue_type(env, cap)); cap->temp = new_value(env, t, cap->var.tag); cap->var.value = v; @@ -371,7 +371,7 @@ ANN static bool fptr_do(const Env env, struct FptrInfo *info) { if(info->exp->type->info->func) { CHECK_B(fptr_check(env, info)); if (!(info->exp->type = fptr_type(env, info))) - ERR_b(info->exp->loc, _("no match found")); + ERR_B(info->exp->loc, _("no match found")); return true; } Exp_Lambda *l = &info->exp->d.exp_lambda; @@ -565,7 +565,7 @@ static OP_CHECK(opck_op_impl) { .loc = impl->e->loc}; vector_add(&env->scope->effects, 0); DECL_ON(const Type, t, = op_check(env, &opi)); - CHECK_BN(isa(t, func->def->base->ret_type)); // error message? + CHECK_ON(isa(t, func->def->base->ret_type)); // error message? MP_Vector *const eff = (MP_Vector*)vector_back(&env->scope->effects); // if (eff && !check_effect_overload(eff, func)) // ERR_N(impl->loc, _("`{+Y}%s{0}` has effects not present in `{+G}%s{0}`\n"), @@ -725,18 +725,18 @@ static GACK(gack_function) { INTERP_PRINTF("%s", t->name); } GWION_IMPORT(func) { gwidoc(gwi, "the base of all functions."); const Type t_function = gwi_mk_type(gwi, "function", SZ_INT, NULL); - GWI_BB(gwi_gack(gwi, t_function, gack_function)) - GWI_BB(gwi_set_global_type(gwi, t_function, et_function)) + GWI_B(gwi_gack(gwi, t_function, gack_function)) + GWI_B(gwi_set_global_type(gwi, t_function, et_function)) gwidoc(gwi, "the base of decayed operators."); const Type t_op = gwi_mk_type(gwi, "operator", SZ_INT, "function"); - GWI_BB(gwi_set_global_type(gwi, t_op, et_op)) + GWI_B(gwi_set_global_type(gwi, t_op, et_op)) gwidoc(gwi, "the base of function pointers."); const Type t_closure = gwi_class_ini(gwi, "funptr", "Object"); t_closure->nspc->offset = SZ_INT*3; gwi_class_xtor(gwi, fptr_ctor, fptr_dtor); - GWI_BB(gwi_set_global_type(gwi, t_closure, et_closure)) + GWI_B(gwi_set_global_type(gwi, t_closure, et_closure)) GWI_B(gwi_func_ini(gwi, "void", "default")); GWI_B(gwi_func_end(gwi, fptr_default, ae_flag_none)); gwi_class_end(gwi); @@ -778,5 +778,5 @@ GWION_IMPORT(func) { gwi_register_freearg(gwi, GTmpl, freearg_gtmpl); gwi_register_freearg(gwi, DotTmpl, freearg_dottmpl); - return GW_OK; + return true; } diff --git a/src/lib/deep_equal.c b/src/lib/deep_equal.c index a794c25d..b60a682d 100644 --- a/src/lib/deep_equal.c +++ b/src/lib/deep_equal.c @@ -259,5 +259,5 @@ GWION_IMPORT(deep_equal) { GWI_B(gwi_oper_emi(gwi, opem_deep_equal)) GWI_B(gwi_oper_end(gwi, "<>", NULL)) - return GW_OK; + return true; } diff --git a/src/lib/dict.c b/src/lib/dict.c index 3fc21a46..6f9ebd3b 100644 --- a/src/lib/dict.c +++ b/src/lib/dict.c @@ -290,13 +290,13 @@ static OP_CHECK(opck_dict_remove_toop) { Exp* func = call->func; Exp* args = call->args; e->exp_type = ae_exp_binary; - CHECK_OO(check_exp(env, e->d.exp_binary.rhs = cpy_exp(env->gwion->mp, func->d.exp_dot.base))); - CHECK_OO(check_exp(env, e->d.exp_binary.lhs = args)); + CHECK_O(check_exp(env, e->d.exp_binary.rhs = cpy_exp(env->gwion->mp, func->d.exp_dot.base))); + CHECK_O(check_exp(env, e->d.exp_binary.lhs = args)); e->d.exp_binary.op = insert_symbol("~~"); free_exp(env->gwion->mp, func); const Type t = e->d.exp_binary.rhs->type; HMapInfo *const hinfo = (HMapInfo*)t->nspc->class_data; - if(isa(args->type, hinfo->key) < 0 || args->next) + if(!isa(args->type, hinfo->key) || args->next) ERR_N(e->loc, "dict.remove must be called with one Key argument"); return e->type = env->gwion->type[et_void]; } @@ -450,7 +450,7 @@ static OP_EMIT(opem_dict_access) { const bool ret = _opem_dict_access(emit, data); array->exp->next = enext; CHECK_B(ret); - return !enext ? GW_OK : emit_next_access(emit, info); + return !enext ? true : emit_next_access(emit, info); } static OP_CHECK(opck_dict_access) { @@ -611,7 +611,7 @@ static OP_CHECK(opck_dict_scan) { } GWION_IMPORT(dict) { - DECL_OB(const Type, t_dict, = gwi_class_ini(gwi, "Dict:[Key,Val]", "Object")); + DECL_B(const Type, t_dict, = gwi_class_ini(gwi, "Dict:[Key,Val]", "Object")); gwi_class_xtor(gwi, dict_ctor, dict_dtor); t_dict->nspc->offset += sizeof(struct HMap); gwi->gwion->type[et_dict] = t_dict; @@ -666,5 +666,5 @@ GWION_IMPORT(dict) { GWI_B(gwi_func_arg(gwi, "string", "key")); GWI_B(gwi_func_end(gwi, mfun_string_h, ae_flag_none)); - return GW_OK; + return true; } diff --git a/src/lib/engine.c b/src/lib/engine.c index 1343145f..eb400aba 100644 --- a/src/lib/engine.c +++ b/src/lib/engine.c @@ -49,50 +49,50 @@ ANN static bool import_core_libs(const Gwi gwi) { gwidoc(gwi, "one type to rule them all."); const Type t_class = gwi_mk_type(gwi, "Class", SZ_INT, NULL); set_tflag(t_class, tflag_infer); - GWI_BB(gwi_set_global_type(gwi, t_class, et_class)) - GWI_BB(gwi_gack(gwi, t_class, gack_class)) + GWI_B(gwi_set_global_type(gwi, t_class, et_class)) + GWI_B(gwi_gack(gwi, t_class, gack_class)) gwidoc(gwi, "this type is infered."); const Type t_auto = gwi_mk_type(gwi, "auto", SZ_INT, NULL); set_tflag(t_auto, tflag_infer); - GWI_BB(gwi_set_global_type(gwi, t_auto, et_auto)) + GWI_B(gwi_set_global_type(gwi, t_auto, et_auto)) gwidoc(gwi, "a void type."); const Type t_void = gwi_mk_type(gwi, "void", 0, NULL); - GWI_BB(gwi_gack(gwi, t_void, gack_void)) - GWI_BB(gwi_set_global_type(gwi, t_void, et_void)) + GWI_B(gwi_gack(gwi, t_void, gack_void)) + GWI_B(gwi_set_global_type(gwi, t_void, et_void)) gwidoc(gwi, "integer type."); const Type t_int = gwi_mk_type(gwi, "int", SZ_INT, NULL); - GWI_BB(gwi_gack(gwi, t_int, gack_int)) - GWI_BB(gwi_set_global_type(gwi, t_int, et_int)) + GWI_B(gwi_gack(gwi, t_int, gack_int)) + GWI_B(gwi_set_global_type(gwi, t_int, et_int)) gwidoc(gwi, "character type."); const Type t_char = gwi_mk_type(gwi, "char", SZ_INT, "int"); - GWI_BB(gwi_gack(gwi, t_char, gack_char)) - GWI_BB(gwi_set_global_type(gwi, t_char, et_char)) + GWI_B(gwi_gack(gwi, t_char, gack_char)) + GWI_B(gwi_set_global_type(gwi, t_char, et_char)) gwidoc(gwi, "float type."); const Type t_float = gwi_mk_type(gwi, "float", SZ_FLOAT, NULL); - GWI_BB(gwi_gack(gwi, t_float, gack_float)) - GWI_BB(gwi_set_global_type(gwi, t_float, et_float)) + GWI_B(gwi_gack(gwi, t_float, gack_float)) + GWI_B(gwi_set_global_type(gwi, t_float, et_float)) set_tflag(t_float, tflag_float); gwidoc(gwi, "represent duration."); const Type t_dur = gwi_mk_type(gwi, "dur", SZ_FLOAT, NULL); - GWI_BB(gwi_gack(gwi, t_dur, gack_float)) - GWI_BB(gwi_add_type(gwi, t_dur)) + GWI_B(gwi_gack(gwi, t_dur, gack_float)) + GWI_B(gwi_add_type(gwi, t_dur)) set_tflag(t_dur, tflag_float); gwidoc(gwi, "represent time."); const Type t_time = gwi_mk_type(gwi, "time", SZ_FLOAT, NULL); - GWI_BB(gwi_gack(gwi, t_time, gack_float)) - GWI_BB(gwi_add_type(gwi, t_time)) + GWI_B(gwi_gack(gwi, t_time, gack_float)) + GWI_B(gwi_add_type(gwi, t_time)) set_tflag(t_time, tflag_float); gwidoc(gwi, "internal time for `{/}now{0}{-}`."); const Type t_now = gwi_mk_type(gwi, "@now", SZ_FLOAT, "time"); - GWI_BB(gwi_add_type(gwi, t_now)) + GWI_B(gwi_add_type(gwi, t_now)) struct SpecialId_ spid = {.type = t_now, .exec = RegPushNow, .is_const = 1}; gwi_specialid(gwi, "now", &spid); @@ -105,32 +105,32 @@ ANN static bool import_core_libs(const Gwi gwi) { gwidoc(gwi, "internal base of all objects and structures."); - GWI_BB(gwimport_enum(gwi)); + GWI_B(gwimport_enum(gwi)); const Type t_compound = gwi_mk_type(gwi, "@Compound", SZ_INT, NULL); - GWI_BB(gwi_gack(gwi, t_compound, gack_compound)) - GWI_BB(gwi_set_global_type(gwi, t_compound, et_compound)) + GWI_B(gwi_gack(gwi, t_compound, gack_compound)) + GWI_B(gwi_set_global_type(gwi, t_compound, et_compound)) - GWI_BB(gwimport_object(gwi)) + GWI_B(gwimport_object(gwi)) - GWI_BB(gwimport_prim(gwi)) - GWI_BB(gwimport_func(gwi)) - GWI_BB(gwimport_object_op(gwi)) - GWI_BB(gwimport_values(gwi)) - GWI_BB(gwimport_union(gwi)) + GWI_B(gwimport_prim(gwi)) + GWI_B(gwimport_func(gwi)) + GWI_B(gwimport_object_op(gwi)) + GWI_B(gwimport_values(gwi)) + GWI_B(gwimport_union(gwi)) - GWI_BB(gwimport_array(gwi)) - GWI_BB(gwimport_event(gwi)) - GWI_BB(gwimport_ugen(gwi)) - GWI_BB(gwimport_xork(gwi)) + GWI_B(gwimport_array(gwi)) + GWI_B(gwimport_event(gwi)) + GWI_B(gwimport_ugen(gwi)) + GWI_B(gwimport_xork(gwi)) GWI_B(gwi_oper_ini(gwi, NULL, (m_str)OP_ANY_TYPE, NULL)) GWI_B(gwi_oper_add(gwi, opck_new)) GWI_B(gwi_oper_emi(gwi, opem_new)) GWI_B(gwi_oper_end(gwi, "new", NULL)) - GWI_BB(gwimport_ref(gwi)) - GWI_BB(gwimport_string(gwi)) - GWI_BB(gwimport_shred(gwi)) - GWI_BB(gwimport_modules(gwi)) + GWI_B(gwimport_ref(gwi)) + GWI_B(gwimport_string(gwi)) + GWI_B(gwimport_shred(gwi)) + GWI_B(gwimport_modules(gwi)) gwidoc(gwi, "allow member access."); GWI_B(gwi_oper_ini(gwi, "@Compound", (m_str)OP_ANY_TYPE, NULL)) @@ -144,19 +144,19 @@ ANN static bool import_core_libs(const Gwi gwi) { GWI_B(gwi_oper_emi(gwi, opem_object_dot)) GWI_B(gwi_oper_end(gwi, ".", NULL)) - GWI_BB(gwimport_class(gwi)) + GWI_B(gwimport_class(gwi)) gwidoc(gwi, "allow static access."); GWI_B(gwi_oper_ini(gwi, "Class", (m_str)OP_ANY_TYPE, NULL)) GWI_B(gwi_oper_add(gwi, opck_object_dot)) GWI_B(gwi_oper_emi(gwi, opem_object_dot)) GWI_B(gwi_oper_end(gwi, ".", NULL)) - GWI_BB(gwimport_deep_equal(gwi)); + GWI_B(gwimport_deep_equal(gwi)); - GWI_BB(gwimport_dict(gwi)); - GWI_BB(gwimport_gack(gwi)); - GWI_BB(gwimport_sift(gwi)); - GWI_BB(gwimport_locale(gwi)); + GWI_B(gwimport_dict(gwi)); + GWI_B(gwimport_gack(gwi)); + GWI_B(gwimport_sift(gwi)); + GWI_B(gwimport_locale(gwi)); // seemed need at a point to ease liking diff --git a/src/lib/enum.c b/src/lib/enum.c index fd1a8383..3c4410c3 100644 --- a/src/lib/enum.c +++ b/src/lib/enum.c @@ -27,5 +27,5 @@ GWION_IMPORT(enum) { const Type t_enum = gwi_mk_type(gwi, "enum", SZ_INT, "int"); gwi_set_global_type(gwi, t_enum, et_enum); gwi_gack(gwi, t_enum, gack_enum); - return GW_OK; + return true; } diff --git a/src/lib/event.c b/src/lib/event.c index 11483f60..83df7b3e 100644 --- a/src/lib/event.c +++ b/src/lib/event.c @@ -61,5 +61,5 @@ GWION_IMPORT(event) { GWI_B(gwi_class_end(gwi)) GWI_B(gwi_oper_ini(gwi, "Event", "@now", "int")) GWI_B(gwi_oper_end(gwi, "=>", EventWait)) - return GW_OK; + return true; } diff --git a/src/lib/instr.c b/src/lib/instr.c index d06bcc74..5d1b9cb4 100644 --- a/src/lib/instr.c +++ b/src/lib/instr.c @@ -18,7 +18,7 @@ ANN static Func_Def traverse_tmpl(const Emitter emit, Func_Def fdef, Func_Def fb const Env env = emit->env; const Symbol sym = func_symbol(env, nspc->name, s_name(fdef->base->tag.sym), "template", fbase->vt_index); - DECL_OO(const Value, v, = nspc_lookup_value0(nspc, sym) + DECL_O(const Value, v, = nspc_lookup_value0(nspc, sym) ?: nspc_lookup_value0(nspc, fdef->base->tag.sym)); const f_xfun xfun = v->d.func_ref->def->d.dl_func_ptr; if (vflag(v, vflag_builtin)) diff --git a/src/lib/lib_class.c b/src/lib/lib_class.c index fb1dbd57..94443a2b 100644 --- a/src/lib/lib_class.c +++ b/src/lib/lib_class.c @@ -17,7 +17,7 @@ POP_REG(shred, SZ_INT); \ const Type l = *(Type *)(shred->reg - SZ_INT); \ const Type r = *(Type *)(shred->reg); \ - *(m_uint *)(shred->reg - SZ_INT) = isa(arg0, arg1) > 0 __VA_ARGS__; \ + *(m_uint *)(shred->reg - SZ_INT) = isa(arg0, arg1) __VA_ARGS__; \ } mk_class_instr(ge, l, r) mk_class_instr(gt, l, r, &&l != r) mk_class_instr(le, r, l) mk_class_instr(lt, r, l, &&l != r) @@ -48,7 +48,7 @@ static OP_EMIT(opem_implicit_class) { static OP_CHECK(opck_implicit_class) { struct Implicit *imp = (struct Implicit*)data; const Type t = actual_type(env->gwion, imp->e->type); - if(isa(t, env->gwion->type[et_enum]) > 0) return imp->e->type; + if(isa(t, env->gwion->type[et_enum])) return imp->e->type; return env->gwion->type[et_error]; } */ @@ -79,5 +79,5 @@ GWION_IMPORT(class) { GWI_B(gwi_oper_emi(gwi, opem_implicit_class)) GWI_B(gwi_oper_end(gwi, "@implicit", NULL)) */ - return GW_OK; + return true; } diff --git a/src/lib/lib_gack.c b/src/lib/lib_gack.c index 83b68ede..aa2d225e 100644 --- a/src/lib/lib_gack.c +++ b/src/lib/lib_gack.c @@ -42,8 +42,8 @@ GWION_IMPORT(gack) { gwidoc(gwi, "a type for *pretty print*."); const Type t_gack = gwi_mk_type(gwi, "@Gack", SZ_INT, NULL); - GWI_BB(gwi_gack(gwi, t_gack, gack_gack)) - GWI_BB(gwi_set_global_type(gwi, t_gack, et_gack)); + GWI_B(gwi_gack(gwi, t_gack, gack_gack)) + GWI_B(gwi_set_global_type(gwi, t_gack, et_gack)); gwidoc(gwi, "@Gack implicit cast"); GWI_B(gwi_oper_ini(gwi, "@Gack", (m_str)OP_ANY_TYPE, NULL)) @@ -51,5 +51,5 @@ GWION_IMPORT(gack) { GWI_B(gwi_oper_emi(gwi, opem_gack_implicit)) GWI_B(gwi_oper_end(gwi, "@implicit", NULL)) - return GW_OK; + return true; } diff --git a/src/lib/locale.c b/src/lib/locale.c index 08e5a152..f079c975 100644 --- a/src/lib/locale.c +++ b/src/lib/locale.c @@ -47,5 +47,5 @@ GWION_IMPORT(locale) { GWI_B(gwi_func_ini(gwi, "float", "BasicLocale")); GWI_B(gwi_func_arg(gwi, "string", "str")); GWI_B(gwi_func_end(gwi, BasicLocale, ae_flag_none)); - return GW_OK; + return true; } diff --git a/src/lib/modules.c b/src/lib/modules.c index a97944fa..b5792223 100644 --- a/src/lib/modules.c +++ b/src/lib/modules.c @@ -35,7 +35,7 @@ static MFUN(gain_set_gain) { } static GWION_IMPORT(gain) { - GWI_OB(gwi_class_ini(gwi, "Gain", "UGen")) + GWI_B(gwi_class_ini(gwi, "Gain", "UGen")) gwi_class_xtor(gwi, gain_ctor, basic_dtor); gwi_func_ini(gwi, "float", "gain"); GWI_B(gwi_func_end(gwi, gain_get_gain, ae_flag_none)) @@ -67,7 +67,7 @@ static MFUN(impulse_set_next) { } static GWION_IMPORT(impulse) { - GWI_OB(gwi_class_ini(gwi, "Impulse", "UGen")) + GWI_B(gwi_class_ini(gwi, "Impulse", "UGen")) gwi_class_xtor(gwi, impulse_ctor, basic_dtor); gwi_func_ini(gwi, "float", "next"); GWI_B(gwi_func_end(gwi, impulse_get_next, ae_flag_none)) @@ -87,7 +87,7 @@ static CTOR(fullrect_ctor) { } static GWION_IMPORT(fullrect) { - GWI_OB(gwi_class_ini(gwi, "FullRect", "UGen")) + GWI_B(gwi_class_ini(gwi, "FullRect", "UGen")) gwi_class_xtor(gwi, fullrect_ctor, basic_dtor); return gwi_class_end(gwi); } @@ -107,7 +107,7 @@ static CTOR(halfrect_ctor) { } static GWION_IMPORT(halfrect) { - GWI_OB(gwi_class_ini(gwi, "HalfRect", "UGen")) + GWI_B(gwi_class_ini(gwi, "HalfRect", "UGen")) gwi_class_xtor(gwi, halfrect_ctor, basic_dtor); return gwi_class_end(gwi); } @@ -131,7 +131,7 @@ static MFUN(step_set_next) { } static GWION_IMPORT(step) { - GWI_OB(gwi_class_ini(gwi, "Step", "UGen")) + GWI_B(gwi_class_ini(gwi, "Step", "UGen")) gwi_class_xtor(gwi, step_ctor, basic_dtor); gwi_func_ini(gwi, "float", "next"); GWI_B(gwi_func_end(gwi, step_get_next, ae_flag_none)) @@ -156,7 +156,7 @@ static CTOR(zerox_ctor) { } static GWION_IMPORT(zerox) { - GWI_OB(gwi_class_ini(gwi, "ZeroX", "UGen")) + GWI_B(gwi_class_ini(gwi, "ZeroX", "UGen")) gwi_class_xtor(gwi, zerox_ctor, basic_dtor); return gwi_class_end(gwi); } @@ -208,14 +208,14 @@ static OP_CHECK(opck_usrugen) { if (!arg || arg->len > 1) ERR_N(exp_self(bin)->loc, _("Tick function take one and only one argument")); - if (isa(((Arg*)(arg->ptr))->type, env->gwion->type[et_float]) < 0) + if (!isa(((Arg*)(arg->ptr))->type, env->gwion->type[et_float])) ERR_N(exp_self(bin)->loc, _("Tick functions argument must be of type float")); - if (isa(bin->lhs->type->info->func->def->base->ret_type, - env->gwion->type[et_float]) < 0) + if (!isa(bin->lhs->type->info->func->def->base->ret_type, + env->gwion->type[et_float])) ERR_N(exp_self(bin)->loc, _("Tick function must return float")); if (bin->lhs->type->info->func->value_ref->from->owner_class) - CHECK_BN(isa(bin->lhs->type->info->func->value_ref->from->owner_class, + CHECK_ON(isa(bin->lhs->type->info->func->value_ref->from->owner_class, bin->rhs->type)); return bin->rhs->type; } @@ -273,7 +273,7 @@ static OP_EMIT(opem_usrugen) { } static GWION_IMPORT(usrugen) { - GWI_OB(gwi_class_ini(gwi, "UsrUGen", "UGen")) + GWI_B(gwi_class_ini(gwi, "UsrUGen", "UGen")) gwi_class_xtor(gwi, usrugen_ctor, usrugen_dtor); GWI_B(gwi_func_ini(gwi, "int", "default_tick")) GWI_B(gwi_func_end(gwi, default_tick, 0)) @@ -282,15 +282,15 @@ static GWION_IMPORT(usrugen) { GWI_B(gwi_oper_add(gwi, opck_usrugen)) GWI_B(gwi_oper_emi(gwi, opem_usrugen)) GWI_B(gwi_oper_end(gwi, "~=>", NULL)) - return GW_OK; + return true; } GWION_IMPORT(modules) { - GWI_BB(gwimport_gain(gwi)) - GWI_BB(gwimport_impulse(gwi)) - GWI_BB(gwimport_fullrect(gwi)) - GWI_BB(gwimport_halfrect(gwi)) - GWI_BB(gwimport_step(gwi)) - GWI_BB(gwimport_zerox(gwi)) + GWI_B(gwimport_gain(gwi)) + GWI_B(gwimport_impulse(gwi)) + GWI_B(gwimport_fullrect(gwi)) + GWI_B(gwimport_halfrect(gwi)) + GWI_B(gwimport_step(gwi)) + GWI_B(gwimport_zerox(gwi)) return gwimport_usrugen(gwi); } diff --git a/src/lib/object.c b/src/lib/object.c index 343aed5e..8bd413fb 100644 --- a/src/lib/object.c +++ b/src/lib/object.c @@ -124,7 +124,7 @@ static ID_CHECK(opck_super) { if(!env->func || is_ctor(env->func->def)) ERR_O(self->loc, "can't use 'super' outside of constructor"); const Type parent = env->class_def->info->parent; - DECL_OO(const Value, v, = find_value(parent, insert_symbol("new"))); + DECL_O(const Value, v, = find_value(parent, insert_symbol("new"))); SET_FLAG(env->func, const); return v->type; } @@ -133,7 +133,7 @@ static ID_EMIT(opem_super) { const Env env = emit->env; Exp* self = exp_self(prim); if(!self->is_call) - ERR_b(self->loc, "can only use 'super' as a function call"); + ERR_B(self->loc, "can only use 'super' as a function call"); emit_regpushmem(emit, 0, SZ_INT, false); emit_pushimm(emit, (m_uint)exp_self(prim)->type); return true; @@ -148,5 +148,5 @@ GWION_IMPORT(object) { gwi_specialid(gwi, "this", &spid_this); struct SpecialId_ spid_super = {.ck = opck_super, .em = opem_super, .is_const = 1}; gwi_specialid(gwi, "super", &spid_super); - return GW_OK; + return true; } diff --git a/src/lib/object_op.c b/src/lib/object_op.c index 15aed3f7..4c961f41 100644 --- a/src/lib/object_op.c +++ b/src/lib/object_op.c @@ -35,7 +35,7 @@ static OP_CHECK(opck_object_at) { SET_FLAG(vd.value, late); } exp_setvar(bin->rhs, 1); - CHECK_BO(isa(bin->lhs->type, bin->rhs->type)); + CHECK_O(isa(bin->lhs->type, bin->rhs->type)); bin->rhs->ref = bin->lhs; return bin->rhs->type; } @@ -78,8 +78,8 @@ static OP_EMIT(opem_object_at) { static OP_CHECK(opck_object_cast) { const Exp_Cast *cast = (Exp_Cast *)data; const Type to = known_type(env, cast->td); - if (isa(cast->exp->type, to) < 0) { - if (isa(to, cast->exp->type) > 0) + if (!isa(cast->exp->type, to)) { + if (isa(to, cast->exp->type)) ERR_N(exp_self(cast)->loc, _("can't upcast '%s' to '%s'"), cast->exp->type->name, to->name); ERR_N(exp_self(cast)->loc, _("can't cast '%s' to '%s'"), @@ -183,7 +183,7 @@ ANN static inline Value get_value(const Env env, const Exp_Dot *member, } ANN static bool member_access(const Env env, Exp* exp, const Value value) { - if (!env->class_def || isa(env->class_def, value->from->owner_class) < 0) { + if (!env->class_def || !isa(env->class_def, value->from->owner_class)) { if (GET_FLAG(value, private)) { gwerr_basic("invalid variable access", "is private", NULL, env->name, exp->loc, 0); @@ -209,7 +209,7 @@ OP_CHECK(opck_object_dot) { const Value v = nspc_lookup_value1(env->curr, member->xid); if(v) { if (self->is_call) { - if (is_func(env->gwion, v->type) && (!v->from->owner_class || isa(the_base, v->from->owner_class) > 0)) // is_callable needs type + if (is_func(env->gwion, v->type) && (!v->from->owner_class || isa(the_base, v->from->owner_class))) // is_callable needs type return v->type; } } @@ -221,7 +221,7 @@ OP_CHECK(opck_object_dot) { CHECK_ON(not_from_owner_class(env, the_base, value, self->loc)); CHECK_ON(member_access(env, self, value)); if ((base_static && vflag(value, vflag_member)) || - (value->from->owner_class != env->class_def && isa(value->from->owner_class, env->class_def) > 0)) + (value->from->owner_class != env->class_def && isa(value->from->owner_class, env->class_def))) ERR_N(self->loc, _("cannot access member '%s.%s' without object instance..."), the_base->name, str); @@ -264,7 +264,7 @@ OP_EMIT(opem_object_dot) { assert(GET_FLAG(value, static)); emit_dot_static_import_data(emit, value, exp_getvar(exp_self(member))); } - if(isa(value->type, emit->gwion->type[et_object]) > 0 && + if(isa(value->type, emit->gwion->type[et_object]) && !exp_getvar(exp_self(member)) && (GET_FLAG(value, static) || GET_FLAG(value, late))) emit_fast_except(emit, value->from, exp_self(member)->loc); @@ -379,7 +379,7 @@ static OP_EMIT(opem_cond_object) { GWION_IMPORT(object_op) { const Type t_error = gwi_mk_type(gwi, "@error", 0, NULL); gwi->gwion->type[et_error] = t_error; - GWI_BB(gwi_set_global_type(gwi, t_error, et_error)) + GWI_B(gwi_set_global_type(gwi, t_error, et_error)) GWI_B(gwi_oper_ini(gwi, "Object", "Object", NULL)) GWI_B(gwi_oper_add(gwi, opck_object_at)) GWI_B(gwi_oper_emi(gwi, opem_object_at)) @@ -403,5 +403,5 @@ GWION_IMPORT(object_op) { GWI_B(gwi_oper_ini(gwi, "@Compound", NULL, NULL)) GWI_B(gwi_oper_add(gwi, opck_struct_scan)) GWI_B(gwi_oper_end(gwi, "class", NULL)) - return GW_OK; + return true; } diff --git a/src/lib/opfunc.c b/src/lib/opfunc.c index f9dc3855..b6ce9ced 100644 --- a/src/lib/opfunc.c +++ b/src/lib/opfunc.c @@ -14,7 +14,7 @@ OP_CHECK(opck_basic_cast) { const Exp_Cast *cast = (Exp_Cast *)data; - return isa(cast->exp->type, exp_self(cast)->type) > 0 + return isa(cast->exp->type, exp_self(cast)->type) ? exp_self(cast)->type : env->gwion->type[et_error]; } @@ -152,7 +152,7 @@ OP_CHECK(opck_new) { (!array || (array->exp && exp_is_zero(array->exp)))) ERR_N(unary->ctor.td->tag.loc, _("can't use 'new' on abstract type '%s'\n"), t->name); - if (isa(t, env->gwion->type[et_object]) < 0) + if (!isa(t, env->gwion->type[et_object])) ERR_N(exp_self(unary)->loc, _("can't use 'new' on non-object types...\n")); return t; } diff --git a/src/lib/prim.c b/src/lib/prim.c index cba312dc..ebbe7a6d 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -129,7 +129,7 @@ GWION_IMPORT(int_op) { IMPORT_BINARY_INT(mul, *) IMPORT_BINARY_INT(div, /) IMPORT_BINARY_INT(mod, %) - return GW_OK; + return true; } static GWION_IMPORT(int_logical) { @@ -172,7 +172,7 @@ static GWION_IMPORT(int_r) { CHECK_OP("&=>", rassign, r_sand) CHECK_OP("|=>", rassign, r_sor) CHECK_OP("^=>", rassign, r_sxor) - return GW_OK; + return true; } static INSTR(IntRange) { @@ -243,7 +243,7 @@ static GWION_IMPORT(int_unary) { GWI_B(gwi_oper_end(gwi, "++", int_post_inc)) GWI_B(gwi_oper_add(gwi, opck_post)) GWI_B(gwi_oper_end(gwi, "--", int_post_dec)) - return GW_OK; + return true; } static GACK(gack_bool) { // gw_out("%s", *(m_uint*)VALUE ? "true" : "false"); @@ -261,9 +261,9 @@ static OP_CHECK(bool2float) { } static GWION_IMPORT(int_values) { - DECL_OB(const Type, t_bool, = gwi_mk_type(gwi, "bool", SZ_INT, "int")); - GWI_BB(gwi_set_global_type(gwi, t_bool, et_bool)) - GWI_BB(gwi_gack(gwi, t_bool, gack_bool)) + DECL_B(const Type, t_bool, = gwi_mk_type(gwi, "bool", SZ_INT, "int")); + GWI_B(gwi_set_global_type(gwi, t_bool, et_bool)) + GWI_B(gwi_gack(gwi, t_bool, gack_bool)) gwi_item_ini(gwi, "bool", "true"); gwi_item_end(gwi, ae_flag_const, num, 1); gwi_item_ini(gwi, "bool", "false"); @@ -278,18 +278,18 @@ static GWION_IMPORT(int_values) { struct SpecialId_ spid = { .type = t_bool, .exec = RegPushMaybe, .is_const = 1}; gwi_specialid(gwi, "maybe", &spid); - return GW_OK; + return true; } static GWION_IMPORT(int) { - GWI_BB(gwimport_int_values(gwi)) + GWI_B(gwimport_int_values(gwi)) GWI_B(gwi_oper_cond(gwi, "int", BranchEqInt, BranchNeqInt)) GWI_B(gwi_oper_ini(gwi, "int", "int", "int")) - GWI_BB(gwimport_int_op(gwi)) - GWI_BB(gwimport_int_logical(gwi)) - GWI_BB(gwimport_int_r(gwi)) - GWI_BB(gwimport_int_unary(gwi)) - return GW_OK; + GWI_B(gwimport_int_op(gwi)) + GWI_B(gwimport_int_logical(gwi)) + GWI_B(gwimport_int_r(gwi)) + GWI_B(gwimport_int_unary(gwi)) + return true; } static OP_CHECK(opck_cast_f2i) { @@ -393,7 +393,7 @@ static GWION_IMPORT(intfloat) { GWI_B(gwi_oper_end(gwi, "==", int_float_eq)) GWI_B(gwi_oper_add(gwi, opck_int_float_neq)) GWI_B(gwi_oper_end(gwi, "!=", int_float_neq)) - return GW_OK; + return true; } #define BINARY_FLOAT_INT_FOLD(name, TYPE, OP, pre) \ @@ -455,7 +455,7 @@ static GWION_IMPORT(floatint) { GWI_B(gwi_oper_end(gwi, "<", float_int_lt)) GWI_B(gwi_oper_add(gwi, opck_float_int_le)) GWI_B(gwi_oper_end(gwi, "<=", float_int_le)) - return GW_OK; + return true; } static GWION_IMPORT(dur) { @@ -614,7 +614,7 @@ static GWION_IMPORT(float) { // GWI_B(gwi_oper_add(gwi, opck_unary_meta2)) GWI_B(gwi_oper_add(gwi, opck_float_not)) GWI_B(gwi_oper_end(gwi, "!", float_not)) - return GW_OK; + return true; } ANN static GWION_IMPORT(ux) { @@ -625,15 +625,15 @@ ANN static GWION_IMPORT(ux) { const Symbol s = insert_symbol(c); if(!gwi_primitive(gwi, s_name(s), i, ae_flag_none)) return false; } - return GW_OK; + return true; } GWION_IMPORT(prim) { - GWI_BB(gwimport_int(gwi)) - GWI_BB(gwimport_ux(gwi)); - GWI_BB(gwimport_float(gwi)) // const folded - GWI_BB(gwimport_intfloat(gwi)) // const folded - GWI_BB(gwimport_floatint(gwi)) // const folded - GWI_BB(gwimport_dur(gwi)) + GWI_B(gwimport_int(gwi)) + GWI_B(gwimport_ux(gwi)); + GWI_B(gwimport_float(gwi)) // const folded + GWI_B(gwimport_intfloat(gwi)) // const folded + GWI_B(gwimport_floatint(gwi)) // const folded + GWI_B(gwimport_dur(gwi)) return gwimport_time(gwi); } diff --git a/src/lib/prim_values.c b/src/lib/prim_values.c index c148fd25..8725799e 100644 --- a/src/lib/prim_values.c +++ b/src/lib/prim_values.c @@ -37,5 +37,5 @@ GWION_IMPORT(values) { gwi_item_end(gwi, ae_flag_const, fnum, sr * 60 * 60); gwi_item_ini(gwi, "time", "t_zero"); gwi_item_end(gwi, ae_flag_const, fnum, 0.0); - return GW_OK; + return true; } diff --git a/src/lib/ref.c b/src/lib/ref.c index ebe952f9..622931bf 100644 --- a/src/lib/ref.c +++ b/src/lib/ref.c @@ -47,7 +47,7 @@ static inline Type ref_base(Type t) { static OP_EMIT(opem_ref_implicit_similar) { const struct Implicit *imp = (struct Implicit *)data; - if(!tflag(imp->t, tflag_contract)) return GW_OK; + if(!tflag(imp->t, tflag_contract)) return true; const Env env = emit->env; const Type base = ref_base(imp->t); struct Op_Import opi = {.op = insert_symbol("@implicit"), @@ -193,5 +193,5 @@ GWION_IMPORT(ref) { GWI_B(gwi_oper_ini(gwi, "Ref", NULL, NULL)) GWI_B(gwi_oper_add(gwi, opck_ref_scan)) GWI_B(gwi_oper_end(gwi, "class", NULL)) - return GW_OK; + return true; } diff --git a/src/lib/shred.c b/src/lib/shred.c index 3621ebb0..7ab6d42b 100644 --- a/src/lib/shred.c +++ b/src/lib/shred.c @@ -15,10 +15,10 @@ #include "gwi.h" #include "ugen.h" -static m_int o_fork_thread, o_shred_cancel, - o_fork_done, o_fork_ev; - -#define FORK_THREAD(o) *(THREAD_TYPE *)(o->data + o_fork_thread) +#define SHRED_CANCEL(o) *(m_int *)(o->data + SZ_INT) +#define FORK_THREAD(o) *(THREAD_TYPE *)(o->data + SZ_INT*2) +#define FORK_DONE(o) *(m_int *)(o->data + SZ_INT*3) +#define FORK_EV(o) *(M_Object *)(o->data + SZ_INT*4) VM_Shred new_shred_base(const VM_Shred shred, const VM_Code code) { const VM_Shred sh = new_vm_shred(shred->info->mp, code); @@ -37,9 +37,8 @@ M_Object new_shred(const VM_Shred shred) { ANN static inline M_Object fork_object(const VM_Shred shred, const Type t) { const Gwion gwion = shred->info->vm->gwion; const M_Object o = new_object(gwion->mp, t); - *(M_Object *)(o->data + o_fork_ev) = - new_object(gwion->mp, gwion->type[et_event]); - vector_init(&EV_SHREDS(*(M_Object *)(o->data + o_fork_ev))); + FORK_EV(o) = new_object(gwion->mp, gwion->type[et_event]); + vector_init(&EV_SHREDS(FORK_EV(o))); return o; } @@ -165,8 +164,8 @@ static void stop(const M_Object o) { gwt_lock(&vm->shreduler->mutex); gwt_lock(&ME(o)->mutex); vm->shreduler->bbq->is_running = 0; - *(m_int *)(o->data + o_shred_cancel) = 1; - *(m_int *)(o->data + o_fork_done) = 1; + SHRED_CANCEL(o) = 1; + FORK_DONE(o) = 1; gwt_unlock(&ME(o)->mutex); gwt_unlock(&vm->shreduler->mutex); } @@ -174,12 +173,12 @@ static void stop(const M_Object o) { static inline void join(const M_Object o) { // if(!ME(o)) return; // gwt_lock(&ME(o)->mutex); -// const bool done = !*(m_int *)(o->data + o_fork_done); +// const bool done = !FORK_DONE(o)); // gwt_unlock(&ME(o)->mutex); -//// if (!*(m_int *)(o->data + o_fork_done)) { +//// if (!FORK_DONE(o)) { if (FORK_THREAD(o)) { // if (!done) { -// *(m_int *)(o->data + o_fork_done) = 1; +// FORK_DONE(o) = 1; THREAD_JOIN(FORK_THREAD(o)); FORK_THREAD(o) = 0; } @@ -188,7 +187,7 @@ static inline void join(const M_Object o) { static DTOR(fork_dtor) { VM *parent = ME(o)->info->vm->parent; gwt_lock(&ME(o)->mutex); - *(m_int *)(o->data + o_fork_done) = 1; + FORK_DONE(o) = 1; gwt_unlock(&ME(o)->mutex); stop(o); join(o); @@ -205,23 +204,23 @@ static DTOR(fork_dtor) { } static MFUN(fork_join) { - if (*(m_int *)(o->data + o_fork_done)) return; + if (FORK_DONE(o)) return; if (!ME(o)->tick) return; shred->info->me->ref++; - vector_add(&EV_SHREDS(*(M_Object *)(o->data + o_fork_ev)), (vtype)shred); + vector_add(&EV_SHREDS(FORK_EV(o)), (vtype)shred); shreduler_remove(shred->tick->shreduler, shred, false); } static MFUN(shred_cancel) { if(!ME(o)->tick)return; gwt_lock(&ME(o)->mutex); - *(m_int *)(o->data + o_shred_cancel) = *(m_int *)MEM(SZ_INT); + SHRED_CANCEL(o) = *(m_int *)MEM(SZ_INT); gwt_unlock(&ME(o)->mutex); } static MFUN(shred_test_cancel) { gwt_lock(&ME(o)->mutex); - if (*(m_int *)(o->data + o_shred_cancel)) { + if (SHRED_CANCEL(o)) { gwt_unlock(&ME(o)->mutex); vm_shred_exit(ME(o)); } else gwt_unlock(&ME(o)->mutex); @@ -230,7 +229,7 @@ static MFUN(shred_test_cancel) { static MFUN(fork_test_cancel) { VM *parent = ME(o)->info->vm; gwt_lock(&parent->shreduler->mutex); - if (*(m_int *)(o->data + o_shred_cancel)) { + if (SHRED_CANCEL(o)) { gwt_unlock(&parent->shreduler->mutex); stop(o); join(o); @@ -264,7 +263,7 @@ struct ThreadLauncher { static inline int fork_running(VM *vm, const M_Object o) { gwt_lock(&ME(o)->mutex); - const int cancel = *(m_int *)(o->data + o_shred_cancel); + const int cancel = SHRED_CANCEL(o); gwt_unlock(&ME(o)->mutex); if(cancel)return false; gwt_lock(&vm->shreduler->mutex); @@ -288,14 +287,14 @@ static ANN THREAD_FUNC(fork_run) { gwion_end_child(ME(me), vm->gwion); vm_lock(vm); gwt_lock(&ME(me)->mutex); - if (!*(m_int *)(me->data + o_shred_cancel) && + if (!SHRED_CANCEL(me) && me->type_ref != vm->gwion->type[et_fork]) memcpy(me->data + vm->gwion->type[et_fork]->nspc->offset, ME(me)->reg, ((Type)vector_front(&me->type_ref->info->tuple->types))->size); - *(m_int *)(me->data + o_fork_done) = 1; + FORK_DONE(me) = 1; gwt_unlock(&ME(me)->mutex); - if (!*(m_int *)(me->data + o_shred_cancel)) - broadcast(*(M_Object *)(me->data + o_fork_ev)); + if (!SHRED_CANCEL(me)) + broadcast(FORK_EV(me)); vm_unlock(vm); THREAD_RETURN(0); } @@ -344,7 +343,7 @@ GWION_IMPORT(shred) { t_shred->nspc->offset += SZ_INT; gwi_item_ini(gwi, "int", "cancel"); - GWI_BB((o_shred_cancel = gwi_item_end(gwi, ae_flag_const, num, 0))) + GWI_B(gwi_item_end(gwi, ae_flag_const, num, 0)); gwi_func_ini(gwi, "void", "exit"); GWI_B(gwi_func_end(gwi, gw_shred_exit, ae_flag_none)) @@ -416,13 +415,12 @@ GWION_IMPORT(shred) { const Type t_fork = gwi_class_ini(gwi, "Fork", "Shred"); gwi_class_xtor(gwi, NULL, fork_dtor); gwi->gwion->type[et_fork] = t_fork; - o_fork_thread = t_fork->nspc->offset; t_fork->nspc->offset += sizeof(gwtthread_t*); gwi_item_ini(gwi, "int", "is_done"); - GWI_BB((o_fork_done = gwi_item_end(gwi, ae_flag_const, num, 0))) + GWI_B(gwi_item_end(gwi, ae_flag_const, num, 0)); gwi_item_ini(gwi, "Event", "ev"); - GWI_BB((o_fork_ev = gwi_item_end(gwi, ae_flag_const, num, 0))) + GWI_B(gwi_item_end(gwi, ae_flag_const, num, 0)); gwi_func_ini(gwi, "void", "join"); GWI_B(gwi_func_end(gwi, fork_join, ae_flag_none)) gwi_func_ini(gwi, "void", "test_cancel"); @@ -432,8 +430,8 @@ GWION_IMPORT(shred) { const Type t_typed = gwi_class_ini(gwi, "TypedFork:[A]", "Fork"); gwi_item_ini(gwi, "A", "retval"); - GWI_BB(gwi_item_end(gwi, ae_flag_const, num, 0)) + GWI_B(gwi_item_end(gwi, ae_flag_const, num, 0)) GWI_B(gwi_class_end(gwi)) SET_FLAG(t_typed, abstract | ae_flag_final); - return GW_OK; + return true; } diff --git a/src/lib/sift.c b/src/lib/sift.c index 0ed55fa4..cd73de37 100644 --- a/src/lib/sift.c +++ b/src/lib/sift.c @@ -100,5 +100,5 @@ GWION_IMPORT(sift) { GWI_B(gwi_oper_ini(gwi, "Sift", "funptr", "Sift")); GWI_B(gwi_oper_add(gwi, opck_sift)); GWI_B(gwi_oper_end(gwi, "|>", NULL)); - return GW_OK; + return true; } diff --git a/src/lib/string.c b/src/lib/string.c index 07ec04e7..1ea69a3a 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -477,7 +477,7 @@ GWION_IMPORT(string) { const Type t_string = gwi_class_ini(gwi, "string", NULL); gwi->gwion->type[et_string] = t_string; // use func gwi_class_xtor(gwi, string_ctor, string_dtor); - GWI_BB(gwi_gack(gwi, t_string, gack_string)) + GWI_B(gwi_gack(gwi, t_string, gack_string)) t_string->nspc->offset += SZ_INT; gwi_func_ini(gwi, "int", "size"); @@ -598,5 +598,5 @@ GWION_IMPORT(string) { struct SpecialId_ line_spid = { .ck = check_linepp, .is_const = 1}; gwi_specialid(gwi, "__line__", &line_spid); - return GW_OK; + return true; } diff --git a/src/lib/ugen.c b/src/lib/ugen.c index b037e8de..4e170b65 100644 --- a/src/lib/ugen.c +++ b/src/lib/ugen.c @@ -393,7 +393,7 @@ static GWION_IMPORT(global_ugens) { struct ugen_importer imp_adc = {vm, adc_tick, "adc", vm->bbq->si->in}; (void)add_ugen(gwi, &imp_adc); SET_FLAG(gwi->gwion->type[et_ugen], abstract); - return GW_OK; + return true; } static OP_CHECK(opck_chuck_ugen) { diff --git a/src/lib/union.c b/src/lib/union.c index d9c6a32a..63820265 100644 --- a/src/lib/union.c +++ b/src/lib/union.c @@ -158,8 +158,8 @@ static OP_CHECK(opck_union_new) { ANN GWION_IMPORT(union) { const Type t_none = gwi_mk_type(gwi, "None", 0, NULL); - GWI_BB(gwi_set_global_type(gwi, t_none, et_none)) - GWI_BB(gwi_gack(gwi, t_none, gack_none)) + GWI_B(gwi_set_global_type(gwi, t_none, et_none)) + GWI_B(gwi_gack(gwi, t_none, gack_none)) gwi_add_type(gwi, t_none); struct SpecialId_ spid = { .type = gwi->gwion->type[et_none], .exec = NoOp, .is_const = 1}; @@ -174,8 +174,8 @@ ANN GWION_IMPORT(union) { //gwi_class_xtor(gwi, NULL, UnionDtor); gwi->gwion->type[et_union] = t_union; - GWI_BB(gwi_item_ini(gwi, "int", "index")) - GWI_BB(gwi_item_end(gwi, ae_flag_const, num, 0)) + GWI_B(gwi_item_ini(gwi, "int", "index")) + GWI_B(gwi_item_end(gwi, ae_flag_const, num, 0)) /* GWI_B(gwi_func_ini(gwi, "void", "@ctor")) GWI_B(gwi_func_end(gwi, union_ctor, ae_flag_none)) @@ -206,5 +206,5 @@ ANN GWION_IMPORT(union) { GWI_B(gwi_union_add(gwi, "A", "val")) GWI_B(gwi_union_end(gwi, ae_flag_none)) - return GW_OK; + return true; } diff --git a/src/lib/xork.c b/src/lib/xork.c index 73bd5144..57281235 100644 --- a/src/lib/xork.c +++ b/src/lib/xork.c @@ -41,7 +41,7 @@ static OP_CHECK(opck_spork) { uint32_t offset = !env->class_def ? 0 : SZ_INT; for(uint32_t i = 0; i < unary->captures->len; i++) { Capture *const cap = mp_vector_at(unary->captures, Capture, i); - DECL_OO(const Type, t, = upvalue_type(env, cap)); + DECL_O(const Type, t, = upvalue_type(env, cap)); cap->temp = new_value(env, t, cap->var.tag); cap->temp->from->offset = offset; offset += cap->temp->type->size; @@ -100,5 +100,5 @@ GWION_IMPORT(xork) { GWI_B(gwi_oper_end(gwi, "fork", NULL)) gwi_register_freearg(gwi, SporkIni, freearg_xork); gwi_register_freearg(gwi, fast_except, clean_fast_except); - return GW_OK; + return true; } diff --git a/src/parse/check.c b/src/parse/check.c index 6c8a296d..c0d58fc9 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -18,14 +18,6 @@ #include "spread.h" #include "array.h" -#undef ERR_B -#define ERR_B(a, b, ...) \ - { \ - env_err(env, (a), (b), ##__VA_ARGS__); \ - return false; \ - } - - ANN bool check_stmt(const Env env, Stmt*); ANN bool check_class_def(const Env env, const Class_Def class_def); @@ -42,7 +34,7 @@ ANN static Type check_internal(const Env env, const Symbol sym, Exp* e, ANN bool check_implicit(const Env env, Exp* e, const Type t) { if (e->type == t) return true; - if (isa(e->type, t) > 0) return true; + if (isa(e->type, t)) return true; const Symbol sym = insert_symbol("@implicit"); return !!(e->cast_to = check_internal(env, sym, e, t)); } @@ -60,7 +52,7 @@ ANN bool check_subscripts(Env env, const Array_Sub array, } } while (++depth && (e = e->next)); if (depth != array->depth) - ERR_B(array->exp->loc, _("invalid array access expression.")) + ERR_B(array->exp->loc, _("invalid array access expression.")); return ok; } @@ -166,7 +158,7 @@ ANN bool ensure_traverse(const Env env, const Type t) { ANN static inline bool inferable(const Env env, const Type t, const loc_t loc) { if (!tflag(t, tflag_infer)) return true; - ERR_B(loc, _("can't infer type.")) + ERR_B(loc, _("can't infer type.")); } ANN Type check_exp_decl(const Env env, Exp_Decl *const decl) { @@ -198,7 +190,7 @@ ANN Type check_exp_decl(const Env env, Exp_Decl *const decl) { env_pop(env, scope); set_vflag(decl->var.vd.value, vflag_direct); } - env_weight(env, 1 + isa(decl->type, env->gwion->type[et_object]) > 0); + env_weight(env, 1 + isa(decl->type, env->gwion->type[et_object])); return ret ? decl->var.vd.value->type : NULL; } @@ -245,8 +237,8 @@ ANN static bool check_range(const Env env, Range *range) { if (range->start) CHECK_B(check_exp(env, range->start)); if (range->end) CHECK_B(check_exp(env, range->end)); if (range->start && range->end) { - if (isa(range->end->type, range->start->type) < 0) - ERR_B(range->start->loc, _("range types do not match")) + if (!isa(range->end->type, range->start->type)) + ERR_B(range->start->loc, _("range types do not match")); } return true; } @@ -285,10 +277,10 @@ ANN static Type check_prim_dict(const Env env, Exp* *data) { ANN bool not_from_owner_class(const Env env, const Type t, const Value v, const loc_t loc) { - if (!v->from->owner_class || isa(t, v->from->owner_class) < 0) { + if (!v->from->owner_class || !isa(t, v->from->owner_class)) { if(!is_class(env->gwion, v->type)) ERR_B(loc, _("'%s' from owner namespace '%s' used in '%s'."), v->name, - v->from->owner ? v->from->owner->name : "?", t->name) + v->from->owner ? v->from->owner->name : "?", t->name); } return true; } @@ -308,10 +300,10 @@ set_tflag(value->from->owner_class, tflag_check); return value; } - if (!value->from->owner_class || isa(env->class_def, value->from->owner_class) > 0) + if (!value->from->owner_class || isa(env->class_def, value->from->owner_class)) return value; if(env->class_def) { - if (isa(env->class_def, value->from->owner_class) > 0 || value == env->class_def->info->value) + if (isa(env->class_def, value->from->owner_class) || value == env->class_def->info->value) return value; } @@ -604,7 +596,7 @@ static Func find_func_match_actual(const Env env, const Func f, Exp* exp, return find_func_match_actual(env, func->next, exp, implicit, specific); } - if (tflag(e->type, tflag_ref) && isa(e->type, arg->type) > 0) { + if (tflag(e->type, tflag_ref) && isa(e->type, arg->type)) { if(!e->cast_to)e->cast_to = arg->type; } @@ -650,7 +642,7 @@ ANN Func find_func_match(const Env env, const Func up, Exp_Call *const call) { Func func; Exp* exp = call->args; Exp* args = - (exp && isa(exp->type, env->gwion->type[et_void]) < 0) ? exp : NULL; + (exp && !isa(exp->type, env->gwion->type[et_void])) ? exp : NULL; if ((func = find_func_match_actual(env, up, args, false, true)) || (func = find_func_match_actual(env, up, args, true, true)) || (func = find_func_match_actual(env, up, args, false, true)) || @@ -711,7 +703,7 @@ static void function_alternative(const Env env, const Type t, Exp* args, return; gwerr_basic("Argument type mismatch", "call site", "valid alternatives:", env->name, loc, 0); - const bool is_closure = isa(t, env->gwion->type[et_closure]) < 0; + const bool is_closure = !isa(t, env->gwion->type[et_closure]); Func up = is_closure ? t->info->func : closure_def(t)->base->func; do print_signature(up); @@ -853,7 +845,7 @@ ANN static TmplArg_List check_template_args(const Env env, Exp_Call *exp, ANN static Type check_exp_call_template(const Env env, Exp_Call *exp) { /*const */Type t = exp->func->type; - if(isa(t, env->gwion->type[et_closure]) > 0) { + if(isa(t, env->gwion->type[et_closure])) { const Func_Def fdef = closure_def(t); t = fdef->base->func->value_ref->type; } @@ -958,7 +950,7 @@ ANN bool func_check(const Env env, Exp_Call *const exp, bool *mod) { CHECK_B(check_exp(env, exp->func)); if (exp->func->exp_type == ae_exp_decl) ERR_B(exp->func->loc, _("Can't call late function pointer at declaration " - "site. did you meant to use `:=>`?")) + "site. did you meant to use `:=>`?")); const Type t = actual_type(env->gwion, exp->func->type); if (is_func(env->gwion, t) && exp->func->exp_type == ae_exp_dot && // is_callable !t->info->value->from->owner_class) { @@ -990,7 +982,7 @@ ANN void call_add_effect(const Env env, const Func func, const loc_t loc) { ANN Type call_type(const Env env, Exp_Call *const exp) { const Type t = exp->func->type; if (is_func(env->gwion, t)) return t; - if(isa(exp->func->type, env->gwion->type[et_closure]) > 0) + if(isa(exp->func->type, env->gwion->type[et_closure])) return closure_def(t)->base->func->value_ref->type; if(is_class(env->gwion, t) && tflag(t->info->base_type, tflag_struct)) { const Value v = nspc_lookup_value0(t->info->base_type->nspc, insert_symbol("new")); @@ -1063,7 +1055,7 @@ ANN Type check_exp_call1(const Env env, Exp_Call *const exp) { CHECK_O(check_static(env, exp->func)); const Type _ret = _check_exp_call1(env, exp); if(_ret) return _ret; - if(isa(exp->func->type, env->gwion->type[et_closure]) > 0) { + if(isa(exp->func->type, env->gwion->type[et_closure])) { if(exp->func->exp_type == ae_exp_dot && t->info->value->from->owner_class) { Exp* args = exp->args; Exp* this_arg = cpy_exp(env->gwion->mp, exp->func->d.exp_dot.base); @@ -1144,7 +1136,7 @@ ANN static Type check_exp_post(const Env env, const Exp_Postfix *post) { CHECK_O(opi.lhs); exp_setuse(post->exp, 1); const Type t = op_check(env, &opi); - if (t && isa(t, env->gwion->type[et_object]) < 0) + if (t && !isa(t, env->gwion->type[et_object])) exp_setmeta(exp_self(post), 1); return t; } @@ -1220,7 +1212,7 @@ ANN static Type check_exp_call(const Env env, Exp_Call *exp) { CHECK_O(func_check(env, exp, &mod)); if (mod) return exp_self(exp)->type; Type t = actual_type(env->gwion, exp->func->type); - if(isa(exp->func->type, env->gwion->type[et_closure]) > 0) { + if(isa(exp->func->type, env->gwion->type[et_closure])) { t = typedef_base(t); t = mp_vector_at(t->info->cdef->body, Section , 0)->d.func_def->base->func->value_ref->type; } @@ -1276,7 +1268,7 @@ ANN static Type check_exp_if(const Env env, Exp_If *const exp_if) { ERR_O(exp_self(exp_if)->loc, _("incompatible types '%s' and '%s' in if expression..."), if_exp->name, else_exp->name); - if (isa(if_exp, else_exp) < 0) + if (!isa(if_exp, else_exp)) ERR_O(exp_self(exp_if)->loc, _("condition type '%s' does not match '%s'"), cond->name, ret->name); exp_setuse(exp_if->cond, true); @@ -1312,7 +1304,7 @@ ANN bool check_type_def(const Env env, const Type_Def tdef) { const Func_Def fdef = new_func_def(env->gwion->mp, fb, code); tdef->when_def = fdef; CHECK_B(traverse_func_def(env, fdef)); - if (isa(when->type, env->gwion->type[et_bool]) < 0) { + if (!isa(when->type, env->gwion->type[et_bool])) { char explain[strlen(when->type->name) + 20]; sprintf(explain, "found `{/+}%s{0}`", when->type->name); gwerr_basic("Invalid `{/+}when{0}` predicate expression type", explain, @@ -1409,7 +1401,7 @@ ANN static inline bool for_empty(const Env env, const Stmt_For stmt) { ERR_B(stmt_self(stmt)->loc, _("empty for loop condition..." "...(note: explicitly use 'true' if it's the intent)" - "...(e.g., 'for(; true;){{ /*...*/ }')")) + "...(e.g., 'for(; true;){{ /*...*/ }')")); return true; } @@ -1500,7 +1492,7 @@ ANN static bool check_stmt_return(const Env env, const Stmt_Exp stmt) { if (is_new(env->func->def)) { if(stmt->val) ERR_B(stmt_self(stmt)->loc, - _("'return' statement inside constructor function should have no expression")) + _("'return' statement inside constructor function should have no expression")); return true; } DECL_B(const Type, ret_type, @@ -1509,7 +1501,7 @@ ANN static bool check_stmt_return(const Env env, const Stmt_Exp stmt) { env->func->def->base->ret_type = ret_type; return true; } - if (isa(ret_type, env->func->def->base->ret_type) > 0) return true; + if (isa(ret_type, env->func->def->base->ret_type)) return true; if (tflag(ret_type, tflag_noret)) ERR_B(stmt->val->loc, _("Can't use type `{+G}%s{+G}` for return"), ret_type->name); @@ -1518,22 +1510,22 @@ ANN static bool check_stmt_return(const Env env, const Stmt_Exp stmt) { if (env->func->def->base->tag.sym == insert_symbol("@implicit") && ret_type == arg->type) ERR_B(stmt_self(stmt)->loc, - _("can't use implicit casting while defining it")) + _("can't use implicit casting while defining it")); if (check_implicit(env, stmt->val, env->func->def->base->ret_type)) return true; ERR_B(stmt_self(stmt)->loc, _("invalid return type: got '%s', expected '%s'"), ret_type->name, - env->func->def->base->ret_type->name) + env->func->def->base->ret_type->name); } - if (isa(env->func->def->base->ret_type, env->gwion->type[et_void]) > 0) + if (isa(env->func->def->base->ret_type, env->gwion->type[et_void])) return true; - ERR_B(stmt_self(stmt)->loc, _("missing value for return statement")) + ERR_B(stmt_self(stmt)->loc, _("missing value for return statement")); } -#define describe_check_stmt_stack(stack, name) \ +#define describe_check_stmt_stack(stack, name) \ ANN static bool check_stmt_##name(const Env env, const Stmt* stmt) { \ - if (!vector_size(&env->scope->stack)) \ - ERR_B(stmt->loc, _("'" #name "' found outside of for/while/until...")) \ + if (!vector_size(&env->scope->stack)) \ + ERR_B(stmt->loc, _("'" #name "' found outside of for/while/until...")); \ return true; \ } describe_check_stmt_stack(conts, continue); @@ -1606,7 +1598,7 @@ ANN static Symbol case_op(const Env env, const Type base, Exp* e) { ANN static bool match_case_exp(const Env env, Exp* e) { Exp* last = e; for (m_uint i = 0; i < vector_size(&env->scope->match->cond); e = e->next, ++i) { - if (!e) ERR_B(last->loc, _("no enough to match")) + if (!e) ERR_B(last->loc, _("no enough to match")); last = e; Exp* base = (Exp*)vector_at(&env->scope->match->cond, i); const Symbol op = case_op(env, base->type, e); @@ -1627,7 +1619,7 @@ ANN static bool match_case_exp(const Env env, Exp* e) { CHECK_B(ret); } } - if (e) ERR_B(e->loc, _("too many expression to match")) + if (e) ERR_B(e->loc, _("too many expression to match")); return true; } @@ -1764,7 +1756,7 @@ ANN static bool check_signature_match(const Env env, const Func_Def fdef, const Func parent) { if (GET_FLAG(parent->def->base, final)) ERR_B(fdef->base->td->tag.loc, _("can't override final function '%s'\n"), - parent->name) + parent->name); if (GET_FLAG(parent->def->base, static) != GET_FLAG(fdef->base, static)) { const m_str c_name = fdef->base->func->value_ref->from->owner_class->name; const m_str p_name = parent->value_ref->from->owner_class->name; @@ -1773,9 +1765,9 @@ ANN static bool check_signature_match(const Env env, const Func_Def fdef, _("function '%s.%s' ressembles '%s.%s' but cannot override...\n" " ...(reason: '%s.%s' is declared as 'static')"), c_name, f_name, p_name, c_name, - GET_FLAG(fdef->base, static) ? c_name : p_name, f_name) + GET_FLAG(fdef->base, static) ? c_name : p_name, f_name); } - if(fdef->base->tmpl || isa(fdef->base->ret_type, parent->def->base->ret_type) > 0) + if(fdef->base->tmpl || isa(fdef->base->ret_type, parent->def->base->ret_type)) return true; gwerr_basic_from("invalid overriding", NULL, NULL, fdef->base->func->value_ref->from, 0); gwerr_secondary_from("does not match", parent->value_ref->from); @@ -1840,7 +1832,7 @@ ANN static bool check_func_overload(const Env env, const Func_Def fdef) { ERR_B(f2->def->base->tag.loc, _("global function '%s' already defined" " for those arguments"), - s_name(fdef->base->tag.sym)) + s_name(fdef->base->tag.sym)); } } return true; @@ -1867,7 +1859,7 @@ ANN static bool check_func_def_override(const Env env, const Func_Def fdef, ERR_B(fdef->base->tag.loc, _("function name '%s' conflicts with previously defined value...\n" " from super class '%s'..."), - s_name(fdef->base->tag.sym), override->from->owner_class->name) + s_name(fdef->base->tag.sym), override->from->owner_class->name); *ov = override; } if (func->value_ref->from->offset && @@ -2003,9 +1995,10 @@ ANN bool _check_func_def(const Env env, const Func_Def f) { if (ret) { if (env->class_def && fdef->base->effects.ptr && (override && - !check_effect_overload(&fdef->base->effects, override->d.func_ref))) + !check_effect_overload(&fdef->base->effects, override->d.func_ref))) { ERR_B(fdef->base->tag.loc, _("too much effects in override."), - s_name(fdef->base->tag.sym)) + s_name(fdef->base->tag.sym)); + } if(is_new(f) && !tflag(env->class_def, tflag_struct)) CHECK_B(check_ctor(env, func)); } @@ -2157,7 +2150,7 @@ ANN static bool class_def_has_body(Ast ast) { } ANN static inline bool type_is_recurs(const Type t, const Type tgt) { - return isa(tgt, t) > 0 || isa(t, tgt) > 0 || (tgt->info->tuple && vector_find(&tgt->info->tuple->contains, (m_uint)t) > -1); + return isa(tgt, t) || isa(t, tgt) || (tgt->info->tuple && vector_find(&tgt->info->tuple->contains, (m_uint)t) > -1); } ANN static bool recursive_type_base(const Env env, const Type t); diff --git a/src/parse/check_traits.c b/src/parse/check_traits.c index 1478b074..c52af181 100644 --- a/src/parse/check_traits.c +++ b/src/parse/check_traits.c @@ -14,7 +14,7 @@ ANN static bool var_match(const Value a, const Value b) { bool error = true; - if (isa(a->type, a->type) < 0) { + if (!isa(a->type, a->type)) { gwerr_basic_from("invalid variable type", NULL, NULL, a->from, 0); error = false; } diff --git a/src/parse/func_resolve_tmpl.c b/src/parse/func_resolve_tmpl.c index 8b78fc3d..7eb29378 100644 --- a/src/parse/func_resolve_tmpl.c +++ b/src/parse/func_resolve_tmpl.c @@ -162,7 +162,7 @@ ANN static Func find_tmpl(const Env env, const Value v, Exp_Call *const exp, get_tmpl(v->from->owner_class) : NULL; if(tmpl) (void)template_push_types(env, tmpl); - const bool is_clos = isa(exp->func->type, env->gwion->type[et_closure]) > 0; + const bool is_clos = isa(exp->func->type, env->gwion->type[et_closure]); const Func m_func = !is_clos ? func_match(env, &ra) : fptr_match(env, &ra); if(tmpl) @@ -210,13 +210,6 @@ ANN static Func _find_template_match(const Env env, const Value v, return f; } -#undef ERR_B -#define ERR_B(a, b, ...) \ - { \ - env_err(env, (a), (b), ##__VA_ARGS__); \ - return false; \ - } - ANN static inline bool check_call(const Env env, const Exp_Call *exp) { const ae_exp_t et = exp->func->exp_type; if (et != ae_exp_primary && et != ae_exp_dot && et != ae_exp_cast) diff --git a/src/parse/operator.c b/src/parse/operator.c index b145b114..247db224 100644 --- a/src/parse/operator.c +++ b/src/parse/operator.c @@ -205,7 +205,7 @@ ANN2(1,2,3) bool _tmpl_match(const Env env, const Type t, Type_Decl *const td, if (!td->next && !td->types && op_template_type(td->tag.sym, sl)) return true; const Type base = known_type(env, td); - return base ? isa(t, base) > 0 : false; + return base ? isa(t, base) : false; } //! check Func_Base matches for template operator diff --git a/src/parse/partial.c b/src/parse/partial.c index 5db510d7..cc3a76a9 100644 --- a/src/parse/partial.c +++ b/src/parse/partial.c @@ -150,7 +150,7 @@ ANN static Func partial_match(const Env env, const Func up, Exp* args, const loc const Func next = partial_match(env, f->next, args, loc); if(next) { const Type tnext = next->value_ref->from->owner_class; - if(!t || !tnext || isa(t, tnext) < 0) { + if(!t || !tnext || !isa(t, tnext)) { gwerr_basic(_("can't resolve ambiguity"), _("in this partial application"), _("use typed holes: _ $ type"), env->name, loc, 0); gw_err(_("\nthose functions could match:\n")); print_signature(f); diff --git a/src/parse/scan0.c b/src/parse/scan0.c index ad21423c..c3f3a139 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -13,13 +13,6 @@ #include "spread.h" #include "emit.h" -#undef ERR_B -#define ERR_B(a, b, ...) \ - { \ - env_err(env, (a), (b), ##__VA_ARGS__); \ - return false; \ - } - static inline void add_type(const Env env, const Nspc nspc, const Type t) { nspc_add_type_front(nspc, insert_symbol(t->name), t); } @@ -57,7 +50,7 @@ ANN static inline bool scan0_global(const Env env, const ae_flag flag, *global = true; return true; } - ERR_B(loc, _("can't declare as global in class def")) + ERR_B(loc, _("can't declare as global in class def")); } ANN bool scan0_fptr_def(const Env env, const Fptr_Def fptr) { @@ -355,7 +348,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_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)) { + if(GET_FLAG(cdef, global) && !isa(parent, env->gwion->type[et_closure]) && !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); env_set_error(env, true); diff --git a/src/parse/scan1.c b/src/parse/scan1.c index a32f1ebd..83cdb98b 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -10,13 +10,6 @@ #include "instr.h" #include "import.h" -#undef ERR_B -#define ERR_B(a, b, ...) \ - { \ - env_err(env, (a), (b), ##__VA_ARGS__); \ - return false; \ - } - ANN static bool scan1_stmt_list(const Env env, Stmt_List list); ANN static bool scan1_stmt(const Env env, Stmt* stmt); @@ -47,7 +40,7 @@ ANN static inline bool ensure_scan1(const Env env, const Type t) { ANN static bool check_global(const Env env, const Type t, const loc_t loc) { const ValueFrom *from = t->info->value->from; - if(from->owner_class && isa(from->owner_class, env->class_def) > 0) + if(from->owner_class && isa(from->owner_class, env->class_def)) return true; if(from_global_nspc(env, from->owner) || (from->owner_class && type_global(env, from->owner_class))) @@ -83,7 +76,7 @@ ANN static Type scan1_exp_decl_type(const Env env, Exp_Decl *decl) { if (decl->var.td->tag.sym == insert_symbol("auto") && decl->type) return decl->type; if (GET_FLAG(t, private) && t->info->value->from->owner != env->curr) ERR_O(exp_self(decl)->loc, _("can't use private type %s"), t->name); - if (GET_FLAG(t, protect) && (!env->class_def || isa(t, env->class_def) < 0)) + if (GET_FLAG(t, protect) && (!env->class_def || !isa(t, env->class_def))) ERR_O(exp_self(decl)->loc, _("can't use protected type %s"), t->name); return t; } @@ -95,10 +88,10 @@ static inline bool scan1_defined(const Env env, const Var_Decl *var) { env->scope->depth) ? nspc_lookup_value1 : nspc_lookup_value2)(env->curr, var->tag.sym); - if(v && (!v->from->owner_class || isa(env->class_def, v->from->owner_class) > 0)) + if(v && (!v->from->owner_class || isa(env->class_def, v->from->owner_class))) ERR_B(var->tag.loc, _("variable %s has already been defined in the same scope..."), - s_name(var->tag.sym)) + s_name(var->tag.sym)); return true; } @@ -141,7 +134,7 @@ ANN static bool scan1_decl(const Env env, Exp_Decl *const decl) { set_vflag(v, vflag_member); if(tflag(t, tflag_release)) set_tflag(env->class_def, tflag_release); - if(isa(t, env->gwion->type[et_object]) > 0) + if(isa(t, env->gwion->type[et_object])) set_vflag(v, vflag_release); if (tflag(env->class_def, tflag_struct)) { v->from->offset = env->class_def->size; @@ -168,7 +161,7 @@ ANN bool scan1_exp_decl(const Env env, Exp_Decl *const decl) { if (global) { if (env->context) env->context->global = true; if (!type_global(env, decl->type)) - ERR_B(exp_self(decl)->loc, _("type '%s' is not global"), decl->type->name) + ERR_B(exp_self(decl)->loc, _("type '%s' is not global"), decl->type->name); } const m_uint scope = !global ? env->scope->depth : env_push_global(env); const bool ret = scan1_decl(env, decl); @@ -340,7 +333,7 @@ ANN static inline bool shadow_arg(const Env env, const Tag tag) { const Value v = nspc_lookup_value0(nspc, tag.sym); if (v && !env->func->def->builtin) { const Type owner = v->from->owner_class; - if (owner && env->class_def && isa(env->class_def, owner) < 0) + if (owner && env->class_def && !isa(env->class_def, owner)) continue; return shadow_err(env, v, tag.loc); } @@ -597,7 +590,7 @@ ANN bool scan1_union_def(const Env env, const Union_Def udef) { ANN static bool scan1_stmt_return(const Env env, const Stmt_Exp stmt) { if (!env->func) ERR_B(stmt_self(stmt)->loc, - _("'return' statement found outside function definition")) + _("'return' statement found outside function definition")); if (env->scope->depth == 1) env->func->memoize = 1; if(stmt->val) CHECK_B(scan1_exp(env, stmt->val)); return true; @@ -657,11 +650,11 @@ ANN static bool scan1_stmt_list(const Env env, Stmt_List l) { ANN static bool class_internal(const Env env, const Func_Base *base) { assert(base->td); if (!env->class_def) - ERR_B(base->td->tag.loc, _("'%s' must be in class def!!"), s_name(base->tag.sym)) + ERR_B(base->td->tag.loc, _("'%s' must be in class def!!"), s_name(base->tag.sym)); if (base->args) - ERR_B(base->td->tag.loc, _("'%s' must not have args"), s_name(base->tag.sym)) + ERR_B(base->td->tag.loc, _("'%s' must not have args"), s_name(base->tag.sym)); if (base->ret_type != env->gwion->type[et_void]) - ERR_B(base->td->tag.loc, _("'%s' must return 'void'"), s_name(base->tag.sym)) + ERR_B(base->td->tag.loc, _("'%s' must return 'void'"), s_name(base->tag.sym)); return true; } @@ -670,15 +663,15 @@ ANN static inline bool scan_internal_arg(const Env env, if (mp_vector_len(base->args) == 1) return true; assert(base->td); ERR_B(base->td->tag.loc, _("'%s' must have one (and only one) argument"), - s_name(base->tag.sym)) + s_name(base->tag.sym)); } ANN static inline bool scan_internal_int(const Env env, const Func_Base *base) { assert(base->td); CHECK_B(scan_internal_arg(env, base)); - if (isa(base->ret_type, env->gwion->type[et_int]) > 0) return true; - ERR_B(base->td->tag.loc, _("'%s' must return 'int'"), s_name(base->tag.sym)) + if (isa(base->ret_type, env->gwion->type[et_int])) return true; + ERR_B(base->td->tag.loc, _("'%s' must return 'int'"), s_name(base->tag.sym)); } ANN static bool scan_internal(const Env env, const Func_Base *base) { @@ -812,11 +805,11 @@ ANN static bool scan1_parent(const Env env, const Class_Def cdef) { if (cdef->base.ext->array && cdef->base.ext->array->exp) CHECK_B(scan1_exp(env, cdef->base.ext->array->exp)); DECL_B(const Type, parent, = scan1_get_parent(env, &cdef->base)); - if (isa(parent, env->gwion->type[et_object]) < 0 && + if (!isa(parent, env->gwion->type[et_object]) && // !(tflag(cdef->base.type, tflag_cdef) || tflag(cdef->base.type, tflag_udef))) !(tflag(cdef->base.type, tflag_cdef) || tflag(cdef->base.type, tflag_union))) - ERR_B(loc, _("cannot extend primitive type '%s'"), parent->name) - if (type_ref(parent)) ERR_B(loc, _("can't use ref type in class extend")) + ERR_B(loc, _("cannot extend primitive type '%s'"), parent->name); + if (type_ref(parent)) ERR_B(loc, _("can't use ref type in class extend")); return true; } @@ -836,8 +829,8 @@ ANN static bool cdef_parent(const Env env, const Class_Def cdef) { } ANN static bool scan1_class_def_body(const Env env, const Class_Def cdef) { - if(!tmpl_base(cdef->base.tmpl) && isa(cdef->base.type, env->gwion->type[et_closure]) < 0 && - isa(cdef->base.type, env->gwion->type[et_dict]) < 0) { + if(!tmpl_base(cdef->base.tmpl) && !isa(cdef->base.type, env->gwion->type[et_closure]) && + !isa(cdef->base.type, env->gwion->type[et_dict])) { MemPool mp = env->gwion->mp; Ast base = cdef->body; Stmt_List ctor = new_mp_vector(mp, Stmt, 0); diff --git a/src/parse/scan2.c b/src/parse/scan2.c index d9d066c9..91a77146 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -14,14 +14,6 @@ #include "spread.h" #include "closure.h" -#undef ERR_B -#define ERR_B(a, b, ...) \ - { \ - env_err(env, (a), (b), ##__VA_ARGS__); \ - return false; \ - } - - ANN static bool scan2_stmt(const Env, Stmt*); ANN static bool scan2_stmt_list(const Env, Stmt_List); @@ -294,7 +286,7 @@ ANN static bool scan2_func_def_overload(const Env env, const Func_Def f, if (!fbflag(f->base, fbflag_internal)) ERR_B(f->base->tag.loc, _("function name '%s' is already used by another value"), - overload->name) + overload->name); } const Func obase = overload->d.func_ref; if (GET_FLAG(obase->def->base, final) && (!env->class_def || (obase->value_ref->from->owner_class != env->class_def))) { @@ -305,9 +297,9 @@ ANN static bool scan2_func_def_overload(const Env env, const Func_Def f, const bool base = tmpl_base(f->base->tmpl); const bool tmpl = fflag(obase, fflag_tmpl); if ((!tmpl && base) || (tmpl && !base && !f->base->tmpl)) - ERR_B(f->base->tag.loc, _("must overload template function with template")) + ERR_B(f->base->tag.loc, _("must overload template function with template")); if (GET_FLAG(f->base, global) != GET_FLAG(obase->def->base, global)) - ERR_B(f->base->tag.loc, _("function is declared global")) // improve me + ERR_B(f->base->tag.loc, _("function is declared global")); // improve me return true; } @@ -391,7 +383,7 @@ static bool scan2_fdef_tmpl(const Env env, const Func_Def f, ERR_B(f->base->tag.loc, "template function '%s' already defined with those arguments " "in this namespace", - name) + name); const Symbol sym = func_symbol(env, env->curr->name, name, "template", ff->def->vt_index); nspc_add_value(env->curr, sym, value); diff --git a/src/parse/template.c b/src/parse/template.c index fdab36d4..369d19b5 100644 --- a/src/parse/template.c +++ b/src/parse/template.c @@ -105,7 +105,7 @@ ANN bool const_generic_typecheck(const Env env, const Specialized *spec, const T CHECK_B(check_exp(env, targ->d.exp)); // check implicits? const Type target = known_type(env, spec->td); - if(isa(targ->d.exp->type, target) < 0) { + if(!isa(targ->d.exp->type, target)) { char msg[256]; tcol_snprintf(msg, 255, "expected {G+}%s{0}", target->name); gwerr_basic("invalid type for const generic argument", msg, NULL, env->name, spec->tag.loc, 0); @@ -181,14 +181,6 @@ static ANN bool is_single_variadic(const MP_Vector *v) { return !strcmp(s_name(spec->tag.sym), "..."); } -#undef ERR_B -#define ERR_B(a, b, ...) \ - { \ - env_err(env, (a), (b), ##__VA_ARGS__); \ - return false; \ - } - - ANN2(1,2) bool check_tmpl(const Env env, const TmplArg_List tl, const Specialized_List sl, const loc_t loc, const bool is_spread) { if (!sl || sl->len > tl->len || (tl->len != sl->len && !is_spread)) ERR_B(loc, "invalid template type number"); diff --git a/src/pass.c b/src/pass.c index 529692cc..f43d479e 100644 --- a/src/pass.c +++ b/src/pass.c @@ -47,7 +47,7 @@ ANN bool pass_set(const Gwion gwion, const Vector passes) { /* if(!strcmp(name, "none")) { vector_clear(v); - return GW_OK; + return true; } */ gw_err("Failed to set compilation passes, back to default\n"); diff --git a/src/plug.c b/src/plug.c index c0d3809e..7d9b292b 100644 --- a/src/plug.c +++ b/src/plug.c @@ -232,7 +232,7 @@ ANN bool plugin_ini(struct Gwion_ *gwion, const m_str iname, const loc_t loc) { env_err(env, loc, "%s: no such plugin\n", iname); return false; } - return GW_OK; + return true; } ANN gwdriver_t driver_ini(const struct Gwion_ *gwion, struct SoundInfo_ *si) { diff --git a/src/vm/gack.c b/src/vm/gack.c index 64cd6a0d..e521b1f9 100644 --- a/src/vm/gack.c +++ b/src/vm/gack.c @@ -12,7 +12,7 @@ #include "import.h" #include "gack.h" -ANN2(1) static int fmtlen(const char *fmt, va_list args) { +ANN2(1) static ssize_t fmtlen(const char *fmt, va_list args) { va_list tmpa; va_copy(tmpa, args); const int size = vsnprintf(NULL, 0, fmt, tmpa); @@ -24,7 +24,8 @@ ANN2(2) static int gw_vasprintf(MemPool mp, char **str, const char *fmt, va_list args) { char * base = *str; const size_t base_len = base ? strlen(base) : 0; - DECL_BB(const int, size, = fmtlen(fmt, args)); + const int size = fmtlen(fmt, args); + if(size < 0) return -1; char *ret = mp_malloc2(mp, base_len + size + 1); if (base) strcpy(ret, base); const int final_len = vsprintf(ret + base_len, fmt, args); diff --git a/tests/driver/non_driver.c b/tests/driver/non_driver.c index edce9916..22ff136e 100644 --- a/tests/driver/non_driver.c +++ b/tests/driver/non_driver.c @@ -10,5 +10,5 @@ GWION_IMPORT(non_driver) { (void)gwi; - return GW_OK; + return true; } diff --git a/tests/module/get_module.c b/tests/module/get_module.c index f3224fa8..eaf6ba91 100644 --- a/tests/module/get_module.c +++ b/tests/module/get_module.c @@ -19,9 +19,9 @@ GWMODINI(get_module) { GWMODEND(get_module) { puts(__func__); } GWION_IMPORT(get_module) { - CHECK_b(set_module(gwi->gwion, "get_module", (void *)1)); - GWI_OB(get_module(gwi->gwion, "get_module")) + CHECK_B(set_module(gwi->gwion, "get_module", (void *)1)); + GWI_B(get_module(gwi->gwion, "get_module")) puts("test passed"); get_module(gwi->gwion, "non_existant_module"); - return GW_OK; + return true; } diff --git a/tests/plug/array.c b/tests/plug/array.c index 6988b4c1..a262e56e 100644 --- a/tests/plug/array.c +++ b/tests/plug/array.c @@ -12,13 +12,13 @@ MFUN(test_mfun) {} GWION_IMPORT(array) { - GWI_OB(gwi_class_ini(gwi, "ArrayTest", NULL)) - GWI_BB(gwi_item_ini(gwi, "int[]", "int_array")) - GWI_BB(gwi_item_end(gwi, 0, obj, NULL)) // import array var + GWI_B(gwi_class_ini(gwi, "ArrayTest", NULL)) + GWI_B(gwi_item_ini(gwi, "int[]", "int_array")) + GWI_B(gwi_item_end(gwi, 0, obj, NULL)) // import array var GWI_B(gwi_func_ini(gwi, "float[][]", "f")) GWI_B(gwi_func_end(gwi, test_mfun, ae_flag_none)) GWI_B(gwi_func_ini(gwi, "float[][]", "g")) GWI_B(gwi_func_end(gwi, test_mfun, ae_flag_none)) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/array_in_var_name.c b/tests/plug/array_in_var_name.c index 995a8ee4..0f994435 100644 --- a/tests/plug/array_in_var_name.c +++ b/tests/plug/array_in_var_name.c @@ -11,5 +11,5 @@ GWION_IMPORT(array_in_var_name) { gwi_item_ini(gwi, "int", "array[2][3]"); - return GW_OK; + return true; } diff --git a/tests/plug/array_in_var_name_fail.c b/tests/plug/array_in_var_name_fail.c index e728a77b..3b25bcf4 100644 --- a/tests/plug/array_in_var_name_fail.c +++ b/tests/plug/array_in_var_name_fail.c @@ -12,5 +12,5 @@ GWION_IMPORT(array_in_var_name_fail) { GWI_B(gwi_union_ini(gwi, "U")) GWI_B(gwi_union_add(gwi, "int", "i")) - return GW_OK; + return true; } diff --git a/tests/plug/array_incoherent_in_var_name.c b/tests/plug/array_incoherent_in_var_name.c index 1cbd95ae..1f6d7504 100644 --- a/tests/plug/array_incoherent_in_var_name.c +++ b/tests/plug/array_incoherent_in_var_name.c @@ -11,5 +11,5 @@ GWION_IMPORT(array_incoherent_in_var_name) { gwi_item_ini(gwi, "int", "array[2][3][]"); - return GW_OK; + return true; } diff --git a/tests/plug/array_invalid_in_var_name.c b/tests/plug/array_invalid_in_var_name.c index 5ad58b8c..1652daae 100644 --- a/tests/plug/array_invalid_in_var_name.c +++ b/tests/plug/array_invalid_in_var_name.c @@ -11,5 +11,5 @@ GWION_IMPORT(array_invalid_in_var_name) { gwi_item_ini(gwi, "int", "array[.]"); - return GW_OK; + return true; } diff --git a/tests/plug/callback.c b/tests/plug/callback.c index 4109bcef..aa4b4e56 100644 --- a/tests/plug/callback.c +++ b/tests/plug/callback.c @@ -66,12 +66,12 @@ static SFUN(cb_func) { GWION_IMPORT(callback) { GWI_B(gwi_fptr_ini(gwi, "Vec4", "PtrType")) - GWI_OB(gwi_fptr_end(gwi, 0)) + GWI_B(gwi_fptr_end(gwi, 0)) - GWI_OB(gwi_class_ini(gwi, "Callback", NULL)) + GWI_B(gwi_class_ini(gwi, "Callback", NULL)) GWI_B(gwi_func_ini(gwi, "int", "callback")) GWI_B(gwi_func_arg(gwi, "PtrType", "func")) GWI_B(gwi_func_end(gwi, cb_func, ae_flag_static)) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/class_template.c b/tests/plug/class_template.c index 3b586118..c6dce35e 100644 --- a/tests/plug/class_template.c +++ b/tests/plug/class_template.c @@ -9,10 +9,6 @@ #include "import.h" #include "gwi.h" -static m_int o_map_key; -static m_int o_map_value; -#define MAP_KEY(a) *((M_Object *)(a->data + o_map_key)) -#define MAP_VAL(a) *((M_Object *)(a->data + o_map_value)) static CTOR(class_template_ctor) { /*char* name = strdup(o->type_ref->name);*/ /*char* tmp = strsep(&name, "@");*/ @@ -27,17 +23,17 @@ static CTOR(class_template_ctor) { } GWION_IMPORT(class_template) { - GWI_OB(gwi_class_ini(gwi, ":[A,B]ClassTemplate", NULL)) + GWI_B(gwi_class_ini(gwi, ":[A,B]ClassTemplate", NULL)); gwi_class_xtor(gwi, class_template_ctor, NULL); - GWI_BB(gwi_item_ini(gwi, "A[]", "key")) - GWI_BB((o_map_key = gwi_item_end(gwi, ae_flag_none, obj, NULL))) - GWI_BB(gwi_item_ini(gwi, "B[]", "value")) - GWI_BB((o_map_value = gwi_item_end(gwi, ae_flag_none, obj, NULL))) - GWI_B(gwi_func_ini(gwi, "int", ":[C,D]test")) - GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none)) + GWI_B(gwi_item_ini(gwi, "A[]", "key")); + GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL)); + GWI_B(gwi_item_ini(gwi, "B[]", "value")); + GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL)); + GWI_B(gwi_func_ini(gwi, "int", ":[C,D]test")); + GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none)); - GWI_B(gwi_class_end(gwi)) - GWI_BB(gwi_item_ini(gwi, ":[:[int]Ptr,int[]]ClassTemplate", "testObject")) - GWI_BB(gwi_item_end(gwi, ae_flag_none, obj, NULL)) - return GW_OK; + GWI_B(gwi_class_end(gwi)); + GWI_B(gwi_item_ini(gwi, ":[:[int]Ptr,int[]]ClassTemplate", "testObject")); + GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL)); + return true; } diff --git a/tests/plug/class_template_fail.c b/tests/plug/class_template_fail.c index 06ad7e54..0a88e582 100644 --- a/tests/plug/class_template_fail.c +++ b/tests/plug/class_template_fail.c @@ -10,9 +10,9 @@ #include "gwi.h" GWION_IMPORT(class_template_fail) { - GWI_OB(gwi_class_ini(gwi, ":[A,B]ClassTemplate", NULL)) + GWI_B(gwi_class_ini(gwi, ":[A,B]ClassTemplate", NULL)) GWI_B(gwi_func_ini(gwi, "int", "test")) GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none)) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/class_template_invalid.c b/tests/plug/class_template_invalid.c index 92ed1b6c..ae6a681f 100644 --- a/tests/plug/class_template_invalid.c +++ b/tests/plug/class_template_invalid.c @@ -9,22 +9,17 @@ #include "import.h" #include "gwi.h" -static m_int o_map_key; -static m_int o_map_value; -#define MAP_KEY(a) *((M_Object *)(a->data + o_map_key)) -#define MAP_VAL(a) *((M_Object *)(a->data + o_map_value)) - GWION_IMPORT(class_template_invalid) { - GWI_OB(gwi_class_ini(gwi, "ClassTemplate:[A,B]", NULL)) - GWI_BB(gwi_item_ini(gwi, "A[]", "key")) - GWI_BB((o_map_key = gwi_item_end(gwi, ae_flag_none, obj, NULL))) - GWI_BB(gwi_item_ini(gwi, "B[]", "value")) - GWI_BB((o_map_value = gwi_item_end(gwi, ae_flag_none, obj, NULL))) - GWI_B(gwi_func_ini(gwi, "int", "test:[C,D]")) - GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none)) + GWI_B(gwi_class_ini(gwi, "ClassTemplate:[A,B]", NULL)); + GWI_B(gwi_item_ini(gwi, "A[]", "key")); + GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL)); + GWI_B(gwi_item_ini(gwi, "B[]", "value")); + GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL)); + GWI_B(gwi_func_ini(gwi, "int", "test:[C,D]")); + GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none)); - GWI_B(gwi_class_end(gwi)) - GWI_BB(gwi_item_ini(gwi, "ClassTemplate:[:[int]Ptr,int[]]", "testObject")) - GWI_BB(gwi_item_end(gwi, ae_flag_none, obj, NULL)) - return GW_OK; + GWI_B(gwi_class_end(gwi)); + GWI_B(gwi_item_ini(gwi, "ClassTemplate:[:[int]Ptr,int[]]", "testObject")); + GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL)); + return true; } diff --git a/tests/plug/compile_file.c b/tests/plug/compile_file.c index ddd76fed..8b5a404a 100644 --- a/tests/plug/compile_file.c +++ b/tests/plug/compile_file.c @@ -12,7 +12,7 @@ #include GWION_IMPORT(compile_file) { - DECL_OB(FILE *, file, = fopen("rm_me.gw", "w+")); + DECL_B(FILE *, file, = fopen("rm_me.gw", "w+")); if(fprintf(file, "1;") >= 0) { rewind(file); const bool ret = compile_file(gwi->gwion, __FILE__, file); diff --git a/tests/plug/coverage.c b/tests/plug/coverage.c index dc7da459..6a00c8e2 100644 --- a/tests/plug/coverage.c +++ b/tests/plug/coverage.c @@ -13,27 +13,27 @@ SFUN(coverage_int) { *(m_uint *)RETURN = 0; } SFUN(coverage_float) { *(m_float *)RETURN = 0; } GWION_IMPORT(coverage) { - GWI_OB(gwi_class_ini(gwi, "Coverage", NULL)) + GWI_B(gwi_class_ini(gwi, "Coverage", NULL)) GWI_B(gwi_func_ini(gwi, "int", "i")) GWI_B(gwi_func_end(gwi, coverage_int, ae_flag_static)) GWI_B(gwi_func_ini(gwi, "float", "f")) GWI_B(gwi_func_end(gwi, coverage_float, ae_flag_static)) - GWI_BB(gwi_item_ini(gwi, "int", "s_i")) - GWI_BB(gwi_item_end(gwi, ae_flag_static, num, 5)) + GWI_B(gwi_item_ini(gwi, "int", "s_i")) + GWI_B(gwi_item_end(gwi, ae_flag_static, num, 5)) - GWI_BB(gwi_item_ini(gwi, "float", "s_f")) - GWI_BB(gwi_item_end(gwi, ae_flag_static, fnum, 2.1)) + GWI_B(gwi_item_ini(gwi, "float", "s_f")) + GWI_B(gwi_item_end(gwi, ae_flag_static, fnum, 2.1)) - GWI_BB(gwi_item_ini(gwi, "int", "sc_i")) - GWI_BB(gwi_item_end(gwi, ae_flag_static | ae_flag_const, num, 5)) + GWI_B(gwi_item_ini(gwi, "int", "sc_i")) + GWI_B(gwi_item_end(gwi, ae_flag_static | ae_flag_const, num, 5)) - GWI_BB(gwi_item_ini(gwi, "float", "sc_f")) - GWI_BB(gwi_item_end(gwi, ae_flag_static | ae_flag_const, fnum, 2.1)) + GWI_B(gwi_item_ini(gwi, "float", "sc_f")) + GWI_B(gwi_item_end(gwi, ae_flag_static | ae_flag_const, fnum, 2.1)) - GWI_BB(gwi_item_ini(gwi, "int[][]", "test_array")) - GWI_BB(gwi_item_end(gwi, ae_flag_none, obj, NULL)) + GWI_B(gwi_item_ini(gwi, "int[][]", "test_array")) + GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL)) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/deps.c b/tests/plug/deps.c index d614ea95..93e0fb1c 100644 --- a/tests/plug/deps.c +++ b/tests/plug/deps.c @@ -11,7 +11,7 @@ GWION_IMPORT(deps) { (void)gwi; - return GW_OK; + return true; } static const m_str deps[] = {"array", NULL}; diff --git a/tests/plug/empty_union.c b/tests/plug/empty_union.c index 90b5986f..fd7ce7e3 100644 --- a/tests/plug/empty_union.c +++ b/tests/plug/empty_union.c @@ -11,5 +11,5 @@ GWION_IMPORT(empty_union) { GWI_B(gwi_union_ini(gwi, "U")) GWI_B(gwi_union_end(gwi, 0)) - return GW_OK; + return true; } diff --git a/tests/plug/end_class.c b/tests/plug/end_class.c index 8a2c7893..c5f0544e 100644 --- a/tests/plug/end_class.c +++ b/tests/plug/end_class.c @@ -11,5 +11,5 @@ MFUN(test_mfun) {} GWION_IMPORT(end_class) { GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/enum.c b/tests/plug/enum.c index 4cafdecd..c1fada83 100644 --- a/tests/plug/enum.c +++ b/tests/plug/enum.c @@ -20,9 +20,9 @@ GWION_IMPORT(enum) { GWI_B(gwi_enum_add(gwi, "TYPED_ENUM7", 7)) GWI_B(gwi_enum_add(gwi, "TYPED_ENUM8", 8)) GWI_B(gwi_enum_add(gwi, "TYPED_ENUM9", 9)) - GWI_OB(gwi_enum_end(gwi)) + GWI_B(gwi_enum_end(gwi)) - GWI_OB(gwi_class_end(gwi)) + GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/enum_fail.c b/tests/plug/enum_fail.c index db1b67cb..2d5a9cc3 100644 --- a/tests/plug/enum_fail.c +++ b/tests/plug/enum_fail.c @@ -11,6 +11,6 @@ GWION_IMPORT(enum_fail) { GWI_B(gwi_enum_ini(gwi, "int")) GWI_B(gwi_enum_add(gwi, "zero", 0)) - GWI_OB(gwi_enum_end(gwi)) - return GW_OK; + GWI_B(gwi_enum_end(gwi)) + return true; } diff --git a/tests/plug/enum_fail2.c b/tests/plug/enum_fail2.c index ee0d9849..c1408faf 100644 --- a/tests/plug/enum_fail2.c +++ b/tests/plug/enum_fail2.c @@ -11,6 +11,6 @@ GWION_IMPORT(enum_fail2) { GWI_B(gwi_enum_ini(gwi, "tmp")) GWI_B(gwi_enum_add(gwi, "adc", 0)) - GWI_OB(gwi_enum_end(gwi)) - return GW_OK; + GWI_B(gwi_enum_end(gwi)) + return true; } diff --git a/tests/plug/enum_fail3.c b/tests/plug/enum_fail3.c index eed36eff..dc4b67ac 100644 --- a/tests/plug/enum_fail3.c +++ b/tests/plug/enum_fail3.c @@ -12,5 +12,5 @@ GWION_IMPORT(enum_fail3) { GWI_B(gwi_enum_ini(gwi, "test")) GWI_B(gwi_enum_add(gwi, "adc", 0)) GWI_B(gwi_enum_ini(gwi, "error")) - return GW_OK; + return true; } diff --git a/tests/plug/extend_array.c b/tests/plug/extend_array.c index b7603875..3688c55f 100644 --- a/tests/plug/extend_array.c +++ b/tests/plug/extend_array.c @@ -11,7 +11,7 @@ #include "gwi.h" GWION_IMPORT(extend_array) { - GWI_OB(gwi_class_ini(gwi, "ArrayExt", "float[1]")) + GWI_B(gwi_class_ini(gwi, "ArrayExt", "float[1]")) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/fptr.c b/tests/plug/fptr.c index aa99f196..74b0e1ae 100644 --- a/tests/plug/fptr.c +++ b/tests/plug/fptr.c @@ -11,15 +11,15 @@ static MFUN(test_func) { puts("test"); } GWION_IMPORT(fptr) { GWI_B(gwi_fptr_ini(gwi, "void", "PtrType")) - GWI_OB(gwi_fptr_end(gwi, 0)) + GWI_B(gwi_fptr_end(gwi, 0)) - GWI_OB(gwi_class_ini(gwi, "FuncTypedef", NULL)) + GWI_B(gwi_class_ini(gwi, "FuncTypedef", NULL)) GWI_B(gwi_fptr_ini(gwi, "void", "PtrType")) - GWI_OB(gwi_fptr_end(gwi, ae_flag_static)) + GWI_B(gwi_fptr_end(gwi, ae_flag_static)) GWI_B(gwi_func_ini(gwi, "void", "test_func")) GWI_B(gwi_func_end(gwi, test_func, ae_flag_static)) - GWI_BB(gwi_item_ini(gwi, "PtrType", "ptr")) - GWI_BB(gwi_item_end(gwi, ae_flag_static, obj, NULL)) + GWI_B(gwi_item_ini(gwi, "PtrType", "ptr")) + GWI_B(gwi_item_end(gwi, ae_flag_static, obj, NULL)) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/fptr_tmpl.c b/tests/plug/fptr_tmpl.c index cd7bfce3..c50ad9ec 100644 --- a/tests/plug/fptr_tmpl.c +++ b/tests/plug/fptr_tmpl.c @@ -10,8 +10,8 @@ GWION_IMPORT(fptr_tmpl) { Type t_func_typedef; - GWI_OB((t_func_typedef = gwi_mk_type(gwi, "FuncTypedef", SZ_INT, NULL))) + GWI_B((t_func_typedef = gwi_mk_type(gwi, "FuncTypedef", SZ_INT, NULL))) GWI_B(gwi_fptr_ini(gwi, "int", "test:[test]")) - GWI_OB(gwi_fptr_end(gwi, 0)) - return GW_OK; + GWI_B(gwi_fptr_end(gwi, 0)) + return true; } diff --git a/tests/plug/fptr_tmpl_fail.c b/tests/plug/fptr_tmpl_fail.c index 5fad173e..ee21c746 100644 --- a/tests/plug/fptr_tmpl_fail.c +++ b/tests/plug/fptr_tmpl_fail.c @@ -10,6 +10,6 @@ GWION_IMPORT(fptr_tmpl_fail) { GWI_B(gwi_fptr_ini(gwi, "int~", "test:[A]")) - GWI_OB(gwi_fptr_end(gwi, 0)) - return GW_OK; + GWI_B(gwi_fptr_end(gwi, 0)) + return true; } diff --git a/tests/plug/func_fail.c b/tests/plug/func_fail.c index 20bf9599..f9a0b129 100644 --- a/tests/plug/func_fail.c +++ b/tests/plug/func_fail.c @@ -14,5 +14,5 @@ GWION_IMPORT(func_fail) { GWI_B(gwi_func_arg(gwi, "int", "i[][]")) GWI_B(gwi_func_arg(gwi, "Int", "i")) GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none)) - return GW_OK; + return true; } diff --git a/tests/plug/func_fail2.c b/tests/plug/func_fail2.c index a50a045a..e2d2aa73 100644 --- a/tests/plug/func_fail2.c +++ b/tests/plug/func_fail2.c @@ -14,5 +14,5 @@ GWION_IMPORT(func_fail2) { GWI_B(gwi_func_arg(gwi, "int", "i[][]")) GWI_B(gwi_func_arg(gwi, "int", "me")) GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none)) - return GW_OK; + return true; } diff --git a/tests/plug/func_fail3.c b/tests/plug/func_fail3.c index 4cd99ff5..fc137f4b 100644 --- a/tests/plug/func_fail3.c +++ b/tests/plug/func_fail3.c @@ -14,5 +14,5 @@ GWION_IMPORT(func_fail3) { GWI_B(gwi_func_ini(gwi, "int", "test")) GWI_B(gwi_func_arg(gwi, "int", "i[][]")) GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none)) - return GW_OK; + return true; } diff --git a/tests/plug/func_fail4.c b/tests/plug/func_fail4.c index 31800271..191e8390 100644 --- a/tests/plug/func_fail4.c +++ b/tests/plug/func_fail4.c @@ -12,6 +12,6 @@ GWION_IMPORT(func_fail4) { GWI_B(gwi_func_ini(gwi, "Ptr:[int]", "test:[A]")) GWI_B(gwi_func_arg(gwi, "int", "i[][]")) - GWI_BB(gwi_item_end(gwi, ae_flag_none, num, 0)) - return GW_OK; + GWI_B(gwi_item_end(gwi, ae_flag_none, num, 0)) + return true; } diff --git a/tests/plug/func_subscript_not_empty.c b/tests/plug/func_subscript_not_empty.c index 3ae715a1..4117624b 100644 --- a/tests/plug/func_subscript_not_empty.c +++ b/tests/plug/func_subscript_not_empty.c @@ -12,5 +12,5 @@ GWION_IMPORT(func_subscript_not_empty) { GWI_B(gwi_func_ini(gwi, "int[]", "test")) GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none)) - return GW_OK; + return true; } diff --git a/tests/plug/func_tmpl.c b/tests/plug/func_tmpl.c index 8e6f13c4..c434fa88 100644 --- a/tests/plug/func_tmpl.c +++ b/tests/plug/func_tmpl.c @@ -15,5 +15,5 @@ GWION_IMPORT(func_tmpl) { GWI_B(gwi_func_ini(gwi, "int", "test:[A]")) GWI_B(gwi_func_arg(gwi, "A", "i")) GWI_B(gwi_func_end(gwi, func_tmpl_xfun, ae_flag_none)) - return GW_OK; + return true; } diff --git a/tests/plug/func_tmpl_fail.c b/tests/plug/func_tmpl_fail.c index 803f7a8c..d4360919 100644 --- a/tests/plug/func_tmpl_fail.c +++ b/tests/plug/func_tmpl_fail.c @@ -14,5 +14,5 @@ static SFUN(func_tmpl_xfun) {} GWION_IMPORT(func_tmpl_fail) { GWI_B(gwi_func_ini(gwi, "voit", "test:[A]")) GWI_B(gwi_func_end(gwi, func_tmpl_xfun, ae_flag_none)) - return GW_OK; + return true; } diff --git a/tests/plug/func_too_many_arg.c b/tests/plug/func_too_many_arg.c index 98641d27..a7c26c86 100644 --- a/tests/plug/func_too_many_arg.c +++ b/tests/plug/func_too_many_arg.c @@ -30,5 +30,5 @@ GWION_IMPORT(func_too_many_arg) { GWI_B(gwi_func_arg(gwi, "int", "y")) GWI_B(gwi_func_arg(gwi, "int", "z")) GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none)) - return GW_OK; + return true; } diff --git a/tests/plug/global_func.c b/tests/plug/global_func.c index f5e8e392..74d0de51 100644 --- a/tests/plug/global_func.c +++ b/tests/plug/global_func.c @@ -18,5 +18,5 @@ GWION_IMPORT(global_func) { GWI_B(gwi_func_ini(gwi, "int", "test")) GWI_B(gwi_func_arg(gwi, "int", "i")) GWI_B(gwi_func_end(gwi, coverage_int, ae_flag_none)) - return GW_OK; + return true; } diff --git a/tests/plug/global_var.c b/tests/plug/global_var.c index fee9f063..46afa804 100644 --- a/tests/plug/global_var.c +++ b/tests/plug/global_var.c @@ -13,9 +13,9 @@ GWION_IMPORT(global_var) { const M_Object o = new_object(gwi->gwion->mp, gwi->gwion->type[et_string]); STRING(o) = s_name(insert_symbol(gwi->gwion->st, "test")); - GWI_BB(gwi_item_ini(gwi, "string", "i")) - GWI_BB(gwi_item_end(gwi, 0, obj, o)) - GWI_BB(gwi_item_ini(gwi, "float", "f")) - GWI_BB(gwi_item_end(gwi, 0, fnum, 2.1)) - return GW_OK; + GWI_B(gwi_item_ini(gwi, "string", "i")) + GWI_B(gwi_item_end(gwi, 0, obj, o)) + GWI_B(gwi_item_ini(gwi, "float", "f")) + GWI_B(gwi_item_end(gwi, 0, fnum, 2.1)) + return true; } diff --git a/tests/plug/invalid_arg.c b/tests/plug/invalid_arg.c index a52a33e5..da324ea4 100644 --- a/tests/plug/invalid_arg.c +++ b/tests/plug/invalid_arg.c @@ -10,10 +10,10 @@ static MFUN(test_mfun) {} GWION_IMPORT(invalid_arg) { - GWI_OB(gwi_class_ini(gwi, "InvalidArg", NULL)) + GWI_B(gwi_class_ini(gwi, "InvalidArg", NULL)) GWI_B(gwi_func_ini(gwi, "int[]", "func")) GWI_B(gwi_func_arg(gwi, ".int", "i")) GWI_B(gwi_func_end(gwi, test_mfun, ae_flag_static)) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/invalid_array.c b/tests/plug/invalid_array.c index 6763bd96..10317c60 100644 --- a/tests/plug/invalid_array.c +++ b/tests/plug/invalid_array.c @@ -10,7 +10,7 @@ static MFUN(test_mfun) {} GWION_IMPORT(invalid_array) { - GWI_OB(gwi_class_ini(gwi, "InvalidArray", NULL)) + GWI_B(gwi_class_ini(gwi, "InvalidArray", NULL)) GWI_B(gwi_func_ini(gwi, "int[]", "func")) GWI_B(gwi_func_arg(gwi, "int[][]", "i")) GWI_B(gwi_func_arg(gwi, "int", "j[]")) @@ -30,5 +30,5 @@ GWION_IMPORT(invalid_array) { GWI_B(gwi_func_end(gwi, test_mfun, ae_flag_static)) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/invalid_func.c b/tests/plug/invalid_func.c index 171f3915..67fddb61 100644 --- a/tests/plug/invalid_func.c +++ b/tests/plug/invalid_func.c @@ -10,10 +10,10 @@ static MFUN(test_mfun) {} GWION_IMPORT(invalid_func) { - GWI_OB(gwi_class_ini(gwi, "t_invalid_var_type", NULL)) + GWI_B(gwi_class_ini(gwi, "t_invalid_var_type", NULL)) GWI_B(gwi_func_ini(gwi, ".int", "i")) GWI_B(gwi_func_end(gwi, test_mfun, ae_flag_static)) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/invalid_names.c b/tests/plug/invalid_names.c index bda333ee..58aa719a 100644 --- a/tests/plug/invalid_names.c +++ b/tests/plug/invalid_names.c @@ -11,7 +11,7 @@ #include "gwi.h" GWION_IMPORT(invalid_names) { - DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T~", SZ_INT, NULL)); + DECL_B(const Type, t0, = gwi_mk_type(gwi, "T~", SZ_INT, NULL)); gwi_add_type(gwi, t0); const Type t1 = gwi_mk_type(gwi, "T,", SZ_INT, NULL); @@ -23,5 +23,5 @@ GWION_IMPORT(invalid_names) { const Type t3 = gwi_mk_type(gwi, "T:[a]", SZ_INT, NULL); gwi_add_type(gwi, t3); - return GW_OK; + return true; } diff --git a/tests/plug/invalid_names0.c b/tests/plug/invalid_names0.c index 7f138d54..4fcb19c4 100644 --- a/tests/plug/invalid_names0.c +++ b/tests/plug/invalid_names0.c @@ -11,7 +11,7 @@ #include "gwi.h" GWION_IMPORT(invalid_names0) { - DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T~", SZ_INT, NULL)); + DECL_B(const Type, t0, = gwi_mk_type(gwi, "T~", SZ_INT, NULL)); gwi_add_type(gwi, t0); - return GW_OK; + return true; } diff --git a/tests/plug/invalid_names1.c b/tests/plug/invalid_names1.c index f795e9f2..a4cd2635 100644 --- a/tests/plug/invalid_names1.c +++ b/tests/plug/invalid_names1.c @@ -11,7 +11,7 @@ #include "gwi.h" GWION_IMPORT(invalid_names1) { - DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T,", SZ_INT, NULL)); + DECL_B(const Type, t0, = gwi_mk_type(gwi, "T,", SZ_INT, NULL)); gwi_add_type(gwi, t0); - return GW_OK; + return true; } diff --git a/tests/plug/invalid_names2.c b/tests/plug/invalid_names2.c index 19ff0d83..9f32d959 100644 --- a/tests/plug/invalid_names2.c +++ b/tests/plug/invalid_names2.c @@ -11,7 +11,7 @@ #include "gwi.h" GWION_IMPORT(invalid_names2) { - DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T", SZ_INT, NULL)); + DECL_B(const Type, t0, = gwi_mk_type(gwi, "T", SZ_INT, NULL)); gwi_add_type(gwi, t0); - return GW_OK; + return true; } diff --git a/tests/plug/invalid_names3.c b/tests/plug/invalid_names3.c index 59426ea6..2c22c7f5 100644 --- a/tests/plug/invalid_names3.c +++ b/tests/plug/invalid_names3.c @@ -11,7 +11,7 @@ #include "gwi.h" GWION_IMPORT(invalid_names3) { - DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T:[a]", SZ_INT, NULL)); + DECL_B(const Type, t0, = gwi_mk_type(gwi, "T:[a]", SZ_INT, NULL)); gwi_add_type(gwi, t0); - return GW_OK; + return true; } diff --git a/tests/plug/invalid_type1.c b/tests/plug/invalid_type1.c index c5041b0d..0148638f 100644 --- a/tests/plug/invalid_type1.c +++ b/tests/plug/invalid_type1.c @@ -9,9 +9,9 @@ #include "import.h" GWION_IMPORT(invalid_type1) { - GWI_OB(gwi_class_ini(gwi, "invalid_var_type", NULL)) - GWI_BB(gwi_item_ini(gwi, "i|nt", "test")) - GWI_BB(gwi_item_end(gwi, 0, num, 0)) + GWI_B(gwi_class_ini(gwi, "invalid_var_type", NULL)) + GWI_B(gwi_item_ini(gwi, "i|nt", "test")) + GWI_B(gwi_item_end(gwi, 0, num, 0)) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/invalid_type2.c b/tests/plug/invalid_type2.c index 25051228..0b5bcb8d 100644 --- a/tests/plug/invalid_type2.c +++ b/tests/plug/invalid_type2.c @@ -9,9 +9,9 @@ #include "import.h" GWION_IMPORT(invalid_type2) { - GWI_OB(gwi_class_ini(gwi, "invalid_var_type", NULL)) - GWI_BB(gwi_item_ini(gwi, ".int", "test")) - GWI_BB(gwi_item_end(gwi, 0, num, 0)) + GWI_B(gwi_class_ini(gwi, "invalid_var_type", NULL)) + GWI_B(gwi_item_ini(gwi, ".int", "test")) + GWI_B(gwi_item_end(gwi, 0, num, 0)) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/invalid_type3.c b/tests/plug/invalid_type3.c index 884498e8..cb50af4d 100644 --- a/tests/plug/invalid_type3.c +++ b/tests/plug/invalid_type3.c @@ -9,9 +9,9 @@ #include "import.h" GWION_IMPORT(invalid_type3) { - GWI_OB(gwi_class_ini(gwi, "InvalidVarType", NULL)) - GWI_BB(gwi_item_ini(gwi, ".int", "test")) - GWI_BB(gwi_item_end(gwi, 0, num, 0)) + GWI_B(gwi_class_ini(gwi, "InvalidVarType", NULL)) + GWI_B(gwi_item_ini(gwi, ".int", "test")) + GWI_B(gwi_item_end(gwi, 0, num, 0)) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/mk_type_array.c b/tests/plug/mk_type_array.c index cd2dd528..a3bf4c9a 100644 --- a/tests/plug/mk_type_array.c +++ b/tests/plug/mk_type_array.c @@ -12,7 +12,7 @@ MFUN(test_mfun) {} GWION_IMPORT(mk_type_array) { Type t_invalid_var_name; - GWI_OB((t_invalid_var_name = + GWI_B((t_invalid_var_name = gwi_mk_type(gwi, "invalid_var_name", SZ_INT, "Object[]"))) - return GW_OK; + return true; } diff --git a/tests/plug/not_importing.c b/tests/plug/not_importing.c index 3837c3cf..ab0282a8 100644 --- a/tests/plug/not_importing.c +++ b/tests/plug/not_importing.c @@ -10,5 +10,5 @@ GWION_IMPORT(not_importing) { GWI_B(gwi_enum_add(gwi, "adc", 0)) - return GW_OK; + return true; } diff --git a/tests/plug/pass.c b/tests/plug/pass.c index 2d320eb6..a7b4afa7 100644 --- a/tests/plug/pass.c +++ b/tests/plug/pass.c @@ -13,5 +13,5 @@ ANN static bool pass(Env nv NUSED, Ast *ast NUSED) { return true; } GWION_IMPORT(pass) { gwi_register_pass(gwi, "dummy", pass); - return GW_OK; + return true; } diff --git a/tests/plug/specialid_emit.c b/tests/plug/specialid_emit.c index 762fc8fa..fdbd12de 100644 --- a/tests/plug/specialid_emit.c +++ b/tests/plug/specialid_emit.c @@ -21,5 +21,5 @@ GWION_IMPORT(specialid_emit) { struct SpecialId_ spid = { .type = gwi->gwion->type[et_int], .em = spidem, .is_const = 1}; gwi_specialid(gwi, "testid", &spid); - return GW_OK; + return true; } diff --git a/tests/plug/static_string.c b/tests/plug/static_string.c index 2f7d6f46..04f7bcef 100644 --- a/tests/plug/static_string.c +++ b/tests/plug/static_string.c @@ -13,7 +13,7 @@ GWION_IMPORT(static_string) { const M_Object o = new_object(gwi->gwion->mp, gwi->gwion->type[et_string]); STRING(o) = s_name(insert_symbol(gwi->gwion->st, "test static string")); - GWI_BB(gwi_item_ini(gwi, "string", "self")) - GWI_BB(gwi_item_end(gwi, ae_flag_global, obj, o)) - return GW_OK; + GWI_B(gwi_item_ini(gwi, "string", "self")) + GWI_B(gwi_item_end(gwi, ae_flag_global, obj, o)) + return true; } diff --git a/tests/plug/str2decl.c b/tests/plug/str2decl.c index 343ea77c..9b52fc46 100644 --- a/tests/plug/str2decl.c +++ b/tests/plug/str2decl.c @@ -11,10 +11,10 @@ #include "gwi.h" GWION_IMPORT(str2decl) { - GWI_OB(gwi_class_ini(gwi, "Test", NULL)) - GWI_OB(gwi_class_ini(gwi, "Child", NULL)) + GWI_B(gwi_class_ini(gwi, "Test", NULL)) + GWI_B(gwi_class_ini(gwi, "Child", NULL)) GWI_B(gwi_class_end(gwi)) GWI_B(gwi_class_end(gwi)) - GWI_OB(gwi_class_ini(gwi, "Test2", "Test.Child")) + GWI_B(gwi_class_ini(gwi, "Test2", "Test.Child")) return gwi_class_end(gwi); } diff --git a/tests/plug/str2list_fail.c b/tests/plug/str2list_fail.c index 0d3ad08d..6194a074 100644 --- a/tests/plug/str2list_fail.c +++ b/tests/plug/str2list_fail.c @@ -10,7 +10,7 @@ #include "gwi.h" GWION_IMPORT(str2list_fail) { - GWI_BB(gwi_item_ini(gwi, "SoemClass.child", "i")) - GWI_BB(gwi_item_end(gwi, ae_flag_none, num, 0)) - return GW_OK; + GWI_B(gwi_item_ini(gwi, "SoemClass.child", "i")) + GWI_B(gwi_item_end(gwi, ae_flag_none, num, 0)) + return true; } diff --git a/tests/plug/struct.c b/tests/plug/struct.c index 1cddd7aa..42f1a896 100644 --- a/tests/plug/struct.c +++ b/tests/plug/struct.c @@ -13,26 +13,26 @@ SFUN(coverage_int) { *(m_uint *)RETURN = 0; } SFUN(coverage_float) { *(m_float *)RETURN = 0; } GWION_IMPORT(struct) { - GWI_OB(gwi_struct_ini(gwi, "Struct")) + GWI_B(gwi_struct_ini(gwi, "Struct")) GWI_B(gwi_func_ini(gwi, "int", "i")) GWI_B(gwi_func_end(gwi, coverage_int, ae_flag_static)) GWI_B(gwi_func_ini(gwi, "float", "f")) GWI_B(gwi_func_end(gwi, coverage_float, ae_flag_static)) - GWI_BB(gwi_item_end(gwi, ae_flag_static, num, 5)) + GWI_B(gwi_item_end(gwi, ae_flag_static, num, 5)) - GWI_BB(gwi_item_ini(gwi, "int", "s_f")) - GWI_BB(gwi_item_end(gwi, ae_flag_static, fnum, 2.1)) + GWI_B(gwi_item_ini(gwi, "int", "s_f")) + GWI_B(gwi_item_end(gwi, ae_flag_static, fnum, 2.1)) - GWI_BB(gwi_item_ini(gwi, "int", "sc_i")) - GWI_BB(gwi_item_end(gwi, ae_flag_static | ae_flag_const, num, 5)) + GWI_B(gwi_item_ini(gwi, "int", "sc_i")) + GWI_B(gwi_item_end(gwi, ae_flag_static | ae_flag_const, num, 5)) - GWI_BB(gwi_item_ini(gwi, "float", "sc_f")) - GWI_BB(gwi_item_end(gwi, ae_flag_static | ae_flag_const, fnum, 2.1)) + GWI_B(gwi_item_ini(gwi, "float", "sc_f")) + GWI_B(gwi_item_end(gwi, ae_flag_static | ae_flag_const, fnum, 2.1)) - GWI_BB(gwi_item_ini(gwi, "int[][]", "test_array")) - GWI_BB(gwi_item_end(gwi, ae_flag_none, obj, NULL)) + GWI_B(gwi_item_ini(gwi, "int[][]", "test_array")) + GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL)) GWI_B(gwi_struct_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/template_arg.c b/tests/plug/template_arg.c index 0066599a..7219f6bf 100644 --- a/tests/plug/template_arg.c +++ b/tests/plug/template_arg.c @@ -10,10 +10,10 @@ static MFUN(template_arg_fun) {} GWION_IMPORT(template_arg) { - GWI_OB(gwi_class_ini(gwi, "TemplateArg", NULL)) + GWI_B(gwi_class_ini(gwi, "TemplateArg", NULL)) GWI_B(gwi_func_ini(gwi, "int", "set")) GWI_B(gwi_func_arg(gwi, "Pair,float>", "test")) GWI_B(gwi_func_end(gwi, template_arg_fun, ae_flag_none)) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/trig.c b/tests/plug/trig.c index 69e48139..15a10b18 100644 --- a/tests/plug/trig.c +++ b/tests/plug/trig.c @@ -23,11 +23,11 @@ static CTOR(trig2_ctor) { } GWION_IMPORT(trig) { - GWI_OB(gwi_class_ini(gwi, "Trig", "UGen")) + GWI_B(gwi_class_ini(gwi, "Trig", "UGen")) gwi_class_xtor(gwi, trig_ctor, NULL); gwi_class_end(gwi); - GWI_OB(gwi_class_ini(gwi, "Trig2", "UGen")) + GWI_B(gwi_class_ini(gwi, "Trig2", "UGen")) gwi_class_xtor(gwi, trig2_ctor, NULL); return gwi_class_end(gwi); } diff --git a/tests/plug/typedef.c b/tests/plug/typedef.c index 1f5257c8..ad413ed0 100644 --- a/tests/plug/typedef.c +++ b/tests/plug/typedef.c @@ -9,7 +9,7 @@ #include "import.h" GWION_IMPORT(typedef) { - GWI_OB(gwi_typedef_ini(gwi, "int", "Typedef")) - GWI_OB(gwi_typedef_end(gwi, ae_flag_none)) - return GW_OK; + GWI_B(gwi_typedef_ini(gwi, "int", "Typedef")) + GWI_B(gwi_typedef_end(gwi, ae_flag_none)) + return true; } diff --git a/tests/plug/typedef_fail.c b/tests/plug/typedef_fail.c index b3fb207d..a344f928 100644 --- a/tests/plug/typedef_fail.c +++ b/tests/plug/typedef_fail.c @@ -11,5 +11,5 @@ GWION_IMPORT(typedef_fail) { GWI_B(gwi_typedef_ini(gwi, "int", "Typedef:[A]")) GWI_B(gwi_typedef_ini(gwi, "int", "Typedef:[A]")) - return GW_OK; + return true; } diff --git a/tests/plug/typedef_tmpl.c b/tests/plug/typedef_tmpl.c index b13fa4a1..ab952826 100644 --- a/tests/plug/typedef_tmpl.c +++ b/tests/plug/typedef_tmpl.c @@ -10,6 +10,6 @@ GWION_IMPORT(typedef_tmpl) { GWI_B(gwi_typedef_ini(gwi, "Ptr:[A]", "Typedef:[A]")) - GWI_OB(gwi_typedef_end(gwi, ae_flag_none)) - return GW_OK; + GWI_B(gwi_typedef_end(gwi, ae_flag_none)) + return true; } diff --git a/tests/plug/ugen_connect.c b/tests/plug/ugen_connect.c index 450102f0..6b4b3774 100644 --- a/tests/plug/ugen_connect.c +++ b/tests/plug/ugen_connect.c @@ -15,5 +15,5 @@ GWION_IMPORT(ugen_connect) { const UGen ug1 = (UGen)vector_at(&gwi->gwion->vm->ugen, 1); ugen_connect(ug0, ug1); ugen_disconnect(ug0, ug1); - return GW_OK; + return true; } diff --git a/tests/plug/union.c b/tests/plug/union.c index e6d63ea8..e9361a27 100644 --- a/tests/plug/union.c +++ b/tests/plug/union.c @@ -13,5 +13,5 @@ GWION_IMPORT(union) { GWI_B(gwi_union_add(gwi, "float", "f")) GWI_B(gwi_union_add(gwi, "int", "i")) GWI_B(gwi_union_end(gwi, 0)) - return GW_OK; + return true; } diff --git a/tests/plug/union_fail_exp.c b/tests/plug/union_fail_exp.c index c0d8dc21..a33ab114 100644 --- a/tests/plug/union_fail_exp.c +++ b/tests/plug/union_fail_exp.c @@ -13,5 +13,5 @@ GWION_IMPORT(union_fail_exp) { GWI_B(gwi_union_add(gwi, "Float", "f")) GWI_B(gwi_union_add(gwi, "int", "i")) GWI_B(gwi_union_end(gwi, 0)) - return GW_OK; + return true; } diff --git a/tests/plug/union_member.c b/tests/plug/union_member.c index 52982d70..c307ddc6 100644 --- a/tests/plug/union_member.c +++ b/tests/plug/union_member.c @@ -9,11 +9,11 @@ #include "import.h" GWION_IMPORT(union_member) { - GWI_OB(gwi_class_ini(gwi, "UnionMember", NULL)) + GWI_B(gwi_class_ini(gwi, "UnionMember", NULL)) GWI_B(gwi_union_ini(gwi, "U")) GWI_B(gwi_union_add(gwi, "float", "f")) GWI_B(gwi_union_add(gwi, "int[]", "array")) GWI_B(gwi_union_end(gwi, ae_flag_none)) GWI_B(gwi_class_end(gwi)) - return GW_OK; + return true; } diff --git a/tests/plug/union_name.c b/tests/plug/union_name.c index 6581666a..4e6e26cf 100644 --- a/tests/plug/union_name.c +++ b/tests/plug/union_name.c @@ -13,5 +13,5 @@ GWION_IMPORT(union_name) { GWI_B(gwi_union_add(gwi, "float", "f")) GWI_B(gwi_union_add(gwi, "int", "i")) GWI_B(gwi_union_end(gwi, 0)) - return GW_OK; + return true; } diff --git a/tests/plug/union_tmpl.c b/tests/plug/union_tmpl.c index aa632147..9e226059 100644 --- a/tests/plug/union_tmpl.c +++ b/tests/plug/union_tmpl.c @@ -14,5 +14,5 @@ GWION_IMPORT(union_tmpl) { GWI_B(gwi_union_add(gwi, "int", "i")) GWI_B(gwi_union_add(gwi, "A", "a")) GWI_B(gwi_union_end(gwi, 0)) - return GW_OK; + return true; } diff --git a/tests/plug/union_tmpl_fail.c b/tests/plug/union_tmpl_fail.c index ed100d38..a57b73e2 100644 --- a/tests/plug/union_tmpl_fail.c +++ b/tests/plug/union_tmpl_fail.c @@ -14,5 +14,5 @@ GWION_IMPORT(union_tmpl_fail) { GWI_B(gwi_union_add(gwi, "int", "i")) GWI_B(gwi_union_add(gwi, "A", "a")) GWI_B(gwi_union_end(gwi, 0)) - return GW_OK; + return true; } diff --git a/tests/plug/union_tmpl_fail2.c b/tests/plug/union_tmpl_fail2.c index 5f5f82dc..7d965edc 100644 --- a/tests/plug/union_tmpl_fail2.c +++ b/tests/plug/union_tmpl_fail2.c @@ -15,5 +15,5 @@ GWION_IMPORT(union_tmpl_fail2) { GWI_B(gwi_union_add(gwi, "A", "a")) GWI_B(gwi_union_ini(gwi, "U:[A]")) GWI_B(gwi_union_end(gwi, 0)) - return GW_OK; + return true; } diff --git a/tests/plug/union_tmpl_fail3.c b/tests/plug/union_tmpl_fail3.c index 32f2b09f..feeef915 100644 --- a/tests/plug/union_tmpl_fail3.c +++ b/tests/plug/union_tmpl_fail3.c @@ -14,5 +14,5 @@ GWION_IMPORT(union_tmpl_fail3) { GWI_B(gwi_union_add(gwi, "int", "i")) GWI_B(gwi_union_add(gwi, "A", "a")) GWI_B(gwi_union_end(gwi, 0)) - return GW_OK; + return true; } diff --git a/tests/plug/vm_remove.c b/tests/plug/vm_remove.c index 30348102..5548c147 100644 --- a/tests/plug/vm_remove.c +++ b/tests/plug/vm_remove.c @@ -15,5 +15,5 @@ GWION_IMPORT(vm_remove) { GWI_B(gwi_func_ini(gwi, "int", "test")) GWI_B(gwi_func_arg(gwi, "int", "i")) GWI_B(gwi_func_end(gwi, coverage_int, ae_flag_none)) - return GW_OK; + return true; } diff --git a/util b/util index 373c31f9..40579aff 160000 --- a/util +++ b/util @@ -1 +1 @@ -Subproject commit 373c31f93cc54f6dd0f04dee5b685bb8f73d4a88 +Subproject commit 40579aff6f25a637d6d0da8032700e85b1611cb0 -- 2.43.0