From 5f470863d279449b9e40110b592bd4e349994b7c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Tue, 27 Apr 2021 20:18:28 +0200 Subject: [PATCH] :art: The great uncursing --- include/env/env.h | 1 + include/env/envset.h | 2 +- include/import.h | 4 +- include/parse.h | 12 +- src/arg.c | 2 +- src/compile.c | 4 +- src/emit/emit.c | 226 +++++++++++++++++----------------- src/emit/escape.c | 2 +- src/env/env_utils.c | 2 +- src/env/envset.c | 8 +- src/env/func.c | 2 +- src/gwion.c | 6 +- src/import/import_cdef.c | 8 +- src/import/import_checker.c | 16 +-- src/import/import_enum.c | 8 +- src/import/import_fdef.c | 12 +- src/import/import_item.c | 6 +- src/import/import_tdef.c | 6 +- src/import/import_type.c | 2 +- src/import/import_udef.c | 12 +- src/lib/array.c | 4 +- src/lib/engine.c | 2 +- src/lib/instr.c | 2 +- src/lib/lib_func.c | 14 +-- src/lib/object_op.c | 10 +- src/lib/opfunc.c | 2 +- src/lib/string.c | 2 +- src/lib/union.c | 4 +- src/parse/check.c | 156 +++++++++++------------ src/parse/func_resolve_tmpl.c | 12 +- src/parse/operator.c | 4 +- src/parse/scan0.c | 40 +++--- src/parse/scan1.c | 100 +++++++-------- src/parse/scan2.c | 82 ++++++------ src/parse/scanx.c | 4 +- src/parse/template.c | 4 +- src/parse/traverse.c | 42 +++---- src/plug.c | 4 +- 38 files changed, 415 insertions(+), 414 deletions(-) diff --git a/include/env/env.h b/include/env/env.h index 72683789..4425fabb 100644 --- a/include/env/env.h +++ b/include/env/env.h @@ -55,4 +55,5 @@ struct ScopeEffect { }; ANN void env_add_effect(const Env a, const Symbol effect, const loc_t pos); +ANN void call_add_effect(const Env env, const Func func, const loc_t pos); #endif diff --git a/include/env/envset.h b/include/env/envset.h index eadd7183..c3981bf2 100644 --- a/include/env/envset.h +++ b/include/env/envset.h @@ -18,7 +18,7 @@ ANN2(1) void envset_pop(struct EnvSet*, const Type); ANN static inline m_bool extend_push(const Env env, const Type t) { const Type owner = t->info->value->from->owner_class; if(owner) - CHECK_BB(extend_push(env, owner)) + CHECK_BB(extend_push(env, owner)); return env_push_type(env, t); } diff --git a/include/import.h b/include/import.h index f0b1a466..3f25a51b 100644 --- a/include/import.h +++ b/include/import.h @@ -20,8 +20,8 @@ typedef struct Gwi_* Gwi; #define GWI_OB(a) { gwi_set_loc(gwi, __FILE__, __LINE__); (void)(a); } #define GWION_IMPORT(a) ANN m_bool import_##a(const Gwi gwi) #else -#define GWI_BB(a) { gwi_set_loc(gwi, (m_str)__FILE__, __LINE__); CHECK_BB(a) } -#define GWI_OB(a) { gwi_set_loc(gwi, (m_str)__FILE__, __LINE__); CHECK_OB(a) } +#define GWI_BB(a) { gwi_set_loc(gwi, (m_str)__FILE__, __LINE__); CHECK_BB(a); } +#define GWI_OB(a) { gwi_set_loc(gwi, (m_str)__FILE__, __LINE__); CHECK_OB(a); } #define GWION_IMPORT(a) ANN m_bool import(const Gwi gwi) #endif #define ALLOC_PTR(p, a, b, c) b* a = (b*)_mp_calloc(p, sizeof(b)); *a = (b)c diff --git a/include/parse.h b/include/parse.h index 3e24a72c..3a851511 100644 --- a/include/parse.h +++ b/include/parse.h @@ -31,12 +31,12 @@ ANN static inline type prefix##_section(const Arg a, /* const */ Section* sectio return prefix##_section_func[section->section_type](a, *(void**)d); \ } -#define HANDLE_EXP_FUNC(prefix, type, Arg) \ -DECL_EXP_FUNC(prefix, type, Arg) \ -ANN type prefix##_exp(const Arg arg, Exp exp) { \ - do CHECK_BB(prefix##_exp_func[exp->exp_type](arg, &exp->d)) \ - while((exp = exp->next)); \ - return GW_OK; \ +#define HANDLE_EXP_FUNC(prefix, type, Arg) \ +DECL_EXP_FUNC(prefix, type, Arg) \ +ANN type prefix##_exp(const Arg arg, Exp exp) { \ + do CHECK_BB(prefix##_exp_func[exp->exp_type](arg, &exp->d)); \ + while((exp = exp->next)); \ + return GW_OK; \ } ANN m_bool scan1_exp(const Env, Exp); ANN m_bool scan2_exp(const Env, Exp); diff --git a/src/arg.c b/src/arg.c index 3f893ee8..aa39573b 100644 --- a/src/arg.c +++ b/src/arg.c @@ -205,7 +205,7 @@ ANN static Vector get_config(const char *name) { size_t len = 0; ssize_t nread; FILE *f = fopen(name, "r"); - CHECK_OO(f) + CHECK_OO(f); const Vector v = (Vector)xmalloc(sizeof(struct Vector_)); vector_init(v); vector_add(v, (vtype)name); diff --git a/src/compile.c b/src/compile.c index 6cf1e8fc..56f69059 100644 --- a/src/compile.c +++ b/src/compile.c @@ -104,7 +104,7 @@ ANN static inline m_bool compiler_open(MemPool p, struct Compiler* c) { ANN static inline m_bool _passes(struct Gwion_* gwion, struct Compiler* c) { for(m_uint i = 0; i < vector_size(&gwion->data->passes->vec); ++i) { const compilation_pass pass = (compilation_pass)vector_at(&gwion->data->passes->vec, i); - CHECK_BB(pass(gwion->env, c->ast)) + CHECK_BB(pass(gwion->env, c->ast)); } return GW_OK; } @@ -128,7 +128,7 @@ ANN static inline m_bool passes(struct Gwion_* gwion, struct Compiler* c) { ANN static inline m_bool _check(struct Gwion_* gwion, struct Compiler* c) { struct AstGetter_ arg = { c->name, c->file, gwion->st, .ppa=gwion->ppa }; - CHECK_OB((c->ast = parse(&arg))) + CHECK_OB((c->ast = parse(&arg))); gwion->env->name = c->name; const m_bool ret = passes(gwion, c); if(!arg.global) diff --git a/src/emit/emit.c b/src/emit/emit.c index 6f1ce8f2..2a26d304 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -178,7 +178,7 @@ ANN static m_bool emit_defers(const Emitter emit) { return GW_OK; Stmt stmt; while((stmt = (Stmt)vector_pop(&emit->code->frame->defer))) - CHECK_BB(emit_stmt(emit, stmt, 1)) + CHECK_BB(emit_stmt(emit, stmt, 1)); return GW_OK; } @@ -187,7 +187,7 @@ ANN static m_bool emit_defers2(const Emitter emit) { const Stmt stmt = (Stmt)vector_at(&emit->code->frame->defer, i-1); if(!stmt) break; - CHECK_BB(emit_stmt(emit, stmt, 1)) + CHECK_BB(emit_stmt(emit, stmt, 1)); } return GW_OK; } @@ -320,7 +320,7 @@ ANN static void emit_pre_constructor_array(const Emitter emit, const Type type) ANN2(1) static m_bool extend_indices(const Emitter emit, Exp e, const m_uint depth) { if(e) - CHECK_BB(emit_exp(emit, e)) + CHECK_BB(emit_exp(emit, e)); m_uint count = 0; while(e) { ++count; @@ -352,7 +352,7 @@ ANN static inline void arrayinfo_ctor(const Emitter emit, ArrayInfo *info) { } ANN2(1,2) static ArrayInfo* emit_array_extend_inner(const Emitter emit, const Type t, const Exp e, const uint is_ref) { - CHECK_BO(extend_indices(emit, e, get_depth(t))) + CHECK_BO(extend_indices(emit, e, get_depth(t))); ArrayInfo* info = new_arrayinfo(emit, t); const Instr alloc = emit_add_instr(emit, ArrayAlloc); alloc->m_val = (m_uint)info; @@ -384,7 +384,7 @@ ANN void emit_ext_ctor(const Emitter emit, const Type t) { } ANN m_bool emit_array_extend(const Emitter emit, const Type t, const Exp e) { - CHECK_OB(emit_array_extend_inner(emit, t, e, 0)) + CHECK_OB(emit_array_extend_inner(emit, t, e, 0)); regpop(emit, SZ_INT); const Instr instr = emit_add_instr(emit, Reg2Reg); instr->m_val = -SZ_INT; @@ -533,7 +533,7 @@ ANN2(1) static void emit_exp_addref(const Emitter emit, /* const */Exp exp, m_in ANN static m_bool emit_prim_array(const Emitter emit, const Array_Sub *data) { Exp e = (*data)->exp; - CHECK_BB(emit_exp(emit, e)) + CHECK_BB(emit_exp(emit, e)); emit_exp_addref(emit, e, -exp_totalsize(e)); m_uint count = 0; do ++count; @@ -552,11 +552,11 @@ ANN static inline m_bool emit_exp_pop_next(const Emitter emit, Exp e); ANN static m_bool emit_range(const Emitter emit, Range *range) { if(range->start) - CHECK_BB(emit_exp_pop_next(emit, range->start)) + CHECK_BB(emit_exp_pop_next(emit, range->start)); else regpushi(emit, 0); if(range->end) - CHECK_BB(emit_exp_pop_next(emit, range->end)) + CHECK_BB(emit_exp_pop_next(emit, range->end)); else regpushi(emit, -1); return GW_OK; @@ -564,12 +564,12 @@ ANN static m_bool emit_range(const Emitter emit, Range *range) { ANN static m_bool emit_prim_range(const Emitter emit, Range **data) { Range *range = *data; - CHECK_BB(emit_range(emit, range)) + CHECK_BB(emit_range(emit, range)); const Exp e = range->start ?: range->end; const Symbol sym = insert_symbol("@range"); struct Op_Import opi = { .op=sym, .rhs=e->type, .pos=e->pos, .data=(uintptr_t)prim_exp(data) }; - CHECK_BB(op_emit(emit, &opi)) + CHECK_BB(op_emit(emit, &opi)); emit_gc(emit, -SZ_INT); return GW_OK; } @@ -590,15 +590,15 @@ ANN m_bool emit_array_access(const Emitter emit, struct ArrayAccessInfo *const i } ANN static m_bool emit_exp_array(const Emitter emit, const Exp_Array* array) { - CHECK_BB(emit_exp(emit, array->base)) + CHECK_BB(emit_exp(emit, array->base)); const Exp e = exp_self(array); struct ArrayAccessInfo info = { *array->array, e->type, exp_getvar(e) }; return emit_array_access(emit, &info); } ANN static m_bool emit_exp_slice(const Emitter emit, const Exp_Slice* range) { - CHECK_BB(emit_exp(emit, range->base)) - CHECK_BB(emit_range(emit, range->range)) + CHECK_BB(emit_exp(emit, range->base)); + CHECK_BB(emit_range(emit, range->range)); const Symbol sym = insert_symbol("@slice"); const Exp e = range->range->start ?: range->range->end; struct Op_Import opi = { .op=sym, .lhs=e->type, .rhs=range->base->type, @@ -659,7 +659,7 @@ ANN static m_bool emit_prim_str(const Emitter emit, const m_str *str) { char c[strlen(*str) + 1]; if(strlen(*str)) { strcpy(c, *str); - CHECK_BB(escape_str(emit, c, prim_pos(str))); + CHECK_BB(escape_str(emit, c, prim_pos(str)));; } else c[0] = '\0'; v->d.obj = new_string2(emit->gwion, NULL, c); } @@ -709,7 +709,7 @@ ANN /*static*/ m_bool emit_interp(const Emitter emit, const Exp exp) { } ANN static m_bool emit_prim_hack(const Emitter emit, const Exp *exp) { - CHECK_BB(emit_interp(emit, *exp)) + CHECK_BB(emit_interp(emit, *exp)); if(!(emit->env->func && emit->env->func->def->base->xid == insert_symbol("@gack"))) emit_add_instr(emit, GackEnd); else { @@ -722,7 +722,7 @@ ANN static m_bool emit_prim_hack(const Emitter emit, const Exp *exp) { ANN static m_bool emit_prim_interp(const Emitter emit, const Exp *exp) { const Exp e = *exp; - CHECK_BB(emit_interp(emit, e)) + CHECK_BB(emit_interp(emit, e)); const Instr instr = emit_add_instr(emit, GackEnd); instr->m_val = 1; return GW_OK; @@ -745,8 +745,8 @@ ANN static m_bool decl_static(const Emitter emit, const Exp_Decl *decl, const Va const Value v = var_decl->value; Code* code = emit->code; emit->code = (Code*)vector_back(&emit->stack); - CHECK_BB(emit_instantiate_decl(emit, v->type, decl->td, var_decl->array, is_ref)) - CHECK_BB(emit_dot_static_data(emit, v, 1)) + CHECK_BB(emit_instantiate_decl(emit, v->type, decl->td, var_decl->array, is_ref)); + CHECK_BB(emit_dot_static_data(emit, v, 1)); emit_add_instr(emit, Assign); // (void)emit_object_addref(emit, -SZ_INT, 0); regpop(emit, SZ_INT); @@ -774,8 +774,8 @@ ANN static void emit_struct_decl_finish(const Emitter emit, const Type t, const ANN static m_bool emit_exp_decl_static(const Emitter emit, const Exp_Decl *decl, const Var_Decl var_decl, const uint is_ref, const uint emit_addr) { const Value v = var_decl->value; if(isa(v->type, emit->gwion->type[et_object]) > 0 && !is_ref) - CHECK_BB(decl_static(emit, decl, var_decl, 0)) - CHECK_BB(emit_dot_static_data(emit, v, !struct_ctor(v) ? emit_addr : 1)) + CHECK_BB(decl_static(emit, decl, var_decl, 0)); + CHECK_BB(emit_dot_static_data(emit, v, !struct_ctor(v) ? emit_addr : 1)); if(struct_ctor(v)) emit_struct_decl_finish(emit, v->type, emit_addr); return GW_OK; @@ -801,7 +801,7 @@ ANN static m_bool emit_exp_decl_non_static(const Emitter emit, const Exp_Decl *d const m_bool is_obj = isa(type, emit->gwion->type[et_object]) > 0; const uint emit_addr = (!is_obj || (is_ref && !is_array)) ? emit_var : 1; if(is_obj && (is_array || !is_ref)) - CHECK_BB(emit_instantiate_decl(emit, type, decl->td, array, is_ref)) + CHECK_BB(emit_instantiate_decl(emit, type, decl->td, array, is_ref)); f_instr *exec = (f_instr*)allocmember; if(!vflag(v, vflag_member)) { v->from->offset = emit_local(emit, type); @@ -836,7 +836,7 @@ ANN static m_bool emit_exp_decl_global(const Emitter emit, const Exp_Decl *decl, const m_bool is_obj = isa(type, emit->gwion->type[et_object]) > 0; const uint emit_addr = (!is_obj || (is_ref && !is_array)) ? emit_var : 1; if(is_obj && (is_array || !is_ref)) - CHECK_BB(emit_instantiate_decl(emit, type, decl->td, array, is_ref)) + CHECK_BB(emit_instantiate_decl(emit, type, decl->td, array, is_ref)); const Instr instr = emit_kind(emit, v->type->size, !struct_ctor(v) ? emit_addr : 1, dotstatic); if(type->size > SZ_INT) //{ v->d.ptr = mp_calloc2(emit->gwion->mp, v->type->size); @@ -871,11 +871,11 @@ ANN static m_bool emit_decl(const Emitter emit, const Exp_Decl* decl) { const Value v = list->self->value; const uint r = ref || GET_FLAG(v, late); if(GET_FLAG(decl->td, static)) - CHECK_BB(emit_exp_decl_static(emit, decl, list->self, r, var)) + CHECK_BB(emit_exp_decl_static(emit, decl, list->self, r, var)); else if(!global) - CHECK_BB(emit_exp_decl_non_static(emit, decl, list->self, r, var)) + CHECK_BB(emit_exp_decl_non_static(emit, decl, list->self, r, var)); else - CHECK_BB(emit_exp_decl_global(emit, decl, list->self, r, var)) + CHECK_BB(emit_exp_decl_global(emit, decl, list->self, r, var)); set_late(emit->gwion, decl, list->self); if(GET_FLAG(array_base(v->type), abstract) && !GET_FLAG(decl->td, late) && GET_FLAG(v, late)) { env_warn(emit->env, decl->td->pos, _("Type '%s' is abstract, use late"), v->type->name); @@ -886,7 +886,7 @@ ANN static m_bool emit_decl(const Emitter emit, const Exp_Decl* decl) { ANN /*static */m_bool emit_exp_decl(const Emitter emit, const Exp_Decl* decl) { const Type t = decl->type; - CHECK_BB(ensure_emit(emit, t)) + CHECK_BB(ensure_emit(emit, t)); const m_bool global = GET_FLAG(decl->td, global); const m_uint scope = !global ? emit->env->scope->depth : emit_push_global(emit); const m_bool ret = emit_decl(emit, decl); @@ -923,7 +923,7 @@ ANN static void emit_func_arg_vararg(const Emitter emit, const Exp_Call* exp_cal ANN static m_bool emit_func_args(const Emitter emit, const Exp_Call* exp_call) { if(exp_call->args) { - CHECK_BB(emit_exp(emit, exp_call->args)) + CHECK_BB(emit_exp(emit, exp_call->args)); // emit_exp_addref(emit, exp_call->args, -exp_totalsize(exp_call->args)); } const Type t = actual_type(emit->gwion, exp_call->func->type); @@ -934,19 +934,19 @@ ANN static m_bool emit_func_args(const Emitter emit, const Exp_Call* exp_call) { } ANN static m_bool prepare_call(const Emitter emit, const Exp_Call* exp_call) { - CHECK_BB(emit_func_args(emit, exp_call)) + CHECK_BB(emit_func_args(emit, exp_call)); return emit_exp(emit, exp_call->func); } ANN static m_bool emit_exp_call(const Emitter emit, const Exp_Call* exp_call) { - CHECK_BB(prepare_call(emit, exp_call)) + CHECK_BB(prepare_call(emit, exp_call)); const Type t = actual_type(emit->gwion, exp_call->func->type); if(isa(t, emit->gwion->type[et_function]) > 0) - CHECK_BB(emit_exp_call1(emit, t->info->func)) + CHECK_BB(emit_exp_call1(emit, t->info->func)); else { struct Op_Import opi = { .op=insert_symbol("@ctor"), .rhs=t, .data=(uintptr_t)exp_call, .pos=exp_self(exp_call)->pos }; - CHECK_BB(op_emit(emit, &opi)) + CHECK_BB(op_emit(emit, &opi)); } const Exp e = exp_self(exp_call); if(exp_getvar(e)) { @@ -985,7 +985,7 @@ ANN static inline void pop_exp(const Emitter emit, Exp e) { } ANN static inline m_bool emit_exp_pop_next(const Emitter emit, Exp e) { - CHECK_BB(emit_exp(emit, e)) + CHECK_BB(emit_exp(emit, e)); if(e->exp_type == ae_exp_decl) { Var_Decl_List list = e->d.exp_decl.list->next; while(list) { @@ -1001,8 +1001,8 @@ ANN static inline m_bool emit_exp_pop_next(const Emitter emit, Exp e) { ANN static m_bool emit_exp_binary(const Emitter emit, const Exp_Binary* bin) { const Exp lhs = bin->lhs; const Exp rhs = bin->rhs; - CHECK_BB(emit_exp_pop_next(emit, lhs)) - CHECK_BB(emit_exp_pop_next(emit, rhs)) + CHECK_BB(emit_exp_pop_next(emit, lhs)); + CHECK_BB(emit_exp_pop_next(emit, rhs)); // const m_int size = exp_size(rhs); // emit_exp_addref1(emit, lhs, -exp_size(lhs) - size); // emit_exp_addref1(emit, rhs, -size); @@ -1015,7 +1015,7 @@ ANN static m_bool emit_exp_cast(const Emitter emit, const Exp_Cast* cast) { // no pos ? struct Op_Import opi = { .op=insert_symbol("$"), .lhs=cast->exp->type, .rhs=exp_self(cast)->type, .data=(uintptr_t)cast }; - CHECK_BB(emit_exp(emit, cast->exp)) + CHECK_BB(emit_exp(emit, cast->exp)); (void)op_emit(emit, &opi); return GW_OK; } @@ -1024,13 +1024,13 @@ ANN static m_bool emit_exp_post(const Emitter emit, const Exp_Postfix* post) { // no pos ? struct Op_Import opi = { .op=post->op, .lhs=post->exp->type, .data=(uintptr_t)post }; - CHECK_BB(emit_exp(emit, post->exp)) + CHECK_BB(emit_exp(emit, post->exp)); return op_emit(emit, &opi); } ANN static inline m_bool traverse_emit_func_def(const Emitter emit, const Func_Def fdef) { if(!fdef->base->ret_type) - CHECK_BB(traverse_func_def(emit->env, fdef)) + CHECK_BB(traverse_func_def(emit->env, fdef)); return emit_func_def(emit, fdef); } @@ -1038,7 +1038,7 @@ ANN m_bool traverse_dot_tmpl(const Emitter emit, const struct dottmpl_ *dt) { const m_uint scope = emit->env->scope->depth; struct EnvSet es = { .env=emit->env, .data=emit, .func=(_exp_func)emit_cdef, .scope=scope, .flag=tflag_emit }; - CHECK_BB(envset_push(&es, dt->owner_class, dt->owner)) + CHECK_BB(envset_push(&es, dt->owner_class, dt->owner)); (void)emit_push(emit, dt->owner_class, dt->owner); const m_bool ret = traverse_emit_func_def(emit, dt->def); if(es.run) @@ -1077,7 +1077,7 @@ ANN static m_bool emit_template_code(const Emitter emit, const Func f) { const size_t scope = emit->env->scope->depth; struct EnvSet es = { .env=emit->env, .data=emit, .func=(_exp_func)emit_cdef, .scope=scope, .flag=tflag_emit }; - CHECK_BB(envset_push(&es, v->from->owner_class, v->from->owner)) + CHECK_BB(envset_push(&es, v->from->owner_class, v->from->owner)); (void)emit_push(emit, v->from->owner_class, v->from->owner); const m_bool ret = emit_func_def(emit, f->def); if(es.run) @@ -1148,7 +1148,7 @@ static m_bool me_cmp(MemoizeEmitter *me, const Arg_List arg) { struct Exp_ exp = {}; struct Op_Import opi = { .op=sym, .lhs=arg->type, .rhs=arg->type, .pos=me->fdef->base->pos, .data=(uintptr_t)&exp.d }; - CHECK_BB(op_emit(emit, &opi)) + CHECK_BB(op_emit(emit, &opi)); const Instr instr = emit_add_instr(emit, BranchEqInt); vector_add(&me->branch, (vtype)instr); return GW_OK; @@ -1161,7 +1161,7 @@ ANN static m_bool me_arg(MemoizeEmitter *me) { (void)me_push(me, sz); const Instr instr = me_push(me, sz); instr->m_val += me->offset + SZ_INT *2; - CHECK_BB(me_cmp(me, arg)) + CHECK_BB(me_cmp(me, arg)); me->arg_offset += arg->type->size; } while((arg = arg->next)); return GW_OK; @@ -1188,7 +1188,7 @@ ANN m_bool emit_exp_call1(const Emitter emit, const Func f) { if(!f->code || (fflag(f, fflag_ftmpl) && !vflag(f->value_ref, vflag_builtin))) { if(tmpl && !is_fptr(emit->gwion, f->value_ref->type)) { if(emit->env->func != f) - CHECK_BB(emit_template_code(emit, f)) + CHECK_BB(emit_template_code(emit, f)); else { // recursive function. (maybe should be used only for global funcs) const Instr back = (Instr) vector_size(&emit->code->instr) ? (Instr)vector_back(&emit->code->instr) : emit_add_instr(emit, RegPushImm); @@ -1202,7 +1202,7 @@ ANN m_bool emit_exp_call1(const Emitter emit, const Func f) { back->m_val = (m_uint)f; } else { // ensure env? - CHECK_BB(emit_func_def(emit, f->def)) + CHECK_BB(emit_func_def(emit, f->def)); const Instr instr = emit_add_instr(emit, RegSetImm); instr->m_val = (m_uint)f->code; instr->m_val2 = -SZ_INT; @@ -1323,7 +1323,7 @@ ANN static m_bool spork_prepare_func(const Emitter emit, const struct Sporker *s ANN static VM_Code spork_prepare(const Emitter emit, const struct Sporker *sp) { if(!sp->code) - CHECK_BO(prepare_call(emit, &sp->exp->d.exp_call)) + CHECK_BO(prepare_call(emit, &sp->exp->d.exp_call)); if((sp->code ? spork_prepare_code : spork_prepare_func)(emit, sp) > 0) return finalyze(emit, EOC); emit_pop_code(emit); @@ -1379,7 +1379,7 @@ ANN m_bool emit_exp_spork(const Emitter emit, const Exp_Unary* unary) { .is_spork=(unary->op == insert_symbol("spork")), .emit_var=exp_getvar(exp_self(unary)) }; - CHECK_OB((sporker.vm_code = spork_prepare(emit, &sporker))) + CHECK_OB((sporker.vm_code = spork_prepare(emit, &sporker))); spork_ini(emit, &sporker); (unary->unary_type == unary_code ? spork_code : spork_func)(emit, &sporker); return GW_OK; @@ -1388,11 +1388,11 @@ ANN m_bool emit_exp_spork(const Emitter emit, const Exp_Unary* unary) { ANN static m_bool emit_exp_unary(const Emitter emit, const Exp_Unary* unary) { const Type t = exp_self(unary)->type; const Type base = actual_type(emit->gwion, t); - CHECK_BB(ensure_emit(emit, base)) + CHECK_BB(ensure_emit(emit, base)); // no pos ? struct Op_Import opi = { .op=unary->op, .data=(uintptr_t)unary }; if(unary->unary_type == unary_exp && unary->op != insert_symbol("spork") && unary->op != insert_symbol("fork")) { - CHECK_BB(emit_exp_pop_next(emit, unary->exp)) + CHECK_BB(emit_exp_pop_next(emit, unary->exp)); opi.rhs = unary->exp->type; } return op_emit(emit, &opi); @@ -1408,11 +1408,11 @@ ANN static m_bool emit_implicit_cast(const Emitter emit, } ANN static Instr _flow(const Emitter emit, const Exp e, const m_bool b) { - CHECK_BO(emit_exp_pop_next(emit, e)) + CHECK_BO(emit_exp_pop_next(emit, e)); emit_exp_addref1(emit, e, -exp_size(e)); struct Op_Import opi = { .op=insert_symbol(b ? "@conditionnal" : "@unconditionnal"), .rhs=e->type, .pos=e->pos, .data=(uintptr_t)e }; - CHECK_BO(op_emit(emit, &opi)) + CHECK_BO(op_emit(emit, &opi)); return (Instr)vector_back(&emit->code->instr); } #define emit_flow(emit,b) _flow(emit, b, 1) @@ -1424,7 +1424,7 @@ ANN static m_bool emit_exp_if(const Emitter emit, const Exp_If* exp_if) { exp_setvar(exp_if->else_exp, 1); } DECL_OB(const Instr, op, = emit_flow(emit, exp_if->cond)) - CHECK_BB(emit_exp_pop_next(emit, exp_if->if_exp ?: exp_if->cond)) + CHECK_BB(emit_exp_pop_next(emit, exp_if->if_exp ?: exp_if->cond)); const Instr op2 = emit_add_instr(emit, Goto); op->m_val = emit_code_size(emit); const m_bool ret = emit_exp_pop_next(emit, exp_if->else_exp); @@ -1436,7 +1436,7 @@ ANN static inline m_bool emit_prim_novar(const Emitter emit, const Exp_Primary * const Exp e = exp_self(prim); const uint var = exp_getvar(e); exp_setvar(e, 0); - CHECK_BB(emit_symbol(emit, prim)) + CHECK_BB(emit_symbol(emit, prim)); exp_setvar(e, var); return GW_OK; } @@ -1446,7 +1446,7 @@ ANN static m_bool emit_upvalues(const Emitter emit, const Func func) { for(m_uint i = 0; i < map_size(map); ++i) { const Exp_Primary *prim = (Exp_Primary*)VKEY(map, i); const Value v = prim->value; - CHECK_BB(emit_prim_novar(emit, prim)); + CHECK_BB(emit_prim_novar(emit, prim));; if(isa(prim->value->type, emit->gwion->type[et_compound]) > 0) { if(vflag(v, vflag_fglobal) && !vflag(v, vflag_closed)) emit_exp_addref1(emit, exp_self(prim), -v->type->size); @@ -1462,7 +1462,7 @@ ANN static m_bool emit_closure(const Emitter emit, const Func func) { const m_uint sz = VVAL(map, VLEN(map) - 1) + ((Exp_Primary*)VKEY(map, VLEN(map) - 1))->value->type->size; func->code->closure = new_closure(emit->gwion->mp, sz); regpushi(emit, (m_uint)func->code->closure->data); - CHECK_BB(emit_upvalues(emit, func)) + CHECK_BB(emit_upvalues(emit, func)); regpop(emit, sz); const Instr cpy = emit_add_instr(emit, Reg2RegOther); cpy->m_val2 = sz; @@ -1471,9 +1471,9 @@ ANN static m_bool emit_closure(const Emitter emit, const Func func) { } ANN static m_bool emit_lambda(const Emitter emit, const Exp_Lambda * lambda) { - CHECK_BB(emit_func_def(emit, lambda->def)) + CHECK_BB(emit_func_def(emit, lambda->def)); if(lambda->def->base->func->upvalues.ptr) - CHECK_BB(emit_closure(emit, lambda->def->base->func)) + CHECK_BB(emit_closure(emit, lambda->def->base->func)); if(vflag(lambda->def->base->func->value_ref, vflag_member) && !exp_getvar(exp_self(lambda))) emit_add_instr(emit, RegPushMem); regpushi(emit, (m_uint)lambda->def->base->func->code); @@ -1487,7 +1487,7 @@ ANN static m_bool emit_exp_lambda(const Emitter emit, const Exp_Lambda * lambda) } struct EnvSet es = { .env=emit->env, .data=emit, .func=(_exp_func)emit_cdef, .scope=emit->env->scope->depth, .flag=tflag_emit }; - CHECK_BB(envset_push(&es, lambda->owner, lambda->def->base->func->value_ref->from->owner)) + CHECK_BB(envset_push(&es, lambda->owner, lambda->def->base->func->value_ref->from->owner)); const m_bool ret = emit_lambda(emit, lambda); if(es.run) envset_pop(&es, lambda->owner); @@ -1505,9 +1505,9 @@ DECL_EXP_FUNC(emit, m_bool, Emitter) ANN2(1) /*static */m_bool emit_exp(const Emitter emit, /* const */Exp e) { Exp exp = e; do { - CHECK_BB(emit_exp_func[exp->exp_type](emit, &exp->d)) + CHECK_BB(emit_exp_func[exp->exp_type](emit, &exp->d)); if(exp->cast_to) - CHECK_BB(emit_implicit_cast(emit, exp, exp->cast_to)) + CHECK_BB(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) && e->exp_type == ae_exp_decl && GET_FLAG(e->d.exp_decl.td, late) && exp_getuse(e) && !exp_getvar(e) && GET_FLAG(e->d.exp_decl.list->self->value, late)) { @@ -1529,11 +1529,11 @@ ANN static m_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)) - CHECK_BB(scoped_stmt(emit, stmt->if_body, 1)) + CHECK_BB(scoped_stmt(emit, stmt->if_body, 1)); const Instr op2 = emit_add_instr(emit, Goto); op->m_val = emit_code_size(emit); if(stmt->else_body) - CHECK_BB(scoped_stmt(emit, stmt->else_body, 1)) + CHECK_BB(scoped_stmt(emit, stmt->else_body, 1)); op2->m_val = emit_code_size(emit); return GW_OK; } @@ -1564,14 +1564,14 @@ ANN static m_bool optimize_taill_call(const Emitter emit, const Exp_Call* e) { } ANN static m_bool emit_stmt_return(const Emitter emit, const Stmt_Exp stmt) { - CHECK_BB(emit_defers2(emit)) + CHECK_BB(emit_defers2(emit)); if(stmt->val) { if(stmt->val->exp_type == ae_exp_call) { const Func f = stmt->val->d.exp_call.func->type->info->func; if(stmt->val->exp_type == ae_exp_call && emit->env->func == f) return optimize_taill_call(emit, &stmt->val->d.exp_call); } - CHECK_BB(emit_exp_pop_next(emit, stmt->val)) + CHECK_BB(emit_exp_pop_next(emit, stmt->val)); } vector_add(&emit->code->stack_return, (vtype)emit_add_instr(emit, Goto)); return GW_OK; @@ -1594,7 +1594,7 @@ ANN static inline m_bool emit_jump_index(const Emitter emit, const Vector v, con } ANN static inline m_bool emit_stmt_continue(const Emitter emit, const Stmt_Index stmt) { - CHECK_BB(emit_defers2(emit)) + CHECK_BB(emit_defers2(emit)); if(stmt->idx == -1 || stmt->idx == 1) vector_add(&emit->code->stack_cont, (vtype)emit_add_instr(emit, Goto)); else if(stmt->idx) { @@ -1605,7 +1605,7 @@ ANN static inline m_bool emit_stmt_continue(const Emitter emit, const Stmt_Index } ANN static inline m_bool emit_stmt_break(const Emitter emit, const Stmt_Index stmt NUSED) { - CHECK_BB(emit_defers2(emit)) + CHECK_BB(emit_defers2(emit)); if(stmt->idx == -1 || stmt->idx == 1) vector_add(&emit->code->stack_break, (vtype)emit_add_instr(emit, Goto)); else if(stmt->idx) { @@ -1644,10 +1644,10 @@ ANN static m_bool _emit_stmt_flow(const Emitter emit, const Stmt_Flow stmt, cons (is_while && !stmt->cond->d.prim.d.num)) return GW_OK; } - CHECK_BB(scoped_stmt(emit, stmt->body, 1)) + CHECK_BB(scoped_stmt(emit, stmt->body, 1)); if(stmt->is_do) { if(!is_const) { - CHECK_OB((op = _flow(emit, stmt->cond, !is_while))) + CHECK_OB((op = _flow(emit, stmt->cond, !is_while))); op->m_val = index; } else if((is_while && stmt->cond->d.prim.d.num) || (!is_while && !stmt->cond->d.prim.d.num)) { @@ -1673,7 +1673,7 @@ ANN static m_bool emit_stmt_flow(const Emitter emit, const Stmt_Flow stmt) { ANN static m_bool variadic_state(const Emitter emit, const Stmt_VarLoop stmt, const m_uint status) { regpushi(emit, status); - CHECK_BB(emit_exp(emit, stmt->exp)) + CHECK_BB(emit_exp(emit, stmt->exp)); const Instr member = emit_add_instr(emit, DotMember4); member->m_val = SZ_INT; emit_add_instr(emit, int_r_assign); @@ -1682,8 +1682,8 @@ ANN static m_bool variadic_state(const Emitter emit, const Stmt_VarLoop stmt, co } ANN static m_bool emit_stmt_varloop(const Emitter emit, const Stmt_VarLoop stmt) { - CHECK_BB(variadic_state(emit, stmt, 1)) - CHECK_BB(emit_exp(emit, stmt->exp)) + CHECK_BB(variadic_state(emit, stmt, 1)); + CHECK_BB(emit_exp(emit, stmt->exp)); const Instr s = emit_add_instr(emit, DotMember); s->m_val = SZ_INT * 5; const Instr nonnull = emit_add_instr(emit, Goto); @@ -1695,21 +1695,21 @@ ANN static m_bool emit_stmt_varloop(const Emitter emit, const Stmt_VarLoop stmt) const Instr instr = emit_add_instr(emit, BranchEqInt); const m_uint pc = emit_code_size(emit); emit_stmt(emit, stmt->body, 1); - CHECK_BB(emit_exp(emit, stmt->exp)) + CHECK_BB(emit_exp(emit, stmt->exp)); emit_vararg_end(emit, pc); - CHECK_BB(variadic_state(emit, stmt, 0)) + CHECK_BB(variadic_state(emit, stmt, 0)); check->m_val = instr->m_val = emit_code_size(emit); return GW_OK; } ANN static m_bool _emit_stmt_for(const Emitter emit, const Stmt_For stmt, m_uint *action_index) { - CHECK_BB(emit_stmt(emit, stmt->c1, 1)) + CHECK_BB(emit_stmt(emit, stmt->c1, 1)); const m_uint index = emit_code_size(emit); DECL_OB(const Instr, op, = emit_flow(emit, stmt->c2->d.stmt_exp.val)) - CHECK_BB(scoped_stmt(emit, stmt->body, 1)) + CHECK_BB(scoped_stmt(emit, stmt->body, 1)); *action_index = emit_code_size(emit); if(stmt->c3) { - CHECK_BB(emit_exp(emit, stmt->c3)) + CHECK_BB(emit_exp(emit, stmt->c3)); pop_exp(emit, stmt->c3); } const Instr _goto = emit_add_instr(emit, Goto); @@ -1741,7 +1741,7 @@ ANN static inline m_bool roll(const Emitter emit, const struct Looper *loop) { if(loop->roll) loop->roll(emit, loop); const Instr instr = emit_add_instr(emit, BranchEqInt); - CHECK_BB(scoped_stmt(emit, loop->stmt, 1)) + CHECK_BB(scoped_stmt(emit, loop->stmt, 1)); instr->m_val = emit_code_size(emit) + 1; // pass after goto return GW_OK; } @@ -1770,10 +1770,10 @@ ANN static m_bool unroll(const Emitter emit, const struct Looper *loop) { unroll->m_val = loop->offset; const m_uint start = emit_code_size(emit); const Instr gc = scoped_ini(emit); - CHECK_BB(unroll_run(emit, loop)) + CHECK_BB(unroll_run(emit, loop)); const m_uint end = emit_code_size(emit); for(m_uint i = 1; i < loop->n; ++i) - CHECK_BB(unroll_run(emit, loop)) + CHECK_BB(unroll_run(emit, loop)); unroll->m_val2 = end - start; scoped_end(emit, gc); const Instr unroll2 = emit_add_instr(emit, Unroll2); @@ -1797,7 +1797,7 @@ ANN static m_bool _emit_stmt_each(const Emitter emit, const Stmt_Each stmt, m_ui emit_local(emit, emit->gwion->type[et_int]); } - CHECK_BB(emit_exp(emit, stmt->exp)) // add ref? + CHECK_BB(emit_exp(emit, stmt->exp)); // add ref? regpop(emit, SZ_INT); const m_uint offset = emit_local(emit, emit->gwion->type[et_int]);//array? emit_local(emit, emit->gwion->type[et_int]); @@ -1821,7 +1821,7 @@ ANN static m_bool _emit_stmt_each(const Emitter emit, const Stmt_Each stmt, m_ui .roll=stmt_each_roll, .unroll=stmt_each_unroll }; if(n) loop.offset -= SZ_INT; - CHECK_BB(looper_run(emit, &loop)) + CHECK_BB(looper_run(emit, &loop)); *end_pc = emit_code_size(emit); const Instr tgt = emit_add_instr(emit, Goto); tgt->m_val = ini_pc; @@ -1847,14 +1847,14 @@ ANN static m_bool _emit_stmt_loop(const Emitter emit, const Stmt_Loop stmt, m_ui if(n) unroll_init(emit, n); const m_uint offset = emit_local(emit, emit->gwion->type[et_int]); - CHECK_BB(emit_exp_pop_next(emit, stmt->cond)) + CHECK_BB(emit_exp_pop_next(emit, stmt->cond)); regpop(emit, SZ_INT); const Instr tomem = emit_add_instr(emit, Reg2Mem); tomem->m_val = offset; *index = emit_code_size(emit); struct Looper loop = { .stmt=stmt->body, .offset=offset, .n=n, .roll=stmt_loop_roll }; - CHECK_BB(looper_run(emit, &loop)) + CHECK_BB(looper_run(emit, &loop)); const Instr _goto = emit_add_instr(emit, Goto); _goto->m_val = *index; return GW_OK; @@ -1870,7 +1870,7 @@ ANN static m_bool emit_stmt_loop(const Emitter emit, const Stmt_Loop stmt) { ANN static m_bool emit_type_def(const Emitter emit, const Type_Def tdef) { if(tdef->when) - CHECK_BB(emit_func_def(emit, tdef->when_def)) + CHECK_BB(emit_func_def(emit, tdef->when_def)); return (!is_fptr(emit->gwion, tdef->type) && tdef->type->info->cdef) ? emit_class_def(emit, tdef->type->info->cdef) : GW_OK; } @@ -1915,9 +1915,9 @@ ANN static inline m_bool emit_handler_list(const restrict Emitter emit, const Ha const Vector v) { const Instr instr = emit_add_instr(emit, HandleEffect); instr->m_val2 = (m_uint)handler->xid; - CHECK_BB(scoped_stmt(emit, handler->stmt, 1)) + CHECK_BB(scoped_stmt(emit, handler->stmt, 1)); if(handler->next) - CHECK_BB(emit_handler_list(emit, handler->next, v)) + CHECK_BB(emit_handler_list(emit, handler->next, v)); emit_try_goto(emit, v); instr->m_val = emit_code_size(emit); return GW_OK; @@ -1929,11 +1929,11 @@ ANN static inline m_bool emit_stmt_try(const restrict Emitter emit, const Stmt_T (void)emit_add_instr(emit, TryIni); struct Vector_ v; // store Gotos to the happy path vector_init(&v); - CHECK_BB(scoped_stmt(emit, stmt->stmt, 1)) + CHECK_BB(scoped_stmt(emit, stmt->stmt, 1)); emit_try_goto(emit, &v); if(!emit->code->frame->handlers.ptr) map_init(&emit->code->frame->handlers); - CHECK_BB(emit_handler_list(emit, stmt->handler, &v)) + CHECK_BB(emit_handler_list(emit, stmt->handler, &v)); try_goto_indexes(&v, emit_code_size(emit)); vector_release(&v); emit->code->frame->try_top = top; @@ -1955,15 +1955,15 @@ ANN static inline m_bool emit_exp1(const Emitter emit, const Exp e) { ANN static m_bool emit_case_head(const Emitter emit, const Exp base, const Exp e, const Symbol op, const Vector v) { - CHECK_BB(emit_exp1(emit, base)) + CHECK_BB(emit_exp1(emit, base)); emit_exp_addref1(emit, base, -exp_size(base)); - CHECK_BB(emit_exp1(emit, e)) + CHECK_BB(emit_exp1(emit, e)); emit_exp_addref1(emit, e, -exp_size(e)); const Exp_Binary bin = { .lhs=base, .rhs=e, .op=op }; struct Exp_ ebin = { .d={.exp_binary=bin}, }; struct Op_Import opi = { .op=op, .lhs=base->type, .rhs=e->type, .data=(uintptr_t)&ebin.d.exp_binary, .pos=e->pos }; - CHECK_BB(op_emit(emit, &opi)) + CHECK_BB(op_emit(emit, &opi)); const Instr instr = emit_add_instr(emit, BranchEqInt); vector_add(v, (vtype)instr); return GW_OK; @@ -1972,8 +1972,8 @@ ANN static m_bool emit_case_head(const Emitter emit, const Exp base, ANN static m_bool emit_case_body(const Emitter emit, const struct Stmt_Match_* stmt) { const Instr when = stmt->when ? emit_flow(emit, stmt->when) : NULL; if(stmt->when) - CHECK_OB(when) - CHECK_BB(emit_stmt_list(emit, stmt->list)) + CHECK_OB(when); + CHECK_BB(emit_stmt_list(emit, stmt->list)); const Instr instr = emit_add_instr(emit, Goto); vector_add(&emit->env->scope->match->vec, (vtype)instr); if(when) @@ -2001,11 +2001,11 @@ ANN static Symbol case_op(const Emitter emit, const Exp base, const Exp e, const return CASE_PASS; if(!nspc_lookup_value1(emit->env->curr, e->d.prim.d.var)) { if(!n) { - CHECK_BO(emit_exp(emit, base)) + CHECK_BO(emit_exp(emit, base)); emit_exp_addref(emit, base, -exp_totalsize(base)); regpop(emit, base->type->size); } - CHECK_BO(case_value(emit, base, e)) + CHECK_BO(case_value(emit, base, e)); return CASE_PASS; } } @@ -2018,7 +2018,7 @@ ANN static Symbol case_op(const Emitter emit, const Exp base, const Exp e, const const Value v = (Value)VVAL(map, i); if(v) { if(!n) - CHECK_BO(emit_exp(emit, base)) + CHECK_BO(emit_exp(emit, base)); else regpush(emit, SZ_INT); const Instr check = emit_add_instr(emit, UnionCheck); @@ -2037,12 +2037,12 @@ ANN static Symbol case_op(const Emitter emit, const Exp base, const Exp e, const if(!n) return insert_symbol("=="); regpush(emit, SZ_INT); - CHECK_BO(emit_exp(emit, e)) + CHECK_BO(emit_exp(emit, e)); const Exp_Binary bin = { .lhs=base, .rhs=e, .op=insert_symbol("==") }; struct Exp_ ebin = { .d={.exp_binary=bin}, }; struct Op_Import opi = { .op=insert_symbol("=="), .lhs=base->type, .rhs=e->type, .data=(uintptr_t)&ebin.d.exp_binary, .pos=e->pos }; - CHECK_BO(op_emit(emit, &opi)) + CHECK_BO(op_emit(emit, &opi)); const Instr instr = emit_add_instr(emit, BranchEqInt); vector_add(vec, (vtype)instr); return CASE_PASS; @@ -2056,9 +2056,9 @@ ANN static m_bool _emit_stmt_match_case(const Emitter emit, const struct Stmt_Ma const Exp base = (Exp)vector_at(cond, i); const Symbol op = case_op(emit, base, e, v, 0); if(op != CASE_PASS) - CHECK_BB(emit_case_head(emit, base, e, op, v)) + CHECK_BB(emit_case_head(emit, base, e, op, v)); } - CHECK_BB(emit_case_body(emit, stmt)) + CHECK_BB(emit_case_body(emit, stmt)); return GW_OK; } @@ -2086,14 +2086,14 @@ ANN static inline void match_unvec(struct Match_ *const match, const m_uint pc) } ANN static m_bool emit_stmt_cases(const Emitter emit, Stmt_List list) { - do CHECK_BB(emit_stmt_match_case(emit, &list->stmt->d.stmt_match)) + do CHECK_BB(emit_stmt_match_case(emit, &list->stmt->d.stmt_match)); while((list = list->next)); return GW_OK; } ANN static m_bool emit_match(const Emitter emit, const struct Stmt_Match_* stmt) { if(stmt->where) - CHECK_BB(emit_stmt(emit, stmt->where, 1)) + CHECK_BB(emit_stmt(emit, stmt->where, 1)); MATCH_INI(emit->env->scope) vector_init(&m.vec); const m_bool ret = emit_stmt_cases(emit, stmt->list); @@ -2136,7 +2136,7 @@ ANN static m_bool emit_stmt_retry(const Emitter emit, const struct Stmt_Index_* DECL_STMT_FUNC(emit, m_bool , Emitter) ANN static m_bool emit_stmt(const Emitter emit, const Stmt stmt, const m_bool pop) { - CHECK_BB(emit_stmt_func[stmt->stmt_type](emit, &stmt->d)) + CHECK_BB(emit_stmt_func[stmt->stmt_type](emit, &stmt->d)); if(pop && stmt->stmt_type == ae_stmt_exp && stmt->d.stmt_exp.val) { pop_exp(emit, stmt->d.stmt_exp.val); } @@ -2144,7 +2144,7 @@ ANN static m_bool emit_stmt(const Emitter emit, const Stmt stmt, const m_bool po } ANN static m_bool emit_stmt_list(const Emitter emit, Stmt_List l) { - do CHECK_BB(emit_stmt(emit, l->stmt, 1)) + do CHECK_BB(emit_stmt(emit, l->stmt, 1)); while((l = l->next)); return GW_OK; } @@ -2187,7 +2187,7 @@ ANN static void emit_func_def_ensure(const Emitter emit, const Func_Def fdef) { ANN static m_bool emit_func_def_return(const Emitter emit) { const m_uint val = emit_code_size(emit); - CHECK_BB(emit_defers(emit)) + CHECK_BB(emit_defers(emit)); LOOP_OPTIM for(m_uint i = vector_size(&emit->code->stack_return) + 1; --i; ) { const Instr instr = (Instr)vector_at(&emit->code->stack_return, i-1); @@ -2232,7 +2232,7 @@ ANN static m_bool emit_func_def_body(const Emitter emit, const Func_Def fdef) { if(fbflag(fdef->base, fbflag_variadic)) stack_alloc(emit); if(fdef->d.code) - CHECK_BB(scoped_stmt(emit, fdef->d.code, 1)) + CHECK_BB(scoped_stmt(emit, fdef->d.code, 1)); emit_func_def_ensure(emit, fdef); return GW_OK; } @@ -2274,7 +2274,7 @@ ANN static void me_ret(MemoizeEmitter *me) { ANN static m_bool me_run(MemoizeEmitter *me, const m_uint pc) { me_ini(me); if(me->fdef->base->args) - CHECK_BB(me_arg(me)) + CHECK_BB(me_arg(me)); me_ret(me); me_end(me, emit_code_size(me->emit)); me_bottom(me, pc); @@ -2294,8 +2294,8 @@ ANN static m_bool emit_memoize(const Emitter emit, const Func_Def fdef) { ANN static m_bool emit_fdef(const Emitter emit, const Func_Def fdef) { if(emit->info->memoize && fflag(fdef->base->func, fflag_pure)) - CHECK_BB(emit_memoize(emit, fdef)) - CHECK_BB(emit_func_def_body(emit, fdef)) + CHECK_BB(emit_memoize(emit, fdef)); + CHECK_BB(emit_func_def_body(emit, fdef)); emit_func_def_return(emit); return GW_OK; } @@ -2358,14 +2358,14 @@ ANN static m_bool emit_extend_def(const Emitter emit, const Extend_Def xdef); HANDLE_SECTION_FUNC(emit, m_bool, Emitter) ANN static inline m_bool emit_ast_inner(const Emitter emit, Ast ast) { - do CHECK_BB(emit_section(emit, ast->section)) + do CHECK_BB(emit_section(emit, ast->section)); while((ast = ast->next)); return emit_defers(emit); } ANN static m_bool emit_extend_def(const Emitter emit, const Extend_Def xdef) { - CHECK_BB(ensure_emit(emit, xdef->t)) - CHECK_BB(extend_push(emit->env, xdef->t)) + CHECK_BB(ensure_emit(emit, xdef->t)); + CHECK_BB(extend_push(emit->env, xdef->t)); const m_bool ret = emit_ast_inner(emit, xdef->body); extend_pop(emit->env, xdef->t); return ret; @@ -2392,7 +2392,7 @@ ANN /*static */inline m_bool emit_cdef(const Emitter emit, const Type t) { ANN static m_bool cdef_parent(const Emitter emit, const Class_Def cdef) { if(cdef->base.tmpl && cdef->base.tmpl->list) - CHECK_BB(template_push_types(emit->env, cdef->base.tmpl)) + CHECK_BB(template_push_types(emit->env, cdef->base.tmpl)); const m_bool ret = emit_parent(emit, cdef); if(cdef->base.tmpl && cdef->base.tmpl->list) nspc_pop_type(emit->gwion->mp, emit->env->curr); @@ -2408,9 +2408,9 @@ ANN static m_bool emit_class_def(const Emitter emit, const Class_Def cdef) { set_tflag(t, tflag_emit); const Type owner = t->info->value->from->owner_class; if(owner) - CHECK_BB(ensure_emit(emit, owner)) + CHECK_BB(ensure_emit(emit, owner)); if(cdef->base.ext && t->info->parent->info->cdef && !tflag(t->info->parent, tflag_emit)) // ????? - CHECK_BB(cdef_parent(emit, cdef)) + CHECK_BB(cdef_parent(emit, cdef)); nspc_allocdata(emit->gwion->mp, t->nspc); if(cdef->body) { emit_class_code(emit, t->name); diff --git a/src/emit/escape.c b/src/emit/escape.c index c7cb9cd4..e8c943cc 100644 --- a/src/emit/escape.c +++ b/src/emit/escape.c @@ -62,7 +62,7 @@ m_bool escape_str(const Emitter emit, const m_str base, const loc_t pos) { return GW_ERROR; } } else - CHECK_BB((*str++ = (char)get_escape(emit, (char)c, pos))) + CHECK_BB((*str++ = (char)get_escape(emit, (char)c, pos))); } else *str++ = (char)*str_lit; diff --git a/src/env/env_utils.c b/src/env/env_utils.c index 5d7d7ea5..2bac3459 100644 --- a/src/env/env_utils.c +++ b/src/env/env_utils.c @@ -20,7 +20,7 @@ ANN m_bool env_access(const Env env, const ae_flag flag, const loc_t pos) { } ANN m_bool env_storage(const Env env, ae_flag flag, const loc_t pos) { - CHECK_BB(env_access(env, flag, pos)) + CHECK_BB(env_access(env, flag, pos)); return !(env->class_def && GET(flag, ae_flag_global)) ? GW_OK :GW_ERROR; } #undef GET diff --git a/src/env/envset.c b/src/env/envset.c index b733ff1a..52d59559 100644 --- a/src/env/envset.c +++ b/src/env/envset.c @@ -21,14 +21,14 @@ ANN static m_bool push(struct EnvSet *es, const Type t) { es->env->scope->depth = 0; const Type owner_class = t->info->value->from->owner_class; if(owner_class) - CHECK_BB(push(es, owner_class)) + CHECK_BB(push(es, owner_class)); else env_push(es->env, NULL, t->info->value->from->ctx ? t->info->value->from->ctx->nspc : es->env->curr); if(es->func && !(t->tflag & es->flag)) - CHECK_BB(es->func((void*)es->data, t)) + CHECK_BB(es->func((void*)es->data, t)); env_push_type((void*)es->env, t); if(tflag(t, tflag_tmpl)) - CHECK_BB(template_push_types(es->env, t->info->cdef->base.tmpl)) // incorrect templates? + CHECK_BB(template_push_types(es->env, t->info->cdef->base.tmpl)); // incorrect templates? return GW_OK; } @@ -61,7 +61,7 @@ ANN m_bool envset_run(struct EnvSet *es, const Type t) { check(es, t); const Type owner_class = t->info->value->from->owner_class; if(es->run) - CHECK_BB(push(es, owner_class)) + CHECK_BB(push(es, owner_class)); const m_bool ret = t->info->cdef && !(t->tflag & es->flag) ? es->func(es->data, t) : GW_OK; diff --git a/src/env/func.c b/src/env/func.c index da91ce56..893eee7e 100644 --- a/src/env/func.c +++ b/src/env/func.c @@ -33,7 +33,7 @@ ANN2(1,2) Symbol func_symbol(const Env env, const m_str nspc, const m_str base, char name[len + 1]; CHECK_BO(sprintf(name, "%s%s%s%s@%" UINT_F "@%s", base, !tmpl ? "" : ":[", !tmpl ? "" : tmpl, !tmpl ? "" : "]", - i, nspc)) + i, nspc)); return insert_symbol(env->gwion->st, name); } diff --git a/src/gwion.c b/src/gwion.c index 545d2d0f..361f96d2 100644 --- a/src/gwion.c +++ b/src/gwion.c @@ -23,7 +23,7 @@ ANN m_bool gwion_audio(const Gwion gwion) { if(di->si->arg) driver_ini(gwion); di->func(di->driver); - CHECK_BB(di->driver->ini(gwion->vm, di)); + CHECK_BB(di->driver->ini(gwion->vm, di));; driver_alloc(di); return GW_OK; } @@ -61,7 +61,7 @@ ANN static void gwion_core(const Gwion gwion) { } ANN static m_bool gwion_ok(const Gwion gwion, Arg* arg) { - CHECK_BB(plug_ini(gwion, &arg->lib)) + CHECK_BB(plug_ini(gwion, &arg->lib)); shreduler_set_loop(gwion->vm->shreduler, arg->loop); if(gwion_audio(gwion) > 0) { plug_run(gwion, &arg->mod); @@ -92,7 +92,7 @@ ANN m_bool gwion_ini(const Gwion gwion, Arg* arg) { gwion->type = (Type*)xcalloc(MAX_TYPE, sizeof(struct Type_*)); pass_default(gwion); arg->si = gwion->vm->bbq->si = new_soundinfo(gwion->mp); - CHECK_BB(arg_parse(gwion, arg)) + CHECK_BB(arg_parse(gwion, arg)); if(arg->color == COLOR_NEVER) tcol_override_color_checks(0); else if(arg->color == COLOR_AUTO) diff --git a/src/import/import_cdef.c b/src/import/import_cdef.c index ce372094..327bffbf 100644 --- a/src/import/import_cdef.c +++ b/src/import/import_cdef.c @@ -68,11 +68,11 @@ ANN static Type type_finish(const Gwi gwi, const Type t) { ANN2(1,2) Type gwi_class_ini(const Gwi gwi, const m_str name, const m_str parent) { struct ImportCK ck = { .name=name }; - CHECK_BO(check_typename_def(gwi, &ck)) + CHECK_BO(check_typename_def(gwi, &ck)); DECL_OO(Type_Decl *,td, = gwi_str2td(gwi, parent ?: "Object")) Tmpl* tmpl = ck.tmpl ? new_tmpl_base(gwi->gwion->mp, ck.tmpl) : NULL; if(tmpl) - CHECK_BO(template_push_types(gwi->gwion->env, tmpl)) + CHECK_BO(template_push_types(gwi->gwion->env, tmpl)); const Type base = find_type(gwi->gwion->env, td); const Type_List tl = td->types; if(tflag(base, tflag_ntmpl)) @@ -81,7 +81,7 @@ ANN2(1,2) Type gwi_class_ini(const Gwi gwi, const m_str name, const m_str parent td->types = tl; if(tmpl) nspc_pop_type(gwi->gwion->mp, gwi->gwion->env->curr); - CHECK_OO(p) + CHECK_OO(p); const Type t = new_type(gwi->gwion->mp, s_name(ck.sym), p); t->info->cdef = new_class_def(gwi->gwion->mp, 0, ck.sym, td, NULL, gwi->loc); t->info->cdef->base.tmpl = tmpl; @@ -99,7 +99,7 @@ ANN2(1,2) Type gwi_class_ini(const Gwi gwi, const m_str name, const m_str parent ANN Type gwi_struct_ini(const Gwi gwi, const m_str name) { struct ImportCK ck = { .name=name }; - CHECK_BO(check_typename_def(gwi, &ck)) + CHECK_BO(check_typename_def(gwi, &ck)); const Type t = new_type(gwi->gwion->mp, s_name(ck.sym), gwi->gwion->type[et_compound]); set_tflag(t, tflag_struct); if(!ck.tmpl) diff --git a/src/import/import_checker.c b/src/import/import_checker.c index d1ceb775..221c3f0f 100644 --- a/src/import/import_checker.c +++ b/src/import/import_checker.c @@ -81,7 +81,7 @@ ANN Var_Decl str2var(const Gwion gwion, const m_str path, const loc_t pos) { struct td_checker tdc = { .str=path, .pos=pos }; DECL_OO(const Symbol, sym, = __str2sym(gwion, &tdc)) struct AC ac = { .str = tdc.str, .pos=pos }; - CHECK_BO(ac_run(gwion, &ac)) + CHECK_BO(ac_run(gwion, &ac)); const Array_Sub array = ac.depth ? mk_array(gwion->mp, &ac) : NULL; return new_var_decl(gwion->mp, sym, array, pos); @@ -187,7 +187,7 @@ ANN static Type_Decl* _str2td(const Gwion gwion, struct td_checker *tdc) { const uint ref = get_n(tdc, '&'); DECL_OO(const Symbol, sym, = __str2sym(gwion, tdc)) struct AC ac = { .str = tdc->str, .pos=tdc->pos }; - CHECK_BO(ac_run(gwion, &ac)) + CHECK_BO(ac_run(gwion, &ac)); tdc->str = ac.str; Type_List tl = td_tmpl(gwion, tdc); if(tl == (Type_List)GW_ERROR) @@ -269,7 +269,7 @@ ANEW ANN m_str type2str(const Gwion gwion, const Type t, const loc_t pos NUSED) ANEW ANN m_str tl2str(const Gwion gwion, const Type_List tl, const loc_t pos NUSED) { struct td_info info = { .tl=tl, { .mp=gwion->mp} }; - CHECK_BO(td_info_run(gwion->env, &info)) + CHECK_BO(td_info_run(gwion->env, &info)); return info.text.str; } @@ -307,14 +307,14 @@ ANN static inline m_bool ac_noexp(const Gwion gwion, struct AC *ac) { ANN static m_bool _ac_run(const Gwion gwion, struct AC *const ac) { const m_str str = ac->str; const m_int num = strtol(str, &ac->str, 10); - CHECK_BB(ac_finish(gwion, ac)) + CHECK_BB(ac_finish(gwion, ac)); if(str != ac->str) { - CHECK_BB(ac_num(gwion, ac, num)) - CHECK_BB(ac_exp(gwion, ac)) + CHECK_BB(ac_num(gwion, ac, num)); + CHECK_BB(ac_exp(gwion, ac)); const Exp exp = new_prim_int(gwion->mp, num, ac->pos); ac_add_exp(ac, exp); } else - CHECK_BB(ac_noexp(gwion, ac)) + CHECK_BB(ac_noexp(gwion, ac)); ++ac->str; return GW_OK; } @@ -324,7 +324,7 @@ ANN static m_bool ac_run(const Gwion gwion, struct AC *const ac) { if(*ac->str != '[') break; ++ac->str; - CHECK_BB(_ac_run(gwion, ac)) + CHECK_BB(_ac_run(gwion, ac)); ++ac->depth; } return GW_OK; diff --git a/src/import/import_enum.c b/src/import/import_enum.c index f48233af..8bda119b 100644 --- a/src/import/import_enum.c +++ b/src/import/import_enum.c @@ -19,9 +19,9 @@ //! \arg string defining a primitive type //! why is return type m_int ? ANN2(1) m_int gwi_enum_ini(const Gwi gwi, const m_str type) { - CHECK_BB(ck_ini(gwi, ck_edef)) + CHECK_BB(ck_ini(gwi, ck_edef)); if(type) - CHECK_OB((gwi->ck->xid = gwi_str2sym(gwi, type))) + CHECK_OB((gwi->ck->xid = gwi_str2sym(gwi, type))); vector_init(&gwi->ck->v); return GW_OK; } @@ -48,7 +48,7 @@ void Append(DL_Enum* d, const ID_List list) { //! \arg name of the entry //! TODO: change return type to m_bool ANN m_int gwi_enum_add(const Gwi gwi, const m_str name, const m_uint i) { - CHECK_BB(ck_ok(gwi, ck_edef)) + CHECK_BB(ck_ok(gwi, ck_edef)); DECL_OB(const ID_List, list, = gwi_str2symlist(gwi, name)) add2list(gwi->ck, list); vector_add(&gwi->ck->v, (vtype)i); @@ -74,7 +74,7 @@ ANN static void import_enum_end(const Gwi gwi, const Vector v) { //! \arg the importer //! TODO: check what happens in inside template class ANN Type gwi_enum_end(const Gwi gwi) { - CHECK_BO(ck_ok(gwi, ck_edef)) + CHECK_BO(ck_ok(gwi, ck_edef)); if(!vector_size(&gwi->ck->v)) GWI_ERR_O("Enum is empty"); const Gwion gwion = gwi->gwion; diff --git a/src/import/import_fdef.c b/src/import/import_fdef.c index ad6f7e2e..101c6498 100644 --- a/src/import/import_fdef.c +++ b/src/import/import_fdef.c @@ -17,10 +17,10 @@ ANN2(1,2,3) static m_bool dl_func_init(const Gwi gwi, const restrict m_str t, const restrict m_str n) { - CHECK_BB(ck_ini(gwi, ck_fdef)) + CHECK_BB(ck_ini(gwi, ck_fdef)); gwi->ck->name = n; - CHECK_BB(check_typename_def(gwi, gwi->ck)) - CHECK_OB((gwi->ck->td = gwi_str2td(gwi, t))) + CHECK_BB(check_typename_def(gwi, gwi->ck)); + CHECK_OB((gwi->ck->td = gwi_str2td(gwi, t))); vector_init(&gwi->ck->v); return GW_OK; } @@ -80,7 +80,7 @@ ANN m_int gwi_func_valid(const Gwi gwi, ImportCK *ck) { } ANN m_int gwi_func_end(const Gwi gwi, const f_xfun addr, const ae_flag flag) { - CHECK_BB(ck_ok(gwi, ck_fdef)) + CHECK_BB(ck_ok(gwi, ck_fdef)); gwi->ck->addr = addr; gwi->ck->flag = flag; const m_bool ret = gwi_func_valid(gwi, gwi->ck); @@ -89,7 +89,7 @@ ANN m_int gwi_func_end(const Gwi gwi, const f_xfun addr, const ae_flag flag) { } ANN m_int gwi_func_arg(const Gwi gwi, const restrict m_str t, const restrict m_str n) { - CHECK_BB(ck_ok(gwi, ck_fdef)) + CHECK_BB(ck_ok(gwi, ck_fdef)); if(gwi->ck->variadic) GWI_ERR_B(_("already declared as variadic")); if(!strcmp(n, "...")) { @@ -124,7 +124,7 @@ ANN static m_bool section_fptr(const Gwi gwi, const Fptr_Def fdef) { } ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) { - CHECK_BO(ck_ok(gwi, ck_fdef)) + CHECK_BO(ck_ok(gwi, ck_fdef)); DECL_OO(const Fptr_Def, fptr, = import_fptr(gwi)) fptr->base->flag |= flag; if(safe_tflag(gwi->gwion->env->class_def, tflag_tmpl)/* && !fptr->base->tmpl*/) { diff --git a/src/import/import_item.c b/src/import/import_item.c index 129c35a2..5b2f59f0 100644 --- a/src/import/import_item.c +++ b/src/import/import_item.c @@ -11,7 +11,7 @@ #include "gwi.h" ANN m_int gwi_item_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) { - CHECK_BB(ck_ini(gwi, ck_item)) + CHECK_BB(ck_ini(gwi, ck_item)); if((gwi->ck->exp = make_exp(gwi, type, name))) return GW_OK; GWI_ERR_B(_(" ... during var import '%s.%s'."), gwi->gwion->env->name, name) @@ -31,12 +31,12 @@ ANN static m_int gwi_item_tmpl(const Gwi gwi) { #undef gwi_item_end ANN2(1) m_int gwi_item_end(const Gwi gwi, const ae_flag flag, union value_data addr) { - CHECK_BB(ck_ok(gwi, ck_item)) + CHECK_BB(ck_ok(gwi, ck_item)); const Env env = gwi->gwion->env; gwi->ck->exp->d.exp_decl.td->flag = flag; if(env->class_def && tflag(env->class_def, tflag_tmpl)) return gwi_item_tmpl(gwi); - CHECK_BB(traverse_exp(env, gwi->ck->exp)) + CHECK_BB(traverse_exp(env, gwi->ck->exp)); const Value value = gwi->ck->exp->d.exp_decl.list->self->value; value->d = addr; set_vflag(value, vflag_builtin); diff --git a/src/import/import_tdef.c b/src/import/import_tdef.c index 9df5ea6d..0f6d7f30 100644 --- a/src/import/import_tdef.c +++ b/src/import/import_tdef.c @@ -17,14 +17,14 @@ #include "specialid.h" ANN m_int gwi_typedef_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) { - CHECK_BB(ck_ini(gwi, ck_tdef)) + CHECK_BB(ck_ini(gwi, ck_tdef)); gwi->ck->name = name; - CHECK_BB(check_typename_def(gwi, gwi->ck)) + CHECK_BB(check_typename_def(gwi, gwi->ck)); return (gwi->ck->td = gwi_str2td(gwi, type)) ? GW_OK : GW_ERROR; } ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag) { - CHECK_BO(ck_ok(gwi, ck_tdef)) + CHECK_BO(ck_ok(gwi, ck_tdef)); Type_Decl *td = gwi->ck->td; td->flag |= flag; const Type_Def tdef = new_type_def(gwi->gwion->mp, td, gwi->ck->sym, gwi->loc); diff --git a/src/import/import_type.c b/src/import/import_type.c index bfca8fbb..51f772a2 100644 --- a/src/import/import_type.c +++ b/src/import/import_type.c @@ -30,7 +30,7 @@ ANN2(1) static Type get_parent(const Gwi gwi, const m_str parent_name) { } ANN2(1,2) Type gwi_mk_type(const Gwi gwi, const m_str name, const m_uint size, const m_str parent_name) { - CHECK_OO(gwi_str2sym(gwi, name)) + CHECK_OO(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 4efd3884..759a5ddb 100644 --- a/src/import/import_udef.c +++ b/src/import/import_udef.c @@ -25,14 +25,14 @@ ANN Exp make_exp(const Gwi gwi, const m_str type, const m_str name) { } ANN m_int gwi_union_ini(const Gwi gwi, const m_str name) { - CHECK_BB(ck_ini(gwi, ck_udef)) + CHECK_BB(ck_ini(gwi, ck_udef)); gwi->ck->name = name; - CHECK_BB(check_typename_def(gwi, gwi->ck)) + CHECK_BB(check_typename_def(gwi, gwi->ck)); return GW_OK; } ANN m_int gwi_union_add(const Gwi gwi, const restrict m_str type, const restrict m_str name) { - CHECK_BB(ck_ok(gwi, ck_udef)) + CHECK_BB(ck_ok(gwi, ck_udef)); DECL_OB(Type_Decl*, td, = str2td(gwi->gwion, type, gwi->loc)) DECL_OB(const Symbol, xid, = str2sym(gwi->gwion, name, gwi->loc)) const Union_List l = new_union_list(gwi->gwion->mp, td, xid, gwi->loc); @@ -42,8 +42,8 @@ ANN m_int gwi_union_add(const Gwi gwi, const restrict m_str type, const restrict } ANN static Type union_type(const Gwi gwi, const Union_Def udef) { - CHECK_BO(scan0_union_def(gwi->gwion->env, udef)) - CHECK_BO(traverse_union_def(gwi->gwion->env, udef)) + CHECK_BO(scan0_union_def(gwi->gwion->env, udef)); + CHECK_BO(traverse_union_def(gwi->gwion->env, udef)); // if(!udef->tmpl) // emit_union_offset(udef->l, udef->o); // if(gwi->gwion->env->class_def && !GET_FLAG(udef, static)) @@ -56,7 +56,7 @@ ANN static Type union_type(const Gwi gwi, const Union_Def udef) { } ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag) { - CHECK_BO(ck_ok(gwi, ck_udef)) + CHECK_BO(ck_ok(gwi, ck_udef)); if(!gwi->ck->list) GWI_ERR_O(_("union is empty")); const Union_Def udef = new_union_def(gwi->gwion->mp, gwi->ck->list, gwi->loc); diff --git a/src/lib/array.c b/src/lib/array.c index ff4e74e3..1874ef37 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -250,7 +250,7 @@ static OP_CHECK(opck_array_slice) { } static inline m_bool bounds(const M_Vector v, const m_int i) { - CHECK_BB(i) + CHECK_BB(i); return (m_uint)i < ARRAY_LEN(v) ? GW_OK : GW_ERROR; } @@ -333,7 +333,7 @@ ANN static void array_finish(const Emitter emit, const m_uint depth, ANN static inline m_bool array_do(const Emitter emit, const Array_Sub array, const m_bool is_var) { emit_gc(emit, -SZ_INT); - CHECK_BB(emit_exp(emit, array->exp)) + CHECK_BB(emit_exp(emit, array->exp)); array_loop(emit, array->depth); array_finish(emit, array->depth, array->type->size, is_var); return GW_OK; diff --git a/src/lib/engine.c b/src/lib/engine.c index 5525687c..94e9f968 100644 --- a/src/lib/engine.c +++ b/src/lib/engine.c @@ -184,7 +184,7 @@ ANN static m_bool import_core_libs(const Gwi gwi) { ANN m_bool type_engine_init(const Gwion gwion) { gwion->env->name = "[builtin]"; - CHECK_BB(gwi_run(gwion, import_core_libs)) + CHECK_BB(gwi_run(gwion, import_core_libs)); push_global(gwion, "[user]"); return GW_OK; } diff --git a/src/lib/instr.c b/src/lib/instr.c index 97babcb4..35ae9d14 100644 --- a/src/lib/instr.c +++ b/src/lib/instr.c @@ -46,7 +46,7 @@ ANN static Func_Def from_base(const Env env, struct dottmpl_ *const dt, const Ns ANN static Func_Def traverse_tmpl(const Emitter emit, struct dottmpl_ *const dt, const Nspc nspc) { DECL_OO(const Func_Def, def, = from_base(emit->env, dt, nspc)) - CHECK_BO(traverse_dot_tmpl(emit, dt)) + CHECK_BO(traverse_dot_tmpl(emit, dt)); if(dt->xfun) builtin_func(emit->gwion->mp, def->base->func, dt->xfun); return def; diff --git a/src/lib/lib_func.c b/src/lib/lib_func.c index d101d108..701f5b65 100644 --- a/src/lib/lib_func.c +++ b/src/lib/lib_func.c @@ -91,12 +91,12 @@ static m_bool td_match(const Env env, Type_Decl *id[2]) { ANN static m_bool fptr_args(const Env env, Func_Base *base[2]) { Arg_List arg0 = base[0]->args, arg1 = base[1]->args; while(arg0) { - CHECK_OB(arg1) + CHECK_OB(arg1); if(arg0->type && arg1->type) - CHECK_BB(isa(arg0->type, arg1->type)) + CHECK_BB(isa(arg0->type, arg1->type)); else { Type_Decl* td[2] = { arg0->td, arg1->td }; - CHECK_BB(td_match(env, td)) + CHECK_BB(td_match(env, td)); } arg0 = arg0->next; arg1 = arg1->next; @@ -174,7 +174,7 @@ ANN static Type fptr_type(const Env env, struct FptrInfo *info) { } Type type = NULL; Func_Base *base[2] = { info->lhs->def->base, info->rhs->def->base }; - CHECK_BO(fptr_tmpl_push(env, info)) + CHECK_BO(fptr_tmpl_push(env, info)); if (fptr_rettype(env, info) > 0 && fptr_arity(info) && fptr_args(env, base) > 0 && fptr_effects(env, info)) type = actual_type(env->gwion, info->lhs->value_ref->type) ?: info->lhs->value_ref->type; @@ -226,14 +226,14 @@ ANN m_bool check_lambda(const Env env, const Type t, Exp_Lambda *l) { const Func_Def fdef = t->info->func->def; if(!GET_FLAG(t->info->func->value_ref, global)) l->owner = t->info->value->from->owner_class; - CHECK_BB(_check_lambda(env, l, fdef)) + CHECK_BB(_check_lambda(env, l, fdef)); exp_self(l)->type = l->def->base->func->value_ref->type; return GW_OK; } ANN static m_bool fptr_do(const Env env, struct FptrInfo *info) { if(isa(info->exp->type, env->gwion->type[et_lambda]) < 0) { - CHECK_BB(fptr_check(env, info)) + CHECK_BB(fptr_check(env, info)); if(!(info->exp->type = fptr_type(env, info))) ERR_B(info->pos, _("no match found")) return GW_OK; @@ -362,7 +362,7 @@ static m_bool op_call_narg(const Env env, Exp arg, } ANN Type check_op_call(const Env env, Exp_Call *const exp) { - CHECK_BO(op_call_narg(env, exp->args, exp->func->pos)) + CHECK_BO(op_call_narg(env, exp->args, exp->func->pos)); const Exp base = exp_self(exp); const Exp op_exp = exp->func; base->exp_type = ae_exp_binary; diff --git a/src/lib/object_op.c b/src/lib/object_op.c index 71bff20b..43781586 100644 --- a/src/lib/object_op.c +++ b/src/lib/object_op.c @@ -202,7 +202,7 @@ OP_EMIT(opem_object_dot) { (isa(exp_self(member)->type, emit->gwion->type[et_function]) > 0 && !is_fptr(emit->gwion, exp_self(member)->type)))) { if(!tflag(t_base, tflag_struct)) - CHECK_BB(emit_exp(emit, member->base)) + CHECK_BB(emit_exp(emit, member->base)); } if(isa(exp_self(member)->type, emit->gwion->type[et_function]) > 0 && !is_fptr(emit->gwion, exp_self(member)->type)) emit_member_func(emit, member); @@ -211,7 +211,7 @@ OP_EMIT(opem_object_dot) { emit_member(emit, value, exp_getvar(exp_self(member))); else { exp_setvar(member->base, 1); - CHECK_BB(emit_exp(emit, member->base)) + CHECK_BB(emit_exp(emit, member->base)); emit_struct_data(emit, value, exp_getvar(exp_self(member))); } } else if(GET_FLAG(value, static)) @@ -262,9 +262,9 @@ ANN static m_bool scantmpl_union_def(const Env env, struct tmpl_info *info) { ANN static Type _scan_class(const Env env, struct tmpl_info *info) { if(info->base->info->parent != env->gwion->type[et_union]) - CHECK_BO(scantmpl_class_def(env, info)) + CHECK_BO(scantmpl_class_def(env, info)); else - CHECK_BO(scantmpl_union_def(env, info)) + CHECK_BO(scantmpl_union_def(env, info)); return info->ret; } @@ -277,7 +277,7 @@ ANN Type scan_class(const Env env, const Type t, const Type_Decl *td) { struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)scan0_cdef, .scope=env->scope->depth, .flag=tflag_scan0 }; const Type owner = t->info->value->from->owner_class; - CHECK_BO(envset_push(&es, owner, t->info->value->from->owner)) + CHECK_BO(envset_push(&es, owner, t->info->value->from->owner)); const Type ret = _scan_class(env, &info); if(es.run) envset_pop(&es, owner); diff --git a/src/lib/opfunc.c b/src/lib/opfunc.c index 221ffbac..70a9fe3d 100644 --- a/src/lib/opfunc.c +++ b/src/lib/opfunc.c @@ -113,7 +113,7 @@ OP_CHECK(opck_new) { OP_EMIT(opem_new) { const Exp_Unary* unary = (Exp_Unary*)data; CHECK_BB(emit_instantiate_object(emit, exp_self(unary)->type, - unary->td->array, 0)) + unary->td->array, 0)); emit_gc(emit, -SZ_INT); return GW_OK; } diff --git a/src/lib/string.c b/src/lib/string.c index 91deae64..2e8372bf 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -70,7 +70,7 @@ static GACK(gack_string) { } static inline m_bool bounds(const m_str str, const m_int i) { - CHECK_BB(i) + CHECK_BB(i); return (m_uint)i < strlen(str) ? GW_OK : GW_ERROR; } diff --git a/src/lib/union.c b/src/lib/union.c index 06afa9aa..c4c46a10 100644 --- a/src/lib/union.c +++ b/src/lib/union.c @@ -36,7 +36,7 @@ ANN Instr emit_kind(Emitter emit, const m_uint size, const uint addr, const f_in static OP_EMIT(opem_union_dot) { const Exp_Dot *member = (Exp_Dot*)data; const Map map = &member->base->type->nspc->info->value->map; - CHECK_BB(emit_exp(emit, member->base)) + CHECK_BB(emit_exp(emit, member->base)); if(isa(exp_self(member)->type, emit->gwion->type[et_function]) > 0) { const Instr instr = emit_add_instr(emit, RegPushImm); const Func f = (Func)vector_front(&member->base->type->info->parent->nspc->info->vtable); @@ -183,7 +183,7 @@ ANN GWION_IMPORT(union) { const struct Op_Func opfunc = { .ck=opck_union_is }; const struct Op_Import opi = { .rhs=f->value_ref->type, .func=&opfunc, .data=(uintptr_t)f, .pos=gwi->loc, .op=insert_symbol(gwi->gwion->st, "@func_check") }; - CHECK_BB(add_op(gwi->gwion, &opi)) + CHECK_BB(add_op(gwi->gwion, &opi)); gwi->gwion->type[et_union] = t_union; GWI_BB(gwi_oper_ini(gwi, "@Union", (m_str)OP_ANY_TYPE, NULL)) diff --git a/src/parse/check.c b/src/parse/check.c index 31d24917..13335767 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -34,11 +34,11 @@ ANN m_bool check_implicit(const Env env, const Exp e, const Type t) { } ANN m_bool check_subscripts(Env env, const Array_Sub array, const m_bool is_decl) { - CHECK_OB(check_exp(env, array->exp)) + CHECK_OB(check_exp(env, array->exp)); m_uint depth = 0; Exp e = array->exp; do if(is_decl) - CHECK_BB(check_implicit(env, e, env->gwion->type[et_int])) + CHECK_BB(check_implicit(env, e, env->gwion->type[et_int])); while(++depth && (e = e->next)); if(depth != array->depth) ERR_B(array->exp->pos, _("invalid array acces expression.")) @@ -86,7 +86,7 @@ ANN static m_bool check_fptr_decl(const Env env, const Var_Decl var) { ANN static m_bool check_var(const Env env, const Var_Decl var) { if(env->class_def && !env->scope->depth && env->class_def->info->parent) - CHECK_BB(check_exp_decl_parent(env, var)) + CHECK_BB(check_exp_decl_parent(env, var)); if(var->array && var->array->exp) return check_subscripts(env, var->array, 1); return GW_OK; @@ -109,10 +109,10 @@ ANN static m_bool check_decl(const Env env, const Exp_Decl *decl) { Var_Decl_List list = decl->list; do { const Var_Decl var = list->self; - CHECK_BB(check_var(env, var)) - CHECK_BB(check_var_td(env, var, decl->td)) + CHECK_BB(check_var(env, var)); + CHECK_BB(check_var_td(env, var, decl->td)); if(is_fptr(env->gwion, decl->type)) - CHECK_BB(check_fptr_decl(env, var)) + CHECK_BB(check_fptr_decl(env, var)); set_vflag(var->value, vflag_valid); //set_vflag(var->value, vflag_used)); nspc_add_value(env->curr, var->xid, var->value); @@ -144,16 +144,16 @@ ANN static inline m_bool inferable(const Env env, const Type t, const loc_t pos) ANN Type check_exp_decl(const Env env, const Exp_Decl* decl) { if(decl->td->array && decl->td->array->exp) - CHECK_OO(check_exp(env, decl->td->array->exp)) + CHECK_OO(check_exp(env, decl->td->array->exp)); if(decl->td->xid == insert_symbol("auto")) { // should be better - CHECK_BO(scan1_exp(env, exp_self(decl))) - CHECK_BO(scan2_exp(env, exp_self(decl))) + CHECK_BO(scan1_exp(env, exp_self(decl))); + CHECK_BO(scan2_exp(env, exp_self(decl))); } if(!decl->type) ERR_O(decl->td->pos, _("can't find type")); { - CHECK_BO(inferable(env, decl->type, decl->td->pos)) - CHECK_BO(ensure_check(env, decl->type)) + CHECK_BO(inferable(env, decl->type, decl->td->pos)); + CHECK_BO(ensure_check(env, decl->type)); } const m_bool global = GET_FLAG(decl->td, global); const m_uint scope = !global ? env->scope->depth : env_push_global(env); @@ -201,15 +201,15 @@ ANN static Type check_prim_array(const Env env, const Array_Sub *data) { const Exp e = array->exp; if(!e) ERR_O(prim_pos(data), _("must provide values/expressions for array [...]")) - CHECK_OO(check_exp(env, e)) + CHECK_OO(check_exp(env, e)); return array->type = prim_array_match(env, e); } ANN static m_bool check_range(const Env env, Range *range) { if(range->start) - CHECK_OB(check_exp(env, range->start)) + CHECK_OB(check_exp(env, range->start)); if(range->end) - CHECK_OB(check_exp(env, range->end)) + CHECK_OB(check_exp(env, range->end)); if(range->start && range->end) { if(isa(range->end->type, range->start->type) < 0) ERR_B(range->start->pos, _("range types do not match")) @@ -219,7 +219,7 @@ ANN static m_bool check_range(const Env env, Range *range) { ANN static Type check_prim_range(const Env env, Range **data) { Range *range = *data; - CHECK_BO(check_range(env, range)) + CHECK_BO(check_range(env, range)); const Exp e = range->start ?: range->end; const Symbol sym = insert_symbol("@range"); struct Op_Import opi = { .op=sym, .rhs=e->type, .pos=e->pos, .data=(uintptr_t)prim_exp(data) }; @@ -250,7 +250,7 @@ ANN static Value check_non_res_value(const Env env, const Symbol *data) { const Value value = get_value(env, var); if(env->class_def) { if(value && value->from->owner_class) - CHECK_BO(not_from_owner_class(env, env->class_def, value, prim_pos(data))) + CHECK_BO(not_from_owner_class(env, env->class_def, value, prim_pos(data))); const Value v = value ?: find_value(env->class_def, var); if(v) { if(env->func && GET_FLAG(env->func->def->base, static) && vflag(v, vflag_member)) @@ -351,19 +351,19 @@ ANN static Type check_prim_perform(const Env env, const Symbol *data) { } ANN static Type check_prim_interp(const Env env, const Exp* exp) { - CHECK_OO(check_exp(env, *exp)) + CHECK_OO(check_exp(env, *exp)); return env->gwion->type[et_string]; } ANN static Type check_prim_hack(const Env env, const Exp *data) { if(env->func) unset_fflag(env->func, fflag_pure); - CHECK_OO(check_prim_interp(env, data)) + CHECK_OO(check_prim_interp(env, data)); return env->gwion->type[et_gack]; } /* ANN static Type check_prim_map(const Env env, const Exp *data) { - CHECK_OO(check_exp(env, *data)) + CHECK_OO(check_exp(env, *data)); if(env->func) // really? unset_fflag(env->func, fflag_pure); bool err = false; @@ -420,14 +420,14 @@ ANN Type check_array_access(const Env env, const Array_Sub array) { } static ANN Type check_exp_array(const Env env, const Exp_Array* array) { - CHECK_OO((array->array->type = check_exp(env, array->base))) - CHECK_BO(check_subscripts(env, array->array, 0)) + CHECK_OO((array->array->type = check_exp(env, array->base))); + CHECK_BO(check_subscripts(env, array->array, 0)); return check_array_access(env, array->array); } static ANN Type check_exp_slice(const Env env, const Exp_Slice* range) { - CHECK_OO(check_exp(env, range->base)) - CHECK_BO(check_range(env, range->range)) + CHECK_OO(check_exp(env, range->base)); + CHECK_BO(check_range(env, range->range)); const Symbol sym = insert_symbol("@slice"); const Exp e = range->range->start ?: range->range->end; struct Op_Import opi = { .op=sym, .lhs=e->type, .rhs=range->base->type, @@ -476,11 +476,11 @@ ANN2(1,2) static Func find_func_match_actual(const Env env, Func func, const Exp (func->def->base->tmpl && is_fptr(env->gwion, func->value_ref->type) > 0)) { const Type owner = func->value_ref->from->owner_class; if(owner) - CHECK_BO(template_push(env, owner)) + CHECK_BO(template_push(env, owner)); e1->type = known_type(env, e1->td); if(owner) nspc_pop_type(env->gwion->mp, env->curr); - CHECK_OO(e1->type) + CHECK_OO(e1->type); } // if(!func->def->base->tmpl && func->next) // env->context->error = 1; @@ -510,7 +510,7 @@ ANN static Func call2ufcs(const Env env, Exp_Call* call, const Value v) { call->func->exp_type = ae_exp_primary; call->func->d.prim.prim_type = ae_prim_id; call->args = this; - CHECK_OO(check_exp_call(env, call)) + CHECK_OO(check_exp_call(env, call)); return call->func->type->info->func; } @@ -553,7 +553,7 @@ ANN static m_bool check_func_args(const Env env, Arg_List arg_list) { do { const Var_Decl decl = arg_list->var_decl; const Value v = decl->value; - CHECK_BB(already_defined(env, decl->xid, decl->pos)) + CHECK_BB(already_defined(env, decl->xid, decl->pos)); set_vflag(v, vflag_valid); nspc_add_value(env->curr, decl->xid, v); } while((arg_list = arg_list->next)); @@ -641,12 +641,12 @@ ANN static Type check_predefined(const Env env, Exp_Call *exp, const Value v, co if(!fdef->base->ret_type) { // template fptr struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)check_cdef, .scope=env->scope->depth, .flag=tflag_check }; - CHECK_BO(envset_push(&es, v->from->owner_class, v->from->owner)) + CHECK_BO(envset_push(&es, v->from->owner_class, v->from->owner)); func->def->base->fbflag |= fbflag_internal; const m_bool ret = check_traverse_fdef(env, func->def); if(es.run) envset_pop(&es, v->from->owner_class); - CHECK_BO(ret) + CHECK_BO(ret); } exp->func->type = func->value_ref->type; return func->def->base->ret_type; @@ -695,7 +695,7 @@ ANN static Type check_exp_call_template(const Env env, Exp_Call *exp) { ANN static Type check_lambda_call(const Env env, const Exp_Call *exp) { if(exp->args) - CHECK_OO(check_exp(env, exp->args)) + CHECK_OO(check_exp(env, exp->args)); Exp_Lambda *l = &exp->func->d.exp_lambda; Arg_List arg = l->def->base->args; Exp e = exp->args; @@ -721,14 +721,14 @@ ANN static Type check_lambda_call(const Env env, const Exp_Call *exp) { } ANN m_bool func_check(const Env env, Exp_Call *const exp) { - CHECK_OB(check_exp(env, exp->func)) + CHECK_OB(check_exp(env, exp->func)); if(exp->func->exp_type == ae_exp_decl) ERR_B(exp->func->pos, _("Can't call late function pointer at declaration site. did you meant to use `@=>`?")) const Type t = actual_type(env->gwion, exp->func->type); if(isa(t, env->gwion->type[et_function]) > 0 && exp->func->exp_type == ae_exp_dot && !t->info->value->from->owner_class) { if(exp->args) - CHECK_OB(check_exp(env, exp->args)) + CHECK_OB(check_exp(env, exp->args)); return call2ufcs(env, exp, t->info->func->value_ref) ? GW_OK: GW_ERROR; } @@ -767,10 +767,10 @@ ANN Type check_exp_call1(const Env env, Exp_Call *const exp) { if(fflag(t->info->func, fflag_ftmpl)) { const Value value = t->info->func->value_ref; if(value->from->owner_class) - CHECK_BO(ensure_traverse(env, value->from->owner_class)) + CHECK_BO(ensure_traverse(env, value->from->owner_class)); } if(exp->args) - CHECK_OO(check_exp(env, exp->args)) + CHECK_OO(check_exp(env, exp->args)); if(tflag(t, tflag_ftmpl)) return check_exp_call_template(env, (Exp_Call*)exp); // TODO: effects? const Func func = find_func_match(env, t->info->func, exp); @@ -780,8 +780,8 @@ ANN Type check_exp_call1(const Env env, Exp_Call *const exp) { // if(!fflag(func, fflag_valid)) { struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)check_cdef, .scope=env->scope->depth, .flag=tflag_check }; - CHECK_BO(envset_push(&es, func->value_ref->from->owner_class, func->value_ref->from->owner)) - CHECK_BO(check_func_def(env, func->def)) + CHECK_BO(envset_push(&es, func->value_ref->from->owner_class, func->value_ref->from->owner)); + CHECK_BO(check_func_def(env, func->def)); if(es.run) envset_pop(&es, func->value_ref->from->owner_class); } @@ -795,11 +795,11 @@ ANN Type check_exp_call1(const Env env, Exp_Call *const exp) { } ANN static Type check_exp_binary(const Env env, const Exp_Binary* bin) { - CHECK_OO(check_exp(env, bin->lhs)) + CHECK_OO(check_exp(env, bin->lhs)); const m_bool is_auto = bin->rhs->exp_type == ae_exp_decl && bin->rhs->d.exp_decl.type == env->gwion->type[et_auto]; if(is_auto) bin->rhs->d.exp_decl.type = bin->lhs->type; - CHECK_OO(check_exp(env, bin->rhs)) + CHECK_OO(check_exp(env, bin->rhs)); if(is_auto) bin->rhs->type = bin->lhs->type; struct Op_Import opi = { .op=bin->op, .lhs=bin->lhs->type, @@ -814,7 +814,7 @@ ANN static Type check_exp_binary(const Env env, const Exp_Binary* bin) { ANN static Type check_exp_cast(const Env env, const Exp_Cast* cast) { DECL_OO(const Type, t, = check_exp(env, cast->exp)) - CHECK_OO((exp_self(cast)->type = known_type(env, cast->td))) + CHECK_OO((exp_self(cast)->type = known_type(env, cast->td))); struct Op_Import opi = { .op=insert_symbol("$"), .lhs=t, .rhs=exp_self(cast)->type, .data=(uintptr_t)cast, .pos=exp_self(cast)->pos }; return op_check(env, &opi); @@ -823,7 +823,7 @@ ANN static Type check_exp_cast(const Env env, const Exp_Cast* cast) { ANN static Type check_exp_post(const Env env, const Exp_Postfix* post) { struct Op_Import opi = { .op=post->op, .lhs=check_exp(env, post->exp), .data=(uintptr_t)post, .pos=exp_self(post)->pos }; - CHECK_OO(opi.lhs) + CHECK_OO(opi.lhs); exp_setuse(post->exp, 1); const Type t = op_check(env, &opi); if(t && isa(t, env->gwion->type[et_object]) < 0) @@ -852,7 +852,7 @@ ANN static Type check_exp_call(const Env env, Exp_Call* exp) { if(isa(t, env->gwion->type[et_function]) < 0) return check_exp_call1(env, exp); if(exp->args) - CHECK_OO(check_exp(env, exp->args)) + CHECK_OO(check_exp(env, exp->args)); if(!t->info->func->def->base->tmpl) ERR_O(exp_self(exp)->pos, _("template call of non-template function.")) if(t->info->func->def->base->tmpl->call) { @@ -860,7 +860,7 @@ ANN static Type check_exp_call(const Env env, Exp_Call* exp) { exp->func->type = env->func->value_ref->type; return env->func->def->base->ret_type; } else - CHECK_BO(predefined_call(env, t, exp_self(exp)->pos)) + CHECK_BO(predefined_call(env, t, exp_self(exp)->pos)); } const Value v = type_value(env->gwion, t); DECL_OO(const Func, f, = find_template_match(env, v, exp)) @@ -873,14 +873,14 @@ ANN static Type check_exp_call(const Env env, Exp_Call* exp) { ANN static Type check_exp_unary(const Env env, const Exp_Unary* unary) { const Type rhs = unary->unary_type == unary_exp ? check_exp(env, unary->exp) : NULL; if(unary->unary_type == unary_exp) { - CHECK_OO(rhs) + CHECK_OO(rhs); exp_setuse(unary->exp, 1); } struct Op_Import opi = { .op=unary->op, .rhs=rhs, .data=(uintptr_t)unary, .pos=exp_self(unary)->pos }; DECL_OO(const Type, ret, = op_check(env, &opi)) const Type t = actual_type(env->gwion, ret); - CHECK_BO(ensure_traverse(env, t)) + CHECK_BO(ensure_traverse(env, t)); return ret; } @@ -913,7 +913,7 @@ ANN static Type check_exp_if(const Env env, const Exp_If* exp_if) { } ANN static Type check_exp_dot(const Env env, Exp_Dot* member) { - CHECK_OO(check_exp(env, member->base)) + CHECK_OO(check_exp(env, member->base)); return check_dot(env, member); } @@ -944,7 +944,7 @@ ANN m_bool check_type_def(const Env env, const Type_Def tdef) { const Stmt_List body = new_stmt_list(env->gwion->mp, stmt, NULL);//ret_list); const Stmt code = new_stmt_code(env->gwion->mp, body, when->pos); const Func_Def fdef = new_func_def(env->gwion->mp, fb, code); - CHECK_BB(traverse_func_def(env, fdef)) + CHECK_BB(traverse_func_def(env, fdef)); const Exp predicate = stmt->d.stmt_exp.val; if(isa(predicate->type, env->gwion->type[et_bool]) < 0) { char explain[strlen(predicate->type->name) + 7]; @@ -964,7 +964,7 @@ ANN m_bool check_type_def(const Env env, const Type_Def tdef) { const struct Op_Func opfunc = { .ck=opck_predicate }; const struct Op_Import opi = { .rhs=f->value_ref->type, .func=&opfunc, .data=(uintptr_t)f, .pos=tdef->pos, .op=insert_symbol("@func_check") }; - CHECK_BB(add_op(env->gwion, &opi)) + CHECK_BB(add_op(env->gwion, &opi)); */ // we handle the return after, so that we don't get *cant' use implicit casting while defining it* const Exp ret_id = new_prim_id(env->gwion->mp, insert_symbol("self"), when->pos); @@ -992,7 +992,7 @@ ANN Type check_exp(const Env env, const Exp exp) { Exp curr = exp; if(!exp->type) { do { - CHECK_OO((curr->type = check_exp_func[curr->exp_type](env, &curr->d))) + CHECK_OO((curr->type = check_exp_func[curr->exp_type](env, &curr->d))); if(env->func && isa(curr->type, env->gwion->type[et_lambda]) < 0 && isa(curr->type, env->gwion->type[et_function]) > 0 && !fflag(curr->type->info->func, fflag_pure)) unset_fflag(env->func, fflag_pure); @@ -1016,7 +1016,7 @@ ANN static m_bool check_stmt_code(const Env env, const Stmt_Code stmt) { } ANN static m_bool check_stmt_varloop(const Env env, const Stmt_VarLoop stmt) { - CHECK_OB(check_exp(env, stmt->exp)) + CHECK_OB(check_exp(env, stmt->exp)); if(isa(stmt->exp->type, env->gwion->type[et_vararg]) < 0) ERR_B(stmt->exp->pos, "varloop expression type must be '%s', not '%s'", env->gwion->type[et_vararg]->name, stmt->exp->type->name) @@ -1036,7 +1036,7 @@ ANN static m_bool check_breaks(const Env env, const Stmt a, const Stmt b) { ANN static m_bool check_conts(const Env env, const Stmt a, const Stmt b) { vector_add(&env->scope->conts, (vtype)a); - CHECK_BB(check_breaks(env, a, b)) + CHECK_BB(check_breaks(env, a, b)); vector_pop(&env->scope->conts); return GW_OK; } @@ -1062,7 +1062,7 @@ ANN static inline Type foreach_type(const Env env, const Exp exp) { ANN static m_bool do_stmt_each(const Env env, const Stmt_Each stmt) { DECL_OB(const Type, base, = foreach_type(env, stmt->exp)) - CHECK_BB(ensure_traverse(env, base)) + CHECK_BB(ensure_traverse(env, base)); const m_str basename = type2str(env->gwion, base, stmt->exp->pos); char c[15 + strlen(basename)]; sprintf(c, "Ref:[%s]", basename); @@ -1207,12 +1207,12 @@ ANN static m_bool match_case_exp(const Env env, Exp e) { e->next = NULL; const Type t = check_exp(env, e); e->next = next; - CHECK_OB(t) + CHECK_OB(t); Exp_Binary bin = { .lhs=base, .rhs=e, .op=op }; struct Exp_ ebin = { .d={.exp_binary=bin} }; struct Op_Import opi = { .op=op, .lhs=base->type, .rhs=e->type, .data=(uintptr_t)&ebin.d.exp_binary, .pos=e->pos }; - CHECK_OB(op_check(env, &opi)) + CHECK_OB(op_check(env, &opi)); } } if(e) @@ -1221,9 +1221,9 @@ ANN static m_bool match_case_exp(const Env env, Exp e) { } ANN static m_bool _check_stmt_case(const Env env, const Stmt_Match stmt) { - CHECK_BB(match_case_exp(env, stmt->cond)) + CHECK_BB(match_case_exp(env, stmt->cond)); if(stmt->when) - CHECK_OB(check_flow(env, stmt->when)) + CHECK_OB(check_flow(env, stmt->when)); return check_stmt_list(env, stmt->list); } @@ -1233,7 +1233,7 @@ ANN static m_bool check_stmt_case(const Env env, const Stmt_Match stmt) { ANN static m_bool case_loop(const Env env, const Stmt_Match stmt) { Stmt_List list = stmt->list; - do CHECK_BB(check_stmt_case(env, &list->stmt->d.stmt_match)) + do CHECK_BB(check_stmt_case(env, &list->stmt->d.stmt_match)); while((list = list->next)); return GW_OK; } @@ -1241,7 +1241,7 @@ ANN static m_bool case_loop(const Env env, const Stmt_Match stmt) { ANN static inline m_bool check_handler_list(const restrict Env env, const Handler_List handler) { if(handler->next) - CHECK_BB(check_handler_list(env, handler->next)) + CHECK_BB(check_handler_list(env, handler->next)); RET_NSPC(check_stmt(env, handler->stmt)) } @@ -1249,7 +1249,7 @@ ANN static inline m_bool check_stmt_try_start(const restrict Env env, const Stmt RET_NSPC(check_stmt(env, stmt->stmt)) } ANN static inline m_bool _check_stmt_try(const restrict Env env, const Stmt_Try stmt) { - CHECK_BB(check_handler_list(env, stmt->handler)) + CHECK_BB(check_handler_list(env, stmt->handler)); vector_add(&env->scope->effects, 0); const m_bool ret = check_stmt_try_start(env, stmt); const m_uint _v = vector_pop(&env->scope->effects); @@ -1282,7 +1282,7 @@ ANN static inline m_bool check_stmt_try(const restrict Env env, const Stmt_Try s } ANN static m_bool _check_stmt_match(const Env env, const Stmt_Match stmt) { - CHECK_OB(check_exp(env, stmt->cond)) + CHECK_OB(check_exp(env, stmt->cond)); MATCH_INI(env->scope) const m_bool ret = case_loop(env, stmt); MATCH_END(env->scope) @@ -1291,7 +1291,7 @@ ANN static m_bool _check_stmt_match(const Env env, const Stmt_Match stmt) { ANN static inline m_bool handle_where(const Env env, const Stmt_Match stmt) { if(stmt->where) - CHECK_BB(check_stmt(env, stmt->where)) + CHECK_BB(check_stmt(env, stmt->where)); RET_NSPC(_check_stmt_match(env, stmt)) } @@ -1320,7 +1320,7 @@ ANN m_bool check_stmt(const Env env, const Stmt stmt) { } ANN static m_bool check_stmt_list(const Env env, Stmt_List l) { - do CHECK_BB(check_stmt(env, l->stmt)) + do CHECK_BB(check_stmt(env, l->stmt)); while((l = l->next)); return GW_OK; } @@ -1346,7 +1346,7 @@ ANN static m_bool parent_match_actual(const Env env, const restrict Func_Def fde Func parent_func = func; do { if(parent_func->def->base && compat_func(fdef, parent_func->def) > 0) { - CHECK_BB(check_signature_match(env, fdef, parent_func)) + CHECK_BB(check_signature_match(env, fdef, parent_func)); if(!fdef->base->tmpl) { fdef->base->func->vt_index = parent_func->vt_index; vector_set(&env->curr->info->vtable, fdef->base->func->vt_index, (vtype)fdef->base->func); @@ -1422,16 +1422,16 @@ ANN static m_bool check_func_def_override(const Env env, const Func_Def fdef, Va *ov = override; } if(func->value_ref->from->offset && (!fdef->base->tmpl || !fdef->base->tmpl->base)) - CHECK_BB(check_func_overload(env, fdef)) + CHECK_BB(check_func_overload(env, fdef)); return GW_OK; } ANN m_bool check_fdef(const Env env, const Func_Def fdef) { if(fdef->base->args) - CHECK_BB(check_func_args(env, fdef->base->args)) + CHECK_BB(check_func_args(env, fdef->base->args)); if(fdef->d.code) { env->scope->depth--; - CHECK_BB(check_stmt_code(env, &fdef->d.code->d.stmt_code)) + CHECK_BB(check_stmt_code(env, &fdef->d.code->d.stmt_code)); env->scope->depth++; } if(fdef->base->ret_type && fdef->base->ret_type != env->gwion->type[et_void] && @@ -1445,11 +1445,11 @@ ANN m_bool check_func_def(const Env env, const Func_Def f) { const Func_Def fdef = func->def; assert(func == fdef->base->func); if(env->class_def) // tmpl ? - CHECK_BB(check_parent_match(env, fdef)) + CHECK_BB(check_parent_match(env, fdef)); if(tmpl_base(fdef->base->tmpl)) return GW_OK; Value override = NULL; - CHECK_BB(check_func_def_override(env, fdef, &override)) + CHECK_BB(check_func_def_override(env, fdef, &override)); DECL_BB(const m_int, scope, = GET_FLAG(fdef->base, global) ? env_push_global(env) : env->scope->depth) const Func former = env->func; env->func = func; @@ -1493,8 +1493,8 @@ ANN m_bool check_func_def(const Env env, const Func_Def f) { } ANN static m_bool check_extend_def(const Env env, const Extend_Def xdef) { - CHECK_BB(ensure_check(env, xdef->t)) - CHECK_BB(extend_push(env, xdef->t)) + CHECK_BB(ensure_check(env, xdef->t)); + CHECK_BB(extend_push(env, xdef->t)); const m_bool ret = check_ast(env, xdef->body); extend_pop(env, xdef->t); return ret; @@ -1508,8 +1508,8 @@ ANN static m_bool check_parent(const Env env, const Class_Def cdef) { const Type_Decl *td = cdef->base.ext; // if(td->array) if(td->array && td->array->exp) - CHECK_BB(check_subscripts(env, td->array, 1)) - CHECK_BB(ensure_check(env, parent)) + CHECK_BB(check_subscripts(env, td->array, 1)); + CHECK_BB(ensure_check(env, parent)); // if(tflag(parent, tflag_typedef)) { // set_tflag(cdef->base.type, tflag_typedef); // } @@ -1518,7 +1518,7 @@ ANN static m_bool check_parent(const Env env, const Class_Def cdef) { ANN static m_bool cdef_parent(const Env env, const Class_Def cdef) { if(cdef->base.tmpl && cdef->base.tmpl->list) - CHECK_BB(template_push_types(env, cdef->base.tmpl)) + CHECK_BB(template_push_types(env, cdef->base.tmpl)); const m_bool ret = check_parent(env, cdef); if(cdef->base.tmpl && cdef->base.tmpl->list) nspc_pop_type(env->gwion->mp, env->curr); @@ -1574,15 +1574,15 @@ ANN static m_bool check_body(const Env env, Section *const section) { ANN static m_bool _check_class_def(const Env env, const Class_Def cdef) { const Type t = cdef->base.type; if(cdef->base.ext) - CHECK_BB(cdef_parent(env, cdef)) + CHECK_BB(cdef_parent(env, cdef)); if(!tflag(t, tflag_struct)) inherit(t); if(cdef->body) { - CHECK_BB(env_body(env, cdef, check_body)) + CHECK_BB(env_body(env, cdef, check_body)); set_tflag(t, tflag_ctor); } if(!GET_FLAG(cdef, abstract)) - CHECK_BB(check_abstract(env, cdef)) + CHECK_BB(check_abstract(env, cdef)); return GW_OK; } @@ -1592,9 +1592,9 @@ ANN m_bool check_class_def(const Env env, const Class_Def cdef) { const Type t = cdef->base.type; struct Op_Import opi = { .op=insert_symbol("@class_check"), .lhs=t, .data=(uintptr_t)cdef, .pos=cdef->pos }; - CHECK_OB(op_check(env, &opi)) + CHECK_OB(op_check(env, &opi)); if(t->info->value->from->owner_class) - CHECK_BB(ensure_check(env, t->info->value->from->owner_class)) + CHECK_BB(ensure_check(env, t->info->value->from->owner_class)); if(tflag(t, tflag_check)) return GW_OK; set_tflag(t, tflag_check); @@ -1602,7 +1602,7 @@ ANN m_bool check_class_def(const Env env, const Class_Def cdef) { } ANN m_bool check_ast(const Env env, Ast ast) { - do CHECK_BB(check_section(env, ast->section)) + do CHECK_BB(check_section(env, ast->section)); while((ast = ast->next)); check_unhandled(env); return GW_OK; diff --git a/src/parse/func_resolve_tmpl.c b/src/parse/func_resolve_tmpl.c index f81d223e..34e976ba 100644 --- a/src/parse/func_resolve_tmpl.c +++ b/src/parse/func_resolve_tmpl.c @@ -35,7 +35,7 @@ ANN static inline bool tmpl_valid(const Env env, const Func_Def fdef/*, Exp_Call if(safe_fflag(fdef->base->func, fflag_valid)) return true; // const Tmpl tmpl = { .list=fdef->base->tmpl->list, .call=exp->tmpl->call }; -// CHECK_BO(template_push_types(env, &tmpl)); +// CHECK_BO(template_push_types(env, &tmpl));; const bool ret = check_traverse_fdef(env, fdef) > 0; // nspc_pop_type(env->gwion->mp, env->curr); return ret; @@ -50,7 +50,7 @@ ANN static Func ensure_tmpl(const Env env, const Func_Def fdef, Exp_Call *const const Func next = f->next; f->next = NULL; const Tmpl tmpl = { .list=fdef->base->tmpl->list, .call=exp->tmpl->call }; - CHECK_BO(template_push_types(env, &tmpl)); + CHECK_BO(template_push_types(env, &tmpl));; const Func func = find_func_match(env, f, exp); nspc_pop_type(env->gwion->mp, env->curr); f->next = next; @@ -62,7 +62,7 @@ ANN static Func ensure_tmpl(const Env env, const Func_Def fdef, Exp_Call *const } ANN static inline Func ensure_fptr(const Env env, struct ResolverArgs* ra, const Fptr_Def fptr) { - CHECK_BO(traverse_fptr_def(env, fptr)) + CHECK_BO(traverse_fptr_def(env, fptr)); return find_func_match(env, fptr->base->func, ra->e); } @@ -74,7 +74,7 @@ ANN static Func fptr_match(const Env env, struct ResolverArgs* ra) { return exists->info->func; const Func_Def base = v->d.func_ref ? v->d.func_ref->def : ra->e->func->type->info->func->def; const Tmpl tmpl = { .list=base->base->tmpl->list, .call=ra->types }; - CHECK_BO(template_push_types(env, &tmpl)); + CHECK_BO(template_push_types(env, &tmpl));; Func_Base *const fbase = cpy_func_base(env->gwion->mp, base->base); fbase->xid = sym; fbase->tmpl->base = 0; @@ -131,7 +131,7 @@ ANN static Func find_tmpl(const Env env, const Value v, Exp_Call *const exp, con struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)check_cdef, .scope=scope, .flag=tflag_check }; struct ResolverArgs ra = {.v = v, .e = exp, .tmpl_name = tmpl_name, .types = types}; - CHECK_BO(envset_push(&es, v->from->owner_class, v->from->owner)) + CHECK_BO(envset_push(&es, v->from->owner_class, v->from->owner)); (void)env_push(env, v->from->owner_class, v->from->owner); if(v->from->owner_class && v->from->owner_class->info->cdef->base.tmpl) (void)template_push_types(env, v->from->owner_class->info->cdef->base.tmpl); @@ -161,7 +161,7 @@ ANN static inline m_bool check_call(const Env env, const Exp_Call* exp) { } ANN Func find_template_match(const Env env, const Value value, Exp_Call *const exp) { - CHECK_BO(check_call(env, exp)) + CHECK_BO(check_call(env, exp)); const Func f = _find_template_match(env, value, exp); if(f) return f; diff --git a/src/parse/operator.c b/src/parse/operator.c index 0c145e12..05adbdd0 100644 --- a/src/parse/operator.c +++ b/src/parse/operator.c @@ -130,7 +130,7 @@ ANN m_bool add_op(const Gwion gwion, const struct Op_Import* opi) { Nspc n = gwion->env->curr; do { struct OpChecker ock = { .env=gwion->env, .map=&n->info->op_map, .opi=opi }; - CHECK_BB(op_exist(&ock, n)) + CHECK_BB(op_exist(&ock, n)); } while((n = n->parent)); if(!gwion->env->curr->info->op_map.ptr) map_init(&gwion->env->curr->info->op_map); @@ -214,7 +214,7 @@ ANN static m_bool handle_instr(const Emitter emit, const M_Operator* mo) { if(mo->func) { const Instr push = emit_add_instr(emit, mo->func->code ? RegPushImm : SetFunc); push->m_val = ((m_uint)mo->func->code ?:(m_uint)mo->func); - CHECK_BB(emit_exp_call1(emit, mo->func)) + CHECK_BB(emit_exp_call1(emit, mo->func)); if(mo->func->def->base->xid == insert_symbol(emit->gwion->st, "@conditionnal")) emit_add_instr(emit, BranchEqInt); else if(mo->func->def->base->xid == insert_symbol(emit->gwion->st, "@unconditionnal")) diff --git a/src/parse/scan0.c b/src/parse/scan0.c index b203f44e..10efab95 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -62,8 +62,8 @@ static void fptr_def(const Env env, const Fptr_Def fptr) { } ANN m_bool scan0_fptr_def(const Env env, const Fptr_Def fptr) { - CHECK_BB(env_access(env, fptr->base->flag, fptr->base->td->pos)) - CHECK_BB(scan0_defined(env, fptr->base->xid, fptr->base->td->pos)); + CHECK_BB(env_access(env, fptr->base->flag, fptr->base->td->pos)); + CHECK_BB(scan0_defined(env, fptr->base->xid, fptr->base->td->pos));; const m_str name = s_name(fptr->base->xid); const Type t = scan0_type(env, name, env->gwion->type[et_fptr]); const bool global = !env->class_def && GET_FLAG(fptr->base, global); @@ -129,7 +129,7 @@ ANN static m_bool typedef_complex(const Env env, const Type_Def tdef, const Type const ae_flag flag = base->info->cdef ? base->info->cdef->flag : 0; const Class_Def cdef = new_class_def(env->gwion->mp, flag, tdef->xid, cpy_type_decl(env->gwion->mp, tdef->ext), NULL, tdef->ext->pos); - CHECK_BB(scan0_class_def(env, cdef)) + CHECK_BB(scan0_class_def(env, cdef)); tdef->type = cdef->base.type; cdef->base.tmpl = tdef->tmpl;// check cpy mk_class(env, tdef->type, tdef->pos); @@ -148,9 +148,9 @@ ANN static void typedef_fptr(const Env env, const Type_Def tdef, const Type base } ANN m_bool scan0_type_def(const Env env, const Type_Def tdef) { - CHECK_BB(env_access(env, tdef->ext->flag, tdef->ext->pos)) + CHECK_BB(env_access(env, tdef->ext->flag, tdef->ext->pos)); DECL_OB(const Type, base, = tdef->tmpl ? find_type(env, tdef->ext) : known_type(env, tdef->ext)) - CHECK_BB(scan0_defined(env, tdef->xid, tdef->ext->pos)) + CHECK_BB(scan0_defined(env, tdef->xid, tdef->ext->pos)); const bool global = GET_FLAG(tdef->ext, global); // TODO: handle global in class if(global) { context_global(env); @@ -160,7 +160,7 @@ ANN m_bool scan0_type_def(const Env env, const Type_Def tdef) { if(!tdef->ext->types && (!tdef->ext->array || !tdef->ext->array->exp)) typedef_simple(env, tdef, base); else - CHECK_BB(typedef_complex(env, tdef, base)) + CHECK_BB(typedef_complex(env, tdef, base)); } else typedef_fptr(env, tdef, base); if(!tdef->distinct && !tdef->when) @@ -210,9 +210,9 @@ ANN static inline m_bool scan0_global(const Env env, const ae_flag flag, const l } ANN m_bool scan0_enum_def(const Env env, const Enum_Def edef) { - CHECK_BB(env_storage(env, edef->flag, edef->pos)) - CHECK_BB(scan0_defined(env, edef->xid, edef->pos)) - CHECK_BB(scan0_global(env, edef->flag, edef->pos)) + CHECK_BB(env_storage(env, edef->flag, edef->pos)); + CHECK_BB(scan0_defined(env, edef->xid, edef->pos)); + CHECK_BB(scan0_global(env, edef->flag, edef->pos)); edef->t = enum_type(env, edef); vector_init(&edef->values); if(GET_FLAG(edef, global)) @@ -247,8 +247,8 @@ ANN static void union_tmpl(const Env env, const Union_Def udef) { } ANN m_bool scan0_union_def(const Env env, const Union_Def udef) { - CHECK_BB(env_storage(env, udef->flag, udef->pos)) - CHECK_BB(scan0_global(env, udef->flag, udef->pos)) + CHECK_BB(env_storage(env, udef->flag, udef->pos)); + CHECK_BB(scan0_global(env, udef->flag, udef->pos)); const bool global = GET_FLAG(udef, global); // TODO: handle global in class if(global) { context_global(env); @@ -256,7 +256,7 @@ ANN m_bool scan0_union_def(const Env env, const Union_Def udef) { } if(GET_FLAG(udef, global)) context_global(env); - CHECK_BB(scan0_defined(env, udef->xid, udef->pos)) + CHECK_BB(scan0_defined(env, udef->xid, udef->pos)); udef->type = union_type(env, udef->xid, udef->pos); Union_List l = udef->l; do udef->type->nspc->info->offset += SZ_INT; @@ -272,9 +272,9 @@ ANN m_bool scan0_union_def(const Env env, const Union_Def udef) { } ANN static m_bool scan0_class_def_pre(const Env env, const Class_Def cdef) { - CHECK_BB(env_storage(env, cdef->flag, cdef->pos)) - CHECK_BB(isres(env, cdef->base.xid, cdef->pos)) - CHECK_BB(scan0_global(env, cdef->flag, cdef->pos)) + CHECK_BB(env_storage(env, cdef->flag, cdef->pos)); + CHECK_BB(isres(env, cdef->base.xid, cdef->pos)); + CHECK_BB(scan0_global(env, cdef->flag, cdef->pos)); return GW_OK; } @@ -319,7 +319,7 @@ ANN static Type get_parent(const Env env, const Class_Def cdef) { } ANN static Type scan0_class_def_init(const Env env, const Class_Def cdef) { - CHECK_BO(scan0_defined(env, cdef->base.xid, cdef->pos)) + CHECK_BO(scan0_defined(env, cdef->base.xid, cdef->pos)); const Type parent = get_parent(env, cdef); if(parent == (Type)GW_ERROR) return NULL; @@ -345,7 +345,7 @@ ANN static m_bool scan0_stmt_list(const Env env, Stmt_List list) { if(list->stmt->d.stmt_pp.pp_type == ae_pp_include) env->name = list->stmt->d.stmt_pp.data; else if(list->stmt->d.stmt_pp.pp_type == ae_pp_require) - CHECK_BB(plugin_ini(env->gwion, list->stmt->d.stmt_pp.data)) + CHECK_BB(plugin_ini(env->gwion, list->stmt->d.stmt_pp.data)); } while((list = list->next)); return GW_OK; } @@ -371,12 +371,12 @@ ANN static m_bool scan0_extend_def(const Env env, const Extend_Def xdef) { HANDLE_SECTION_FUNC(scan0, m_bool, Env) ANN static m_bool scan0_class_def_inner(const Env env, const Class_Def cdef) { - CHECK_OB((cdef->base.type = scan0_class_def_init(env, cdef))) + CHECK_OB((cdef->base.type = scan0_class_def_init(env, cdef))); set_tflag(cdef->base.type, tflag_scan0); (void)mk_class(env, cdef->base.type, cdef->pos); add_type(env, cdef->base.type->info->value->from->owner, cdef->base.type); if(cdef->body) - CHECK_BB(env_body(env, cdef, scan0_section)) + CHECK_BB(env_body(env, cdef, scan0_section)); return GW_OK; } @@ -401,7 +401,7 @@ ANN m_bool scan0_class_def(const Env env, const Class_Def c) { } ANN m_bool scan0_ast(const Env env, Ast ast) { - do CHECK_BB(scan0_section(env, ast->section)) + do CHECK_BB(scan0_section(env, ast->section)); while((ast = ast->next)); return GW_OK; } diff --git a/src/parse/scan1.c b/src/parse/scan1.c index a30610d6..26368fde 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -34,8 +34,8 @@ ANN static inline m_bool ensure_scan1(const Env env, const Type t) { ANN static Type scan1_type(const Env env, Type_Decl* td) { DECL_OO(const Type, t, = known_type(env, td)) if(!env->func && env->class_def && !GET_FLAG(td, late)) - CHECK_BO(type_cyclic(env, t, td)) - CHECK_BO(ensure_scan1(env, t)) + CHECK_BO(type_cyclic(env, t, td)); + CHECK_BO(ensure_scan1(env, t)); return t; } @@ -77,12 +77,12 @@ ANN static m_bool scan1_decl(const Env env, const Exp_Decl* decl) { const uint decl_ref = array_ref(decl->td->array); do { const Var_Decl var = list->self; - CHECK_BB(isres(env, var->xid, exp_self(decl)->pos)) + CHECK_BB(isres(env, var->xid, exp_self(decl)->pos)); Type t = decl->type; - CHECK_BB(scan1_defined(env, var)) + CHECK_BB(scan1_defined(env, var)); if(var->array) { if(var->array->exp) - CHECK_BB(scan1_exp(env, var->array->exp)) + CHECK_BB(scan1_exp(env, var->array->exp)); t = array_type(env, decl->type, var->array->depth); } if(GET_FLAG(array_base(t), abstract) && ((var->array && var->array->exp) @@ -127,9 +127,9 @@ ANN int is_global(const Nspc nspc, Nspc global) { } ANN m_bool scan1_exp_decl(const Env env, const Exp_Decl* decl) { - CHECK_BB(env_storage(env, decl->td->flag, exp_self(decl)->pos)) + CHECK_BB(env_storage(env, decl->td->flag, exp_self(decl)->pos)); ((Exp_Decl*)decl)->type = scan1_exp_decl_type(env, (Exp_Decl*)decl); - CHECK_OB(decl->type) + CHECK_OB(decl->type); const bool global = GET_FLAG(decl->td, global); if(global) { if(env->context) @@ -179,15 +179,15 @@ ANN static m_bool binary2call(const Env env, const Exp_Binary* bin) { ANN static inline m_bool scan1_exp_binary(const Env env, const Exp_Binary* bin) { if(opiscall(bin->op)) return binary2call(env, bin); - CHECK_BB(scan1_exp(env, bin->lhs)) + CHECK_BB(scan1_exp(env, bin->lhs)); return scan1_exp(env, bin->rhs); } ANN static m_bool scan1_range(const Env env, Range *range) { if(range->start) - CHECK_BB(scan1_exp(env, range->start)) + CHECK_BB(scan1_exp(env, range->start)); if(range->end) - CHECK_BB(scan1_exp(env, range->end)) + CHECK_BB(scan1_exp(env, range->end)); return GW_OK; } @@ -202,12 +202,12 @@ ANN static inline m_bool scan1_prim(const Env env, const Exp_Primary* prim) { } ANN static inline m_bool scan1_exp_array(const Env env, const Exp_Array* array) { - CHECK_BB(scan1_exp(env, array->base)) + CHECK_BB(scan1_exp(env, array->base)); return scan1_exp(env, array->array->exp); } ANN static inline m_bool scan1_exp_slice(const Env env, const Exp_Slice* range) { - CHECK_BB(scan1_exp(env, range->base)) + CHECK_BB(scan1_exp(env, range->base)); return scan1_range(env, range->range); } @@ -219,7 +219,7 @@ ANN static m_bool scan1_exp_post(const Env env, const Exp_Postfix* post) { if(opiscall(post->op)) { return exp2call(env, exp_self(post), post->op, post->exp); } - CHECK_BB(scan1_exp(env, post->exp)) + CHECK_BB(scan1_exp(env, post->exp)); const m_str access = exp_access(post->exp); if(!access) return GW_OK; @@ -230,7 +230,7 @@ ANN static m_bool scan1_exp_post(const Env env, const Exp_Postfix* post) { ANN static m_bool scan1_exp_call(const Env env, const Exp_Call* exp_call) { if(exp_call->tmpl) return GW_OK; - CHECK_BB(scan1_exp(env, exp_call->func)) + CHECK_BB(scan1_exp(env, exp_call->func)); const Exp args = exp_call->args; return args ? scan1_exp(env, args) : GW_OK; } @@ -240,8 +240,8 @@ ANN static inline m_bool scan1_exp_dot(const Env env, const Exp_Dot* member) { } ANN static m_bool scan1_exp_if(const Env env, const Exp_If* exp_if) { - CHECK_BB(scan1_exp(env, exp_if->cond)) - CHECK_BB(scan1_exp(env, exp_if->if_exp ?: exp_if->cond)) + CHECK_BB(scan1_exp(env, exp_if->cond)); + CHECK_BB(scan1_exp(env, exp_if->if_exp ?: exp_if->cond)); return scan1_exp(env, exp_if->else_exp); } @@ -259,9 +259,9 @@ ANN static inline m_bool scan1_exp_unary(const restrict Env env, const Exp_Unary HANDLE_EXP_FUNC(scan1, m_bool, Env) ANN static inline m_bool _scan1_stmt_match_case(const restrict Env env, const Stmt_Match stmt) { - CHECK_BB(scan1_exp(env, stmt->cond)) + CHECK_BB(scan1_exp(env, stmt->cond)); if(stmt->when) - CHECK_BB(scan1_exp(env, stmt->when)) + CHECK_BB(scan1_exp(env, stmt->when)); return scan1_stmt_list(env, stmt->list); } @@ -271,27 +271,27 @@ ANN static inline m_bool scan1_stmt_match_case(const restrict Env env, const Stm ANN static inline m_bool _scan1_stmt_match(const restrict Env env, const Stmt_Match stmt) { if(stmt->where) - CHECK_BB(scan1_stmt(env, stmt->where)) + CHECK_BB(scan1_stmt(env, stmt->where)); Stmt_List list = stmt->list; - do CHECK_BB(scan1_stmt_match_case(env, &list->stmt->d.stmt_match)) + do CHECK_BB(scan1_stmt_match_case(env, &list->stmt->d.stmt_match)); while((list = list->next)); return GW_OK; } ANN static inline m_bool scan1_stmt_match(const restrict Env env, const Stmt_Match stmt) { - CHECK_BB(scan1_exp(env, stmt->cond)) + CHECK_BB(scan1_exp(env, stmt->cond)); RET_NSPC(_scan1_stmt_match(env, stmt)) } ANN static inline m_bool scan1_handler_list(const restrict Env env, const Handler_List handler) { if(handler->next) - CHECK_BB(scan1_handler_list(env, handler->next)) + CHECK_BB(scan1_handler_list(env, handler->next)); RET_NSPC(scan1_stmt(env, handler->stmt)) } ANN static inline m_bool scan1_stmt_try(const restrict Env env, const Stmt_Try stmt) { - CHECK_BB(scan1_handler_list(env, stmt->handler)) + CHECK_BB(scan1_handler_list(env, stmt->handler)); RET_NSPC(scan1_stmt(env, stmt->stmt)) } @@ -333,7 +333,7 @@ ANN static inline m_bool scan1_stmt_exp(const Env env, const Stmt_Exp stmt) { ANN m_bool scan1_enum_def(const Env env, const Enum_Def edef) { ID_List list = edef->list; do { - CHECK_BB(already_defined(env, list->xid, edef->pos)) + CHECK_BB(already_defined(env, list->xid, edef->pos)); const Value v = new_value(env->gwion->mp, edef->t, s_name(list->xid)); valuefrom(env, v->from, edef->pos); if(env->class_def) { @@ -366,10 +366,10 @@ ANN static m_bool scan1_args(const Env env, Arg_List list) { do { const Var_Decl var = list->var_decl; if(var->xid) - CHECK_BB(isres(env, var->xid, var->pos)) + CHECK_BB(isres(env, var->xid, var->pos)); if(list->td) { SET_FLAG(list->td, late); - CHECK_OB((list->type = void_type(env, list->td))) + CHECK_OB((list->type = void_type(env, list->td))); UNSET_FLAG(list->td, late); } var->value = arg_value(env, list); @@ -382,10 +382,10 @@ ANN static m_bool _scan1_fdef_base_tmpl(const Env env, Func_Base *base) { ID_List id = base->tmpl->list; do nspc_add_type(env->curr, id->xid, env->gwion->type[et_auto]); while((id = id->next)); - CHECK_OB((base->ret_type = known_type(env, base->td))) + CHECK_OB((base->ret_type = known_type(env, base->td))); if(base->args) { Arg_List arg = base->args; - do CHECK_OB(known_type(env, arg->td)) + do CHECK_OB(known_type(env, arg->td)); while((arg = arg->next)); } return GW_OK; @@ -406,7 +406,7 @@ ANN m_bool scan1_fptr_def(const Env env, const Fptr_Def fptr) { fptr->type = nspc_lookup_type0(env->curr, fptr->base->xid); } const Func_Def fdef = fptr->base->func->def; - CHECK_OB((fdef->base->ret_type = scan1_type(env, fdef->base->td))) + CHECK_OB((fdef->base->ret_type = scan1_type(env, fdef->base->td))); if(!fdef->base->args) return GW_OK; RET_NSPC(scan1_args(env, fdef->base->args)) @@ -416,7 +416,7 @@ ANN m_bool scan1_type_def(const Env env, const Type_Def tdef) { if(!tdef->type) tdef->type = nspc_lookup_type0(env->curr, tdef->xid); if(tdef->when) - CHECK_BB(scan1_exp(env, tdef->when)) + CHECK_BB(scan1_exp(env, tdef->when)); return (!is_fptr(env->gwion, tdef->type) && tdef->type->info->cdef) ? scan1_cdef(env, tdef->type) : GW_OK; } @@ -447,7 +447,7 @@ ANN static inline m_bool scan1_union_def_inner_loop(const Env env, Union_Def ude ANN static m_bool scan1_union_def_inner(const Env env, const Union_Def udef) { if(udef->tmpl && udef->tmpl->call) - CHECK_BB(template_push_types(env, udef->tmpl)) + CHECK_BB(template_push_types(env, udef->tmpl)); const m_bool ret = scan1_union_def_inner_loop(env, udef); if(udef->tmpl && udef->tmpl->call) nspc_pop_type(env->gwion->mp, env->curr); @@ -489,7 +489,7 @@ ANN static inline m_bool scan1_stmt(const Env env, const Stmt stmt) { ANN static m_bool scan1_stmt_list(const Env env, Stmt_List l) { do { - CHECK_BB(scan1_stmt(env, l->stmt)) + CHECK_BB(scan1_stmt(env, l->stmt)); if(l->next) { if(l->stmt->stmt_type != ae_stmt_return) { if(l->next->stmt->stmt_type == ae_stmt_exp && @@ -526,7 +526,7 @@ ANN static inline m_bool scan_internal_arg(const Env env, const Func_Base *base) } ANN static inline m_bool scan_internal_int(const Env env, const Func_Base *base) { - CHECK_BB(scan_internal_arg(env, base)) + CHECK_BB(scan_internal_arg(env, base)); if(isa(base->ret_type, env->gwion->type[et_int]) > 0) return GW_OK; ERR_B(base->td->pos, _("'%s' must return 'int'"), s_name(base->xid)) @@ -557,19 +557,19 @@ ANN static m_bool scan1_fdef_args(const Env env, Arg_List list) { ANN m_bool scan1_fbody(const Env env, const Func_Def fdef) { if(fdef->base->args) { - CHECK_BB(scan1_fdef_args(env, fdef->base->args)) - CHECK_BB(scan1_args(env, fdef->base->args)) + CHECK_BB(scan1_fdef_args(env, fdef->base->args)); + CHECK_BB(scan1_args(env, fdef->base->args)); } if(fdef->d.code && fdef->d.code->d.stmt_code.stmt_list) - CHECK_BB(scan1_stmt_list(env, fdef->d.code->d.stmt_code.stmt_list)) + CHECK_BB(scan1_stmt_list(env, fdef->d.code->d.stmt_code.stmt_list)); return GW_OK; } ANN m_bool scan1_fdef(const Env env, const Func_Def fdef) { if(fdef->base->td) - CHECK_OB((fdef->base->ret_type = known_type(env, fdef->base->td))) + CHECK_OB((fdef->base->ret_type = known_type(env, fdef->base->td))); if(fbflag(fdef->base, fbflag_internal)) - CHECK_BB(scan_internal(env, fdef->base)) + CHECK_BB(scan_internal(env, fdef->base)); else if(fbflag(fdef->base, fbflag_op) && env->class_def) SET_FLAG(fdef->base, static); RET_NSPC(scan1_fbody(env, fdef)) @@ -592,8 +592,8 @@ ANN m_bool scan1_func_def(const Env env, const Func_Def fdef) { const bool global = GET_FLAG(fdef->base, global); const m_uint scope = !global ? env->scope->depth : env_push_global(env); if(fdef->base->td) - CHECK_BB(env_storage(env, fdef->base->flag, fdef->base->td->pos)) - CHECK_BB(scan1_fdef_defined(env, fdef)) + CHECK_BB(env_storage(env, fdef->base->flag, fdef->base->td->pos)); + CHECK_BB(scan1_fdef_defined(env, fdef)); if(tmpl_base(fdef->base->tmpl)) return scan1_fdef_base_tmpl(env, fdef->base); struct Func_ fake = { .name=s_name(fdef->base->xid) }, *const former = env->func; @@ -608,8 +608,8 @@ ANN m_bool scan1_func_def(const Env env, const Func_Def fdef) { } ANN static m_bool scan1_extend_def(const Env env, const Extend_Def xdef) { - CHECK_BB(ensure_scan1(env, xdef->t)) - CHECK_BB(extend_push(env, xdef->t)) + CHECK_BB(ensure_scan1(env, xdef->t)); + CHECK_BB(extend_push(env, xdef->t)); const m_bool ret = scan1_ast(env, xdef->body); extend_pop(env, xdef->t); return ret; @@ -619,7 +619,7 @@ HANDLE_SECTION_FUNC(scan1, m_bool, Env) ANN static Type scan1_get_parent(const Env env, const Type_Def tdef) { const Type parent = known_type(env, tdef->ext); - CHECK_OO((tdef->type->info->parent = parent)); + CHECK_OO((tdef->type->info->parent = parent));; Type t = parent; do if(tdef->type == t) ERR_O(tdef->ext->pos, _("recursive (%s <= %s) class declaration."), tdef->type->name, t->name) @@ -630,11 +630,11 @@ ANN static Type scan1_get_parent(const Env env, const Type_Def tdef) { ANN static m_bool scan1_parent(const Env env, const Class_Def cdef) { const loc_t pos = cdef->base.ext->pos; if(cdef->base.ext->array && cdef->base.ext->array->exp) - CHECK_BB(scan1_exp(env, cdef->base.ext->array->exp)) + CHECK_BB(scan1_exp(env, cdef->base.ext->array->exp)); DECL_OB(const Type , parent, = scan1_get_parent(env, &cdef->base)) if(isa(parent, env->gwion->type[et_object]) < 0) ERR_B(pos, _("cannot extend primitive type '%s'"), parent->name) - CHECK_BB(ensure_scan1(env, parent)) + CHECK_BB(ensure_scan1(env, parent)); if(type_ref(parent)) ERR_B(pos, _("can't use ref type in class extend")) return GW_OK; @@ -642,7 +642,7 @@ ANN static m_bool scan1_parent(const Env env, const Class_Def cdef) { ANN static m_bool cdef_parent(const Env env, const Class_Def cdef) { if(cdef->base.tmpl && cdef->base.tmpl->list) - CHECK_BB(template_push_types(env, cdef->base.tmpl)) + CHECK_BB(template_push_types(env, cdef->base.tmpl)); const m_bool ret = scan1_parent(env, cdef); if(cdef->base.tmpl && cdef->base.tmpl->list) nspc_pop_type(env->gwion->mp, env->curr); @@ -657,16 +657,16 @@ ANN m_bool scan1_class_def(const Env env, const Class_Def cdef) { return GW_OK; set_tflag(t, tflag_scan1); if(t->info->value->from->owner_class) - CHECK_BB(ensure_scan1(env, t->info->value->from->owner_class)) + CHECK_BB(ensure_scan1(env, t->info->value->from->owner_class)); if(cdef->base.ext) - CHECK_BB(cdef_parent(env, cdef)) + CHECK_BB(cdef_parent(env, cdef)); if(cdef->body) - CHECK_BB(env_body(env, cdef, scan1_section)) + CHECK_BB(env_body(env, cdef, scan1_section)); return GW_OK; } ANN m_bool scan1_ast(const Env env, Ast ast) { - do CHECK_BB(scan1_section(env, ast->section)) + do CHECK_BB(scan1_section(env, ast->section)); while((ast = ast->next)); return GW_OK; } diff --git a/src/parse/scan2.c b/src/parse/scan2.c index f7b9b400..a123bb1b 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -24,13 +24,13 @@ ANN static inline m_bool ensure_scan2(const Env env, const Type t) { ANN static m_bool scan2_decl(const Env env, const Exp_Decl* decl) { const Type t = decl->type; - CHECK_BB(ensure_scan2(env, t)) + CHECK_BB(ensure_scan2(env, t)); Var_Decl_List list = decl->list; do { const Var_Decl var = list->self; const Exp array = var->array ? var->array->exp : NULL; if(array) - CHECK_BB(scan2_exp(env, array)) + CHECK_BB(scan2_exp(env, array)); nspc_add_value(env->curr, var->xid, var->value); } while((list = list->next)); return GW_OK; @@ -92,7 +92,7 @@ ANN m_bool scan2_fptr_def(const Env env NUSED, const Fptr_Def fptr) { ANN static m_bool scan2_func_def_op(const Env env, const Func_Def f); ANN m_bool scan2_type_def(const Env env, const Type_Def tdef) { if(tdef->when) - CHECK_BB(scan2_exp(env, tdef->when)) + CHECK_BB(scan2_exp(env, tdef->when)); if(!tdef->type->info->cdef) return GW_OK; return (!is_fptr(env->gwion, tdef->type) && tdef->type->info->cdef) ? @@ -101,15 +101,15 @@ ANN m_bool scan2_type_def(const Env env, const Type_Def tdef) { ANN static m_bool scan2_range(const Env env, Range *range) { if(range->start) - CHECK_BB(scan2_exp(env, range->start)) + CHECK_BB(scan2_exp(env, range->start)); if(range->end) - CHECK_BB(scan2_exp(env, range->end)) + CHECK_BB(scan2_exp(env, range->end)); return GW_OK; } ANN static inline m_bool scan2_prim(const Env env, const Exp_Primary* prim) { if(prim->prim_type == ae_prim_hack || prim->prim_type == ae_prim_interp) - CHECK_BB(scan2_exp(env, prim->d.exp)) + CHECK_BB(scan2_exp(env, prim->d.exp)); /* else if(prim->prim_type == ae_prim_id) { const Value v = prim_value(env, prim->d.var); if(v) @@ -122,12 +122,12 @@ ANN static inline m_bool scan2_prim(const Env env, const Exp_Primary* prim) { } ANN static inline m_bool scan2_exp_array(const Env env, const Exp_Array* array) { - CHECK_BB(scan2_exp(env, array->base)) + CHECK_BB(scan2_exp(env, array->base)); return scan2_exp(env, array->array->exp); } ANN static inline m_bool scan2_exp_slice(const Env env, const Exp_Slice* exp) { - CHECK_BB(scan2_exp(env, exp->base)) + CHECK_BB(scan2_exp(env, exp->base)); return scan2_range(env, exp->range); } @@ -141,9 +141,9 @@ ANN static m_bool multi_decl(const Env env, const Exp e, const Symbol op) { } ANN static inline m_bool scan2_exp_binary(const Env env, const Exp_Binary* bin) { - CHECK_BB(scan2_exp(env, bin->lhs)) - CHECK_BB(scan2_exp(env, bin->rhs)) - CHECK_BB(multi_decl(env, bin->lhs, bin->op)) + CHECK_BB(scan2_exp(env, bin->lhs)); + CHECK_BB(scan2_exp(env, bin->rhs)); + CHECK_BB(multi_decl(env, bin->lhs, bin->op)); return multi_decl(env, bin->rhs, bin->op); } @@ -158,7 +158,7 @@ ANN static inline m_bool scan2_exp_post(const Env env, const Exp_Postfix* post) ANN static inline m_bool scan2_exp_call(const Env env, const Exp_Call* exp_call) { if(exp_call->tmpl) return GW_OK; - CHECK_BB(scan2_exp(env, exp_call->func)) + CHECK_BB(scan2_exp(env, exp_call->func)); const Exp args = exp_call->args; return args ? scan2_exp(env, args) : GW_OK; } @@ -168,8 +168,8 @@ ANN static inline m_bool scan2_exp_dot(const Env env, const Exp_Dot* member) { } ANN static inline m_bool scan2_exp_if(const Env env, const Exp_If* exp_if) { - CHECK_BB(scan2_exp(env, exp_if->cond)) - CHECK_BB(scan2_exp(env, exp_if->if_exp ?: exp_if->cond)) + CHECK_BB(scan2_exp(env, exp_if->cond)); + CHECK_BB(scan2_exp(env, exp_if->if_exp ?: exp_if->cond)); return scan2_exp(env, exp_if->else_exp); } @@ -182,9 +182,9 @@ ANN static m_bool scan2_exp_unary(const Env env, const Exp_Unary * unary) { } ANN static inline m_bool _scan2_stmt_match_case(const restrict Env env, const Stmt_Match stmt) { - CHECK_BB(scan2_exp(env, stmt->cond)) + CHECK_BB(scan2_exp(env, stmt->cond)); if(stmt->when) - CHECK_BB(scan2_exp(env, stmt->when)) + CHECK_BB(scan2_exp(env, stmt->when)); return scan2_stmt_list(env, stmt->list); } @@ -194,26 +194,26 @@ ANN static inline m_bool scan2_stmt_match_case(const restrict Env env, const Stm ANN static inline m_bool _scan2_stmt_match(const restrict Env env, const Stmt_Match stmt) { if(stmt->where) - CHECK_BB(scan2_stmt(env, stmt->where)) + CHECK_BB(scan2_stmt(env, stmt->where)); Stmt_List list = stmt->list; - do CHECK_BB(scan2_stmt_match_case(env, &list->stmt->d.stmt_match)) + do CHECK_BB(scan2_stmt_match_case(env, &list->stmt->d.stmt_match)); while((list = list->next)); return GW_OK; } ANN static inline m_bool scan2_handler_list(const restrict Env env, const Handler_List handler) { if(handler->next) - CHECK_BB(scan2_handler_list(env, handler->next)) + CHECK_BB(scan2_handler_list(env, handler->next)); RET_NSPC(scan2_stmt(env, handler->stmt)) } ANN static inline m_bool scan2_stmt_try(const restrict Env env, const Stmt_Try stmt) { - CHECK_BB(scan2_handler_list(env, stmt->handler)) + CHECK_BB(scan2_handler_list(env, stmt->handler)); RET_NSPC(scan2_stmt(env, stmt->stmt)) } ANN static inline m_bool scan2_stmt_match(const restrict Env env, const Stmt_Match stmt) { - CHECK_BB(scan2_exp(env, stmt->cond)) + CHECK_BB(scan2_exp(env, stmt->cond)); RET_NSPC(_scan2_stmt_match(env, stmt)) } @@ -280,7 +280,7 @@ ANN static m_bool scan2_stmt(const Env env, const Stmt stmt) { } ANN static m_bool scan2_stmt_list(const Env env, Stmt_List list) { - do CHECK_BB(scan2_stmt(env, list->stmt)) + do CHECK_BB(scan2_stmt(env, list->stmt)); while((list = list->next)); return GW_OK; } @@ -324,7 +324,7 @@ ANN2(1,2) static Value func_value(const Env env, const Func f, const Type t = func_type(env, f); const Value v = t->info->value = new_value(env->gwion->mp, t, t->name); valuefrom(env, v->from, f->def->base->pos); - CHECK_OO(scan2_func_assign(env, f->def, f, v)) + CHECK_OO(scan2_func_assign(env, f->def, f, v)); if(!overload) { value_addref(v); nspc_add_value_front(env->curr, f->def->base->xid, v); @@ -393,7 +393,7 @@ ANN static m_bool scan2_func_def_op(const Env env, const Func_Def f) { struct Op_Import opi = { .ret=f->base->ret_type, .pos=f->base->pos, .data=(uintptr_t)f->base->func, .func=&opfunc }; func_operator(f, &opi); - CHECK_BB(add_op(env->gwion, &opi)) + CHECK_BB(add_op(env->gwion, &opi)); operator_set_func(&opi); return GW_OK; } @@ -401,7 +401,7 @@ ANN static m_bool scan2_func_def_op(const Env env, const Func_Def f) { ANN static m_bool scan2_func_def_code(const Env env, const Func_Def f) { const Func former = env->func; env->func = f->base->func; - CHECK_BB(scan2_stmt_code(env, &f->d.code->d.stmt_code)) + CHECK_BB(scan2_stmt_code(env, &f->d.code->d.stmt_code)); env->func = former; return GW_OK; } @@ -464,16 +464,16 @@ ANN2(1,2) m_bool scan2_fdef_std(const Env env, const Func_Def f, const Value ove if(!name)return GW_ERROR; const Func base = f->base->func; if(!base) - CHECK_OB(func_create(env, f, overload, name)) + CHECK_OB(func_create(env, f, overload, name)); else f->base->func = base; if(f->base->args) - CHECK_BB(scan2_args(f)) + CHECK_BB(scan2_args(f)); if(f->d.code) - CHECK_BB(scan2_func_def_code(env, f)) + CHECK_BB(scan2_func_def_code(env, f)); if(!base) { if(fbflag(f->base, fbflag_op)) - CHECK_BB(scan2_func_def_op(env, f)) + CHECK_BB(scan2_func_def_op(env, f)); set_vflag(f->base->func->value_ref, vflag_valid); } return GW_OK; @@ -493,8 +493,8 @@ ANN static void upfunction(const Env env, const Func_Base *fb) { ANN m_bool scan2_fdef(const Env env, const Func_Def fdef) { const Value overload = nspc_lookup_value2(env->curr, fdef->base->xid); if(overload) - CHECK_BB(scan2_func_def_overload(env, fdef, overload)) - CHECK_BB((!tmpl_base(fdef->base->tmpl) ? scan2_fdef_std : scan2_fdef_tmpl)(env, fdef, overload)) + CHECK_BB(scan2_func_def_overload(env, fdef, overload)); + CHECK_BB((!tmpl_base(fdef->base->tmpl) ? scan2_fdef_std : scan2_fdef_tmpl)(env, fdef, overload)); if(env->class_def) upfunction(env, fdef->base); return GW_OK; @@ -532,15 +532,15 @@ ANN m_bool scan2_func_def(const Env env, const Func_Def fdef) { const m_bool ret = scanx_fdef(env, env, f, (_exp_func)scan2_fdef); if(GET_FLAG(f->base, global)) env_pop(env, scope); - CHECK_BB(ret) + CHECK_BB(ret); fdef->base->func = f->base->func; // only needed if 'is_cpy()' return GW_OK; } ANN static m_bool scan2_extend_def(const Env env, const Extend_Def xdef) { - CHECK_BB(ensure_scan2(env, xdef->t)) - CHECK_BB(extend_push(env, xdef->t)) + CHECK_BB(ensure_scan2(env, xdef->t)); + CHECK_BB(extend_push(env, xdef->t)); const m_bool ret = scan2_ast(env, xdef->body); extend_pop(env, xdef->t); return ret; @@ -551,15 +551,15 @@ HANDLE_SECTION_FUNC(scan2, m_bool, Env) ANN static m_bool scan2_parent(const Env env, const Class_Def cdef) { const Type parent = cdef->base.type->info->parent; - CHECK_BB(ensure_scan2(env, parent)) + CHECK_BB(ensure_scan2(env, parent)); if(cdef->base.ext->array && cdef->base.ext->array->exp) - CHECK_BB(scan2_exp(env, cdef->base.ext->array->exp)) + CHECK_BB(scan2_exp(env, cdef->base.ext->array->exp)); return GW_OK; } ANN static m_bool cdef_parent(const Env env, const Class_Def cdef) { if(cdef->base.tmpl && cdef->base.tmpl->list) - CHECK_BB(template_push_types(env, cdef->base.tmpl)) + CHECK_BB(template_push_types(env, cdef->base.tmpl)); const m_bool ret = scan2_parent(env, cdef); if(cdef->base.tmpl && cdef->base.tmpl->list) nspc_pop_type(env->gwion->mp, env->curr); @@ -573,17 +573,17 @@ ANN m_bool scan2_class_def(const Env env, const Class_Def cdef) { if(tflag(t, tflag_scan2)) return GW_OK; if(t->info->value->from->owner_class) - CHECK_BB(ensure_scan2(env, t->info->value->from->owner_class)) + CHECK_BB(ensure_scan2(env, t->info->value->from->owner_class)); set_tflag(t, tflag_scan2); if(cdef->base.ext) - CHECK_BB(cdef_parent(env, cdef)) + CHECK_BB(cdef_parent(env, cdef)); if(cdef->body) - CHECK_BB(env_body(env, cdef, scan2_section)) + CHECK_BB(env_body(env, cdef, scan2_section)); return GW_OK; } ANN m_bool scan2_ast(const Env env, Ast ast) { - do CHECK_BB(scan2_section(env, ast->section)) + do CHECK_BB(scan2_section(env, ast->section)); while((ast = ast->next)); return GW_OK; } diff --git a/src/parse/scanx.c b/src/parse/scanx.c index 827b8715..0264ed1e 100644 --- a/src/parse/scanx.c +++ b/src/parse/scanx.c @@ -7,7 +7,7 @@ #include "parse.h" ANN static inline m_bool _body(const Env e, Ast b, const _exp_func f) { - do CHECK_BB(f(e, b->section)) + do CHECK_BB(f(e, b->section)); while((b = b->next)); return GW_OK; } @@ -60,7 +60,7 @@ ANN m_bool scanx_cdef(const Env env, void* opt, const Type t, ANN m_bool scanx_fdef(const Env env, void *data, const Func_Def fdef, const _exp_func func) { if(fdef->base->tmpl) - CHECK_BB(template_push_types(env, fdef->base->tmpl)) + CHECK_BB(template_push_types(env, fdef->base->tmpl)); const bool in_try = env->scope->in_try; const m_bool ret = func(data, fdef); if(fdef->base->tmpl) diff --git a/src/parse/template.c b/src/parse/template.c index 6d5610b4..c0830c18 100644 --- a/src/parse/template.c +++ b/src/parse/template.c @@ -29,7 +29,7 @@ ANN static m_bool push_types(const Env env, const Tmpl *tmpl) { ANN static m_bool _template_push(const Env env, const Type t) { if(t->info->value->from->owner_class) - CHECK_BB(template_push(env, t->info->value->from->owner_class)) + CHECK_BB(template_push(env, t->info->value->from->owner_class)); if(tflag(t, tflag_tmpl)) return push_types(env, t->info->cdef->base.tmpl); // incorrect return GW_OK; @@ -115,7 +115,7 @@ ANN Type scan_type(const Env env, const Type t, Type_Decl* td) { const Type maybe_array = known_type(env, td); const Type owner = array_base(maybe_array); td->next = next; - CHECK_OO(owner) + CHECK_OO(owner); if(!owner->nspc) ERR_O(td->pos, "type '%s' has no namespace", owner->name) struct EnvSet es = { .env=env, .data=env, diff --git a/src/parse/traverse.c b/src/parse/traverse.c index 802a14c2..0a5c5b5c 100644 --- a/src/parse/traverse.c +++ b/src/parse/traverse.c @@ -4,21 +4,21 @@ #include "traverse.h" ANN m_bool traverse_ast(const Env env, const Ast ast) { - CHECK_BB(scan0_ast(env, ast)) - CHECK_BB(scan1_ast(env, ast)) - CHECK_BB(scan2_ast(env, ast)) + CHECK_BB(scan0_ast(env, ast)); + CHECK_BB(scan1_ast(env, ast)); + CHECK_BB(scan2_ast(env, ast)); return check_ast(env, ast); } ANN m_bool traverse_exp(const Env env, const Exp exp) { - CHECK_BB(scan1_exp(env, exp)) - CHECK_BB(scan2_exp(env, exp)) + CHECK_BB(scan1_exp(env, exp)); + CHECK_BB(scan2_exp(env, exp)); return check_exp(env, exp) ? 1 : -1; } ANN static m_bool _traverse_func_def(const Env env, const Func_Def fdef) { - CHECK_BB(scan1_func_def(env, fdef)) - CHECK_BB(scan2_func_def(env, fdef)) + CHECK_BB(scan1_func_def(env, fdef)); + CHECK_BB(scan2_func_def(env, fdef)); return check_func_def(env, fdef); } @@ -31,41 +31,41 @@ ANN m_bool traverse_func_def(const Env env, const Func_Def fdef) { ANN m_bool traverse_union_def(const Env env, const Union_Def def) { // if(!GET_FLAG(def, scan1)) - CHECK_BB(scan1_union_def(env, def)) + CHECK_BB(scan1_union_def(env, def)); // if(!GET_FLAG(def, scan2)) - CHECK_BB(scan2_union_def(env, def)) + CHECK_BB(scan2_union_def(env, def)); // if(!GET_FLAG(def, check)) - CHECK_BB(check_union_def(env, def)) + CHECK_BB(check_union_def(env, def)); return check_union_def(env, def); } ANN m_bool traverse_enum_def(const Env env, const Enum_Def def) { - CHECK_BB(scan0_enum_def(env, def)) - CHECK_BB(scan1_enum_def(env, def)) -// CHECK_BB(scan2_enum_def(env, def)) + CHECK_BB(scan0_enum_def(env, def)); + CHECK_BB(scan1_enum_def(env, def)); +// CHECK_BB(scan2_enum_def(env, def)); return check_enum_def(env, def); } ANN m_bool traverse_fptr_def(const Env env, const Fptr_Def def) { - CHECK_BB(scan0_fptr_def(env, def)) - CHECK_BB(scan1_fptr_def(env, def)) + CHECK_BB(scan0_fptr_def(env, def)); + CHECK_BB(scan1_fptr_def(env, def)); return scan2_fptr_def(env, def); -// CHECK_BB(check_fptr_def(env, def)) +// CHECK_BB(check_fptr_def(env, def)); } ANN m_bool traverse_type_def(const Env env, const Type_Def def) { - CHECK_BB(scan0_type_def(env, def)) - CHECK_BB(scan1_type_def(env, def)) - CHECK_BB(scan2_type_def(env, def)) + CHECK_BB(scan0_type_def(env, def)); + CHECK_BB(scan1_type_def(env, def)); + CHECK_BB(scan2_type_def(env, def)); return check_type_def(env, def); } ANN m_bool traverse_class_def(const Env env, const Class_Def def) { const Type t = def->base.type; if(!tflag(t, tflag_scan1)) - CHECK_BB(scan1_class_def(env, def)) + CHECK_BB(scan1_class_def(env, def)); if(!tflag(t, tflag_scan2)) - CHECK_BB(scan2_class_def(env, def)) + CHECK_BB(scan2_class_def(env, def)); if(!tflag(t, tflag_check)) return check_class_def(env, def); return GW_OK; diff --git a/src/plug.c b/src/plug.c index 5ed27f5e..13514830 100644 --- a/src/plug.c +++ b/src/plug.c @@ -144,7 +144,7 @@ ANN static m_bool dependencies(struct Gwion_ *gwion, const Plug plug) { m_str *const base = dep(); m_str *deps = base; while(*deps) { - CHECK_BB(plugin_ini(gwion, *deps)) + CHECK_BB(plugin_ini(gwion, *deps)); ++deps; } } @@ -170,7 +170,7 @@ ANN static m_bool _plugin_ini(struct Gwion_ *gwion, const m_str iname) { if(!imp) break; plug->imp = 1; - CHECK_BB(dependencies(gwion, plug)) + CHECK_BB(dependencies(gwion, plug)); const m_uint scope = env_push_global(gwion->env); const m_bool ret = gwi_run(gwion, imp); env_pop(gwion->env, scope); -- 2.43.0