};
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
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);
}
#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
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);
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);
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;
}
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)
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;
}
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;
}
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;
}
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;
}
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;
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;
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;
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;
}
}
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,
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);
}
}
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 {
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;
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);
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;
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);
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);
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);
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);
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);
}
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)) {
}
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) {
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);
// 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;
}
// 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);
}
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)
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)
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;
(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;
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);
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;
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);
.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;
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);
}
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)
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);
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;
}
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);
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;
}
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);
}
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);
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)) {
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;
}
}
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;
}
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) {
}
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) {
(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)) {
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);
}
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);
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);
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;
}
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);
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]);
.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;
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;
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;
}
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;
(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;
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;
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)
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;
}
}
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);
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;
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;
}
}
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);
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);
}
}
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;
}
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);
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;
}
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);
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;
}
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;
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);
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);
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;
}
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
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;
}
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;
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);
}
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;
}
}
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);
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)
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))
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;
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)
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);
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)
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;
}
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;
}
if(*ac->str != '[')
break;
++ac->str;
- CHECK_BB(_ac_run(gwion, ac))
+ CHECK_BB(_ac_run(gwion, ac));
++ac->depth;
}
return GW_OK;
//! \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;
}
//! \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);
//! \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;
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;
}
}
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);
}
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, "...")) {
}
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*/) {
#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)
#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);
#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);
}
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;
}
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);
}
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))
}
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);
}
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;
}
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;
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;
}
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;
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;
}
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;
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;
}
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;
(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);
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))
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;
}
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);
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;
}
}
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;
}
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);
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))
}
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."))
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;
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);
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);
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"))
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) };
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))
}
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;
}
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,
(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;
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;
}
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));
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;
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;
}
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;
}
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);
// 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);
}
}
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,
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);
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)
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) {
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))
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;
}
}
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);
}
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];
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);
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);
}
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)
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;
}
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);
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)
}
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);
}
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;
}
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))
}
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);
}
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)
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))
}
}
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;
}
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);
*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] &&
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;
}
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;
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);
// }
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);
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;
}
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);
}
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;
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;
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;
}
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);
}
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;
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);
}
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;
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);
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"))
}
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);
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);
}
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);
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)
}
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))
}
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);
}
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;
}
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;
}
}
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;
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;
}
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;
}
}
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;
}
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;
}
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)
}
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)
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;
}
}
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);
}
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;
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;
}
}
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);
}
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);
}
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))
}
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) {
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);
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;
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))
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;
}
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);
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 &&
}
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))
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))
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;
}
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;
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)
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;
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);
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;
}
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;
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) ?
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)
}
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);
}
}
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);
}
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;
}
}
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);
}
}
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);
}
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))
}
}
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;
}
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);
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;
}
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;
}
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;
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;
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;
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);
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;
}
#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;
}
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)
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;
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,
#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);
}
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;
m_str *const base = dep();
m_str *deps = base;
while(*deps) {
- CHECK_BB(plugin_ini(gwion, *deps))
+ CHECK_BB(plugin_ini(gwion, *deps));
++deps;
}
}
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);