ANN m_bool check_stmt_enum(const Env env, const Stmt_Enum def);
ANN m_bool scan0_stmt_type(const Env env, const Stmt_Type stmt);
+
+ANN m_bool scan0_class_def(const Env env, const Class_Def def);
ANN m_bool scan1_class_def(const Env env, const Class_Def def);
ANN m_bool scan2_class_def(const Env env, const Class_Def def);
ANN m_bool check_class_def(const Env env, const Class_Def def);
mp_free(p, Code, code);
}
-ANN static void emit_pop_scope(const Emitter emit) { GWDEBUG_EXE
+ANN static void emit_pop_scope(const Emitter emit) {
m_int offset;
while((offset = frame_pop(emit->code->frame)) > -1) {
Instr instr = emit_add_instr(emit, ObjectRelease);
return emit->code->frame->curr_offset;
}
-ANN static inline m_uint emit_local(const Emitter emit, const m_uint size, const m_bool is_obj) { GWDEBUG_EXE
+ANN static inline m_uint emit_local(const Emitter emit, const m_uint size, const m_bool is_obj) {
return frame_local(emit->gwion->p, emit->code->frame, size, is_obj);
}
-ANN static void emit_pre_ctor(const Emitter emit, const Type type) { GWDEBUG_EXE
+ANN static void emit_pre_ctor(const Emitter emit, const Type type) {
if(type->parent)
emit_pre_ctor(emit, type->parent);
if(type->nspc->pre_ctor)
emit_add_instr(emit, ArrayPost);
}
-ANN ArrayInfo* emit_array_extend_inner(const Emitter emit, const Type t, const Exp e) { GWDEBUG_EXE
+ANN ArrayInfo* emit_array_extend_inner(const Emitter emit, const Type t, const Exp e) {
CHECK_BO(emit_exp(emit, e, 0))
const Type base = array_base(t);
ArrayInfo* info = mp_alloc(emit->gwion->p, ArrayInfo);
return info;
}
-ANN void emit_ext_ctor(const Emitter emit, const VM_Code code) { GWDEBUG_EXE
+ANN void emit_ext_ctor(const Emitter emit, const VM_Code code) {
const Instr cpy = emit_add_instr(emit, Reg2Reg);
cpy->m_val2 = -SZ_INT;
const Instr push_f = emit_add_instr(emit, RegPushImm);
next->m_val2 = offset->m_val;
}
-ANN m_bool emit_array_extend(const Emitter emit, const Type t, const Exp e) { GWDEBUG_EXE
+ANN m_bool emit_array_extend(const Emitter emit, const Type t, const Exp e) {
CHECK_OB(emit_array_extend_inner(emit, t, e))
emit_add_instr(emit, PopArrayClass);
return GW_OK;
return ret;
}
-ANN static m_bool emit_symbol_builtin(const Emitter emit, const Exp_Primary* prim) { GWDEBUG_EXE
+ANN static m_bool emit_symbol_builtin(const Emitter emit, const Exp_Primary* prim) {
const Value v = prim->value;
if(GET_FLAG(v, func)) {
const Instr instr = emit_add_instr(emit, RegPushImm);
return GW_OK;
}
-ANN static m_bool emit_symbol(const Emitter emit, const Exp_Primary* prim) { GWDEBUG_EXE
+ANN static m_bool emit_symbol(const Emitter emit, const Exp_Primary* prim) {
const Value v = prim->value;
if(v->owner_class)
return emit_symbol_owned(emit, prim);
return GW_OK;
}
-ANEW ANN VM_Code emit_code(const Emitter emit) { GWDEBUG_EXE
+ANEW ANN VM_Code emit_code(const Emitter emit) {
Code* c = emit->code;
const VM_Code code = new_vm_code(emit->gwion->p, &c->instr, c->stack_depth,
c->flag, c->name);
return depth;
}
-ANN static m_bool emit_exp_array(const Emitter emit, const Exp_Array* array) { GWDEBUG_EXE
+ANN static m_bool emit_exp_array(const Emitter emit, const Exp_Array* array) {
const m_uint is_var = exp_self(array)->emit_var;
const m_uint depth = get_depth(array->base->type) - exp_self(array)->type->array_depth;
CHECK_BB(emit_exp(emit, array->base, 0))
return GW_OK;
}
-ANN static m_bool prim_vec(const Emitter emit, const Exp_Primary * primary) { GWDEBUG_EXE
+ANN static m_bool prim_vec(const Emitter emit, const Exp_Primary * primary) {
const Vec * vec = &primary->d.vec;
const ae_prim_t t = primary->primary_type;
CHECK_BB(emit_exp(emit, vec->exp, 0));
return GW_OK;
}
-ANN static m_bool prim_str(const Emitter emit, const Exp_Primary* prim) { GWDEBUG_EXE
+ANN static m_bool prim_str(const Emitter emit, const Exp_Primary* prim) {
char c[strlen(prim->d.str) + 1];
if(strlen(prim->d.str)) {
strcpy(c, prim->d.str);
(_exp_func)prim_vec, (_exp_func)prim_char, (_exp_func)dummy_func,
};
-ANN static m_bool emit_exp_primary(const Emitter emit, const Exp_Primary* prim) { GWDEBUG_EXE
+ANN static m_bool emit_exp_primary(const Emitter emit, const Exp_Primary* prim) {
return prim_func[prim->primary_type](emit, prim);
}
-ANN static m_bool emit_dot_static_data(const Emitter emit, const Value v, const uint emit_var) { GWDEBUG_EXE
+ANN static m_bool emit_dot_static_data(const Emitter emit, const Value v, const uint emit_var) {
const m_uint size = v->type->size;
if(isa(v->type, t_class) < 0) {
if(isa(v->type, t_union) < 0) {
return GW_OK;
}
-ANN static m_bool emit_exp_decl_static(const Emitter emit, const Var_Decl var_decl, const uint is_ref, const uint emit_addr) { GWDEBUG_EXE
+ANN static m_bool emit_exp_decl_static(const Emitter emit, const Var_Decl var_decl, const uint is_ref, const uint emit_addr) {
const Value value = var_decl->value;
if(isa(value->type, t_object) > 0 && !is_ref)
CHECK_BB(decl_static(emit, var_decl, 0))
}
ANN static m_bool emit_exp_decl_non_static(const Emitter emit, const Var_Decl var_decl,
- const uint is_ref, const uint emit_var) { GWDEBUG_EXE
+ const uint is_ref, const uint emit_var) {
const Value v = var_decl->value;
const Type type = v->type;
const Array_Sub array = var_decl->array;
}
ANN static m_bool emit_exp_decl_global(const Emitter emit, const Var_Decl var_decl,
- const uint is_ref, const uint emit_var) { GWDEBUG_EXE
+ const uint is_ref, const uint emit_var) {
const Value v = var_decl->value;
const Type type = v->type;
const Array_Sub array = var_decl->array;
ANN static m_bool emit_class_def(const Emitter, const Class_Def);
-ANN static m_bool emit_exp_decl_template(const Emitter emit, const Exp_Decl* decl) { GWDEBUG_EXE
+ANN static m_bool emit_exp_decl_template(const Emitter emit, const Exp_Decl* decl) {
const Type t = typedef_base(decl->type);
if(!GET_FLAG(t, emit)) {
CHECK_BB(template_push_types(emit->env, t->def->tmpl->list.list, t->def->tmpl->base))
return GW_OK;
}
-ANN static m_bool emit_exp_decl(const Emitter emit, const Exp_Decl* decl) { GWDEBUG_EXE
+ANN static m_bool emit_exp_decl(const Emitter emit, const Exp_Decl* decl) {
Var_Decl_List list = decl->list;
const uint ref = GET_FLAG(decl->td, ref) || type_ref(decl->type);
const uint var = exp_self(decl)->emit_var;
return ((i + (SZ_INT-1)) & ~(SZ_INT-1));
}
-ANN static void emit_func_arg_vararg(const Emitter emit, const Exp_Call* exp_call) { GWDEBUG_EXE
+ANN static void emit_func_arg_vararg(const Emitter emit, const Exp_Call* exp_call) {
const Instr instr = emit_add_instr(emit, VarargIni);
const Vector kinds = new_vector(emit->gwion->p);
if((instr->m_val = round2szint(vararg_size(exp_call, kinds))))
}
}
-ANN static m_bool emit_func_args(const Emitter emit, const Exp_Call* exp_call) { GWDEBUG_EXE
+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, 1))
if(GET_FLAG(exp_call->m_func->def, variadic))
return GW_OK;
}
-ANN static m_bool prepare_call(const Emitter emit, const Exp_Call* exp_call) { GWDEBUG_EXE
+ANN static m_bool prepare_call(const Emitter emit, const Exp_Call* exp_call) {
CHECK_BB(emit_func_args(emit, exp_call))
return emit_exp(emit, exp_call->func, 0);
}
return GW_OK;
}
-ANN static m_bool emit_exp_call(const Emitter emit, const Exp_Call* exp_call) { GWDEBUG_EXE
+ANN static m_bool emit_exp_call(const Emitter emit, const Exp_Call* exp_call) {
if(!exp_call->tmpl)
CHECK_BB(prepare_call(emit, exp_call))
else
return emit_exp_call1(emit, exp_call->m_func);
}
-ANN static m_bool emit_exp_binary(const Emitter emit, const Exp_Binary* bin) { GWDEBUG_EXE
+ANN static m_bool emit_exp_binary(const Emitter emit, const Exp_Binary* bin) {
const Exp lhs = bin->lhs;
const Exp rhs = bin->rhs;
struct Op_Import opi = { .op=bin->op, .lhs=lhs->type, .rhs=rhs->type, .pos=exp_self(bin)->pos, .data = (uintptr_t)bin };
return GW_OK;
}
-ANN static m_bool emit_exp_post(const Emitter emit, const Exp_Postfix* post) { GWDEBUG_EXE
+ANN static m_bool emit_exp_post(const Emitter emit, const Exp_Postfix* post) {
struct Op_Import opi = { .op=post->op, .lhs=post->exp->type, .data=(uintptr_t)post };
CHECK_BB(emit_exp(emit, post->exp, 1))
return op_emit(emit, &opi);
return emit_add_instr(emit, exec);
}
-ANN m_bool emit_exp_call1(const Emitter emit, const Func f) { GWDEBUG_EXE
+ANN m_bool emit_exp_call1(const Emitter emit, const Func f) {
if(!f->code || (GET_FLAG(f, ref) && !GET_FLAG(f, builtin))) {
if(GET_FLAG(f, template) && emit->env->func != f)
CHECK_BB(emit_template_code(emit, f))
emit_push_code(emit, c);
}
-ANN static m_bool spork_func(const Emitter emit, const Exp_Call* exp) { GWDEBUG_EXE
+ANN static m_bool spork_func(const Emitter emit, const Exp_Call* exp) {
if(GET_FLAG(exp->m_func, member))
SET_FLAG(emit->code, member);
return emit_exp_call1(emit, exp->m_func);
return GW_OK;
}
-ANN static m_bool emit_exp_unary(const Emitter emit, const Exp_Unary* unary) { GWDEBUG_EXE
+ANN static m_bool emit_exp_unary(const Emitter emit, const Exp_Unary* unary) {
struct Op_Import opi = { .op=unary->op, .data=(uintptr_t)unary };
if(unary->op != op_spork && unary->op != op_fork && unary->exp) {
CHECK_BB(emit_exp(emit, unary->exp, 1))
}
ANN static m_bool emit_implicit_cast(const Emitter emit,
- const restrict Type from, const restrict Type to) { GWDEBUG_EXE
+ const restrict Type from, const restrict Type to) {
struct Op_Import opi = { .op=op_impl, .lhs=from, .rhs=to, .data=(m_uint)from };
return op_emit(emit, &opi);
}
ANN static Instr emit_flow(const Emitter emit, const Type type,
- const f_instr f1, const f_instr f2) { GWDEBUG_EXE
+ const f_instr f1, const f_instr f2) {
if(isa(type, t_float) > 0 || isa(type, t_dur) > 0 || isa(type, t_time) > 0)
return emit_add_instr(emit, f2);
return emit_add_instr(emit, f1);
}
-ANN static m_bool emit_exp_if(const Emitter emit, const Exp_If* exp_if) { GWDEBUG_EXE
+ANN static m_bool emit_exp_if(const Emitter emit, const Exp_If* exp_if) {
CHECK_BB(emit_exp(emit, exp_if->cond, 0))
const Instr op = emit_flow(emit, exp_if->cond->type, BranchEqInt, BranchEqFloat);
CHECK_BB(emit_exp(emit, exp_if->if_exp, 0))
return ret;
}
-ANN static m_bool emit_exp_lambda(const Emitter emit, const Exp_Lambda * lambda) { GWDEBUG_EXE
+ANN static m_bool emit_exp_lambda(const Emitter emit, const Exp_Lambda * lambda) {
if(lambda->def) {
const m_uint scope = !lambda->owner ?
emit->env->scope->depth : emit_push_type(emit, lambda->owner);
DECL_EXP_FUNC(emit)
-ANN2(1) static m_bool emit_exp(const Emitter emit, Exp exp, const m_bool ref) { GWDEBUG_EXE
+ANN2(1) static m_bool emit_exp(const Emitter emit, Exp exp, const m_bool ref) {
do {
CHECK_BB(exp_func[exp->exp_type](emit, &exp->d))
if(exp->cast_to)
return GW_OK;
}
-ANN static m_bool emit_stmt_if(const Emitter emit, const Stmt_If stmt) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_if(const Emitter emit, const Stmt_If stmt) {
emit_push_scope(emit);
CHECK_BB(emit_exp(emit, stmt->cond, 0))
const Instr op = emit_flow(emit, isa(stmt->cond->type, t_object) > 0 ?
return GW_OK;
}
-ANN static m_bool emit_stmt_code(const Emitter emit, const Stmt_Code stmt) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_code(const Emitter emit, const Stmt_Code stmt) {
++emit->env->scope->depth;
const m_bool ret = stmt->stmt_list ? emit_stmt_list(emit, stmt->stmt_list) : 1;
--emit->env->scope->depth;
#endif
-ANN static m_bool emit_stmt_return(const Emitter emit, const Stmt_Exp stmt) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_return(const Emitter emit, const Stmt_Exp stmt) {
if(stmt->val) {
OPTIMIZE_TCO
CHECK_BB(emit_exp(emit, stmt->val, 0))
return GW_OK;
}
-ANN static inline m_bool emit_stmt_continue(const Emitter emit, const Stmt stmt NUSED) { GWDEBUG_EXE
+ANN static inline m_bool emit_stmt_continue(const Emitter emit, const Stmt stmt NUSED) {
vector_add(&emit->code->stack_cont, (vtype)emit_add_instr(emit, Goto));
return GW_OK;
}
-ANN static inline m_bool emit_stmt_break(const Emitter emit, const Stmt stmt NUSED) { GWDEBUG_EXE
+ANN static inline m_bool emit_stmt_break(const Emitter emit, const Stmt stmt NUSED) {
vector_add(&emit->code->stack_break, (vtype)emit_add_instr(emit, Goto));
return GW_OK;
}
return emit_flow(emit, e->type, instr_i, instr_f);
}
-ANN static m_bool emit_stmt_flow(const Emitter emit, const Stmt_Flow stmt) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_flow(const Emitter emit, const Stmt_Flow stmt) {
const m_uint index = emit_code_size(emit);
Instr op = NULL;
emit_push_stack(emit);
}
}
-ANN static m_bool emit_stmt_for(const Emitter emit, const Stmt_For stmt) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_for(const Emitter emit, const Stmt_For stmt) {
emit_push_stack(emit);
CHECK_BB(emit_stmt(emit, stmt->c1, 1))
const m_uint index = emit_code_size(emit);
return emit_add_instr(emit, Reg2Mem);
}
-ANN static m_bool emit_stmt_auto(const Emitter emit, const Stmt_Auto stmt) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_auto(const Emitter emit, const Stmt_Auto stmt) {
CHECK_BB(emit_exp(emit, stmt->exp, 0))
const Instr s1 = emit_add_instr(emit, MemSetImm);
emit_push_stack(emit);
return GW_OK;
}
-ANN static m_bool emit_stmt_loop(const Emitter emit, const Stmt_Loop stmt) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_loop(const Emitter emit, const Stmt_Loop stmt) {
emit_push_stack(emit);
CHECK_BB(emit_exp(emit, stmt->cond, 0))
const m_uint index = emit_code_size(emit);
return GW_OK;
}
-ANN static m_bool emit_stmt_jump(const Emitter emit, const Stmt_Jump stmt) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_jump(const Emitter emit, const Stmt_Jump stmt) {
if(!stmt->is_label)
stmt->data.instr = emit_add_instr(emit, Goto);
else {
return m;
}
-ANN static m_bool emit_stmt_switch(const Emitter emit, const Stmt_Switch stmt) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_switch(const Emitter emit, const Stmt_Switch stmt) {
switch_get(emit->env, stmt);
Instr push[3] = { NULL, NULL, NULL};
CHECK_BB(emit_exp(emit, stmt->val, 0))
return GW_OK;
}
-ANN static m_bool emit_stmt_case(const Emitter emit, const Stmt_Exp stmt) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_case(const Emitter emit, const Stmt_Exp stmt) {
CHECK_BB(switch_inside(emit->env, stmt_self(stmt)->pos))
m_int value = 0;
const Value v = case_value(stmt->val);
return GW_OK;
}
-ANN static m_bool emit_stmt_type(const Emitter emit, const Stmt_Type stmt) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_type(const Emitter emit, const Stmt_Type stmt) {
return stmt->type->def ? emit_class_def(emit, stmt->type->def) : 1;
}
-ANN static m_bool emit_stmt_enum(const Emitter emit, const Stmt_Enum stmt) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_enum(const Emitter emit, const Stmt_Enum stmt) {
LOOP_OPTIM
for(m_uint i = 0; i < vector_size(&stmt->values); ++i) {
const Value v = (Value)vector_at(&stmt->values, i);
return GW_OK;
}
-ANN void emit_union_offset(Decl_List l, const m_uint o) { GWDEBUG_EXE
+ANN void emit_union_offset(Decl_List l, const m_uint o) {
do {
Var_Decl_List v = l->self->d.exp_decl.list;
do v->self->value->offset = o;
} while((l = l->next));
}
-ANN static m_bool emit_stmt_union(const Emitter emit, const Stmt_Union stmt) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_union(const Emitter emit, const Stmt_Union stmt) {
Decl_List l = stmt->l;
m_uint scope = emit->env->scope->depth;
const m_bool global = GET_FLAG(stmt, global);
(_exp_func)dummy_func, (_exp_func)emit_stmt_type, (_exp_func)emit_stmt_union,
};
-ANN static m_bool emit_stmt(const Emitter emit, const Stmt stmt, const m_bool pop) { GWDEBUG_EXE
+ANN static m_bool emit_stmt(const Emitter emit, const Stmt stmt, const m_bool pop) {
CHECK_BB(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);
return GW_OK;
}
-ANN static m_bool emit_stmt_list(const Emitter emit, Stmt_List l) { GWDEBUG_EXE
+ANN static m_bool emit_stmt_list(const Emitter emit, Stmt_List l) {
do CHECK_BB(emit_stmt(emit, l->stmt, 1))
while((l = l->next));
return GW_OK;
}
-ANN static m_bool emit_dot_static_import_data(const Emitter emit, const Value v, const uint emit_addr) { GWDEBUG_EXE
+ANN static m_bool emit_dot_static_import_data(const Emitter emit, const Value v, const uint emit_addr) {
if(v->d.ptr && GET_FLAG(v, builtin)) {
if(GET_FLAG(v, enum)) {
const Instr func_i = emit_add_instr(emit, RegPushImm);
return emit_dot_static_data(emit, v, emit_addr);
}
-ANN static m_bool emit_complex_member(const Emitter emit, const Exp_Dot* member) { GWDEBUG_EXE
+ANN static m_bool emit_complex_member(const Emitter emit, const Exp_Dot* member) {
const Exp base = member->base;
base->emit_var = 1;
CHECK_BB(emit_exp(emit, base, 0))
return GW_OK;
}
-ANN static m_bool emit_vararg_start(const Emitter emit, const m_uint offset) { GWDEBUG_EXE
+ANN static m_bool emit_vararg_start(const Emitter emit, const m_uint offset) {
emit->env->func->variadic = emit_add_instr(emit, VarargTop);
emit->env->func->variadic->m_val = offset;
emit->env->func->variadic->m_val2 = emit_code_size(emit);
return GW_OK;
}
-ANN static void emit_vararg_end(const Emitter emit, const m_uint offset) { GWDEBUG_EXE
+ANN static void emit_vararg_end(const Emitter emit, const m_uint offset) {
const Instr instr = emit_add_instr(emit, VarargEnd);
instr->m_val = offset;
instr->m_val2 = emit->env->func->variadic->m_val2;
SET_FLAG(emit->env->func, empty);// mark vararg func as complete
}
-ANN static m_bool emit_vararg(const Emitter emit, const Exp_Dot* member) { GWDEBUG_EXE
+ANN static m_bool emit_vararg(const Emitter emit, const Exp_Dot* member) {
m_uint offset = emit->env->class_def ? SZ_INT : 0;
Arg_List l = emit->env->func->def->base->args;
const m_str str = s_name(member->xid);
return GW_OK;
}
-ANN static m_bool emit_exp_dot_special(const Emitter emit, const Exp_Dot* member) { GWDEBUG_EXE
+ANN static m_bool emit_exp_dot_special(const Emitter emit, const Exp_Dot* member) {
const Type t = member->t_base;
if(isa(t, t_complex) > 0 || isa(t, t_polar) > 0)
return emit_complex_member(emit, member);
return emit_vararg(emit, member);
}
-ANN static m_bool emit_member_func(const Emitter emit, const Exp_Dot* member, const Func func) { GWDEBUG_EXE
+ANN static m_bool emit_member_func(const Emitter emit, const Exp_Dot* member, const Func func) {
if(isa(member->t_base, t_class) > 0 || GET_FLAG(member->base->type, force)) {
const Instr func_i = emit_add_instr(emit, func->code ? RegPushImm : PushStaticCode);
func_i->m_val = (m_uint)(func->code ?: (VM_Code)func);
return GW_OK;
}
-ANN static m_bool emit_exp_dot(const Emitter emit, const Exp_Dot* member) { GWDEBUG_EXE
+ANN static m_bool emit_exp_dot(const Emitter emit, const Exp_Dot* member) {
if(is_special(member->t_base) > 0)
return emit_exp_dot_special(emit, member);
const Value value = find_value(actual_type(member->t_base), member->xid);
return (GET_FLAG(value, member) ? emit_member : emit_dot_static_import_data) (emit, value, exp_self(member)->emit_var);
}
-ANN static inline void emit_func_def_global(const Emitter emit, const Value value) { GWDEBUG_EXE
+ANN static inline void emit_func_def_global(const Emitter emit, const Value value) {
const Instr set_mem = emit_add_instr(emit, MemSetImm);
set_mem->m_val = value->offset;
set_mem->m_val2 = (m_uint)value->d.func_ref->code;
}
-ANN static void emit_func_def_init(const Emitter emit, const Func func) { GWDEBUG_EXE
+ANN static void emit_func_def_init(const Emitter emit, const Func func) {
const Type t = emit->env->class_def;
char c[(t ? strlen(t->name) + 1 : 0) + strlen(func->name) + 6];
sprintf(c, "%s%s%s(...)", t ? t->name : "", t ? "." : "", func->name);
emit_push_code(emit, c);
}
-ANN static void emit_func_def_args(const Emitter emit, Arg_List a) { GWDEBUG_EXE
+ANN static void emit_func_def_args(const Emitter emit, Arg_List a) {
do {
const Value value = a->var_decl->value;
const m_uint size = value->type->size;
} while((a = a->next));
}
-ANN static void emit_func_def_ensure(const Emitter emit, const Func_Def func_def) { GWDEBUG_EXE
+ANN static void emit_func_def_ensure(const Emitter emit, const Func_Def func_def) {
const m_uint size = func_def->base->ret_type->size;
if(size) {
const Instr instr = emit_kind(emit, size, 0, regpushimm);
vector_add(&emit->code->stack_return, (vtype)emit_add_instr(emit, Goto));
}
-ANN static void emit_func_def_return(const Emitter emit) { GWDEBUG_EXE
+ANN static void emit_func_def_return(const Emitter emit) {
const m_uint val = emit_code_size(emit);
LOOP_OPTIM
for(m_uint i = vector_size(&emit->code->stack_return) + 1; --i; ) {
emit_add_instr(emit, FuncReturn);
}
-ANN static void emit_func_def_code(const Emitter emit, const Func func) { GWDEBUG_EXE
+ANN static void emit_func_def_code(const Emitter emit, const Func func) {
func->code = emit_code(emit);
if(GET_FLAG(func->def, dtor)) {
emit->env->class_def->nspc->dtor = func->code;
}
}
-ANN static m_bool emit_func_def_body(const Emitter emit, const Func_Def func_def) { GWDEBUG_EXE
+ANN static m_bool emit_func_def_body(const Emitter emit, const Func_Def func_def) {
if(func_def->base->args)
emit_func_def_args(emit, func_def->base->args);
if(GET_FLAG(func_def, variadic))
return GW_OK;
}
-ANN static m_bool emit_func_def(const Emitter emit, const Func_Def func_def) { GWDEBUG_EXE
+ANN static m_bool emit_func_def(const Emitter emit, const Func_Def func_def) {
const Func func = get_func(emit->env, func_def);
const Func former = emit->env->func;
if(func->code)
DECL_SECTION_FUNC(emit)
-ANN Code* emit_class_code(const Emitter emit, const m_str name) { GWDEBUG_EXE
+ANN Code* emit_class_code(const Emitter emit, const m_str name) {
const m_uint len = strlen(name) + 7;
char c[len];
snprintf(c, len, "class %s", name);
return emit->code;
}
-ANN inline void emit_class_finish(const Emitter emit, const Nspc nspc) { GWDEBUG_EXE
+ANN inline void emit_class_finish(const Emitter emit, const Nspc nspc) {
emit_add_instr(emit, FuncReturn);
nspc->pre_ctor = emit_code(emit);
}
-ANN static inline void emit_class_push(const Emitter emit, const Type type) { GWDEBUG_EXE
+ANN static inline void emit_class_push(const Emitter emit, const Type type) {
vector_add(&emit->env->scope->class_stack, (vtype)emit->env->class_def);
emit->env->class_def = type;
}
-ANN static inline void emit_class_pop(const Emitter emit) { GWDEBUG_EXE
+ANN static inline void emit_class_pop(const Emitter emit) {
emit->env->class_def = (Type)vector_pop(&emit->env->scope->class_stack);
emit_pop_code(emit);
}
-ANN static m_bool emit_class_def(const Emitter emit, const Class_Def class_def) { GWDEBUG_EXE
+ANN static m_bool emit_class_def(const Emitter emit, const Class_Def class_def) {
const Type type = class_def->base.type;
const Nspc nspc = type->nspc;
if(tmpl_class_base(class_def->tmpl))
free_code(emit->gwion->p, code);
}
-ANN static void emit_free_stack(const Emitter emit) { GWDEBUG_EXE
+ANN static void emit_free_stack(const Emitter emit) {
LOOP_OPTIM
for(m_uint i = vector_size(&emit->stack) + 1; --i;)
emit_free_code(emit, (Code*)vector_at(&emit->stack, i - 1));
emit_free_code(emit, emit->code);
}
-ANN static inline m_bool emit_ast_inner(const Emitter emit, Ast ast) { GWDEBUG_EXE
+ANN static inline m_bool emit_ast_inner(const Emitter emit, Ast ast) {
do CHECK_BB(emit_section(emit, ast->section))
while((ast = ast->next));
return GW_OK;
}
-ANN VM_Code emit_ast(const Emitter emit, Ast ast) { GWDEBUG_EXE
+ANN VM_Code emit_ast(const Emitter emit, Ast ast) {
emit->code = new_code(emit, emit->env->name);
emit_push_scope(emit);
const m_bool ret = emit_ast_inner(emit, ast);
return GW_OK;
}
-INSTR(ArrayBottom) { GWDEBUG_EXE
+INSTR(ArrayBottom) {
*(M_Object*)(*(m_uint**)REG(-SZ_INT * 4))[(*(m_int*)REG(-SZ_INT * 3))++] = *(M_Object*)REG(-SZ_INT);
}
-INSTR(ArrayPost) { GWDEBUG_EXE
+INSTR(ArrayPost) {
xfree(*(m_uint**)REG(0));
}
-INSTR(ArrayInit) { GWDEBUG_EXE // for litteral array
+INSTR(ArrayInit) {// for litteral array
const Type t = (Type)instr->m_val;
const m_uint sz = *(m_uint*)REG(0);
const m_uint off = instr->m_val2 * sz;
return *num_obj > 0 ? (M_Object*)xcalloc(*num_obj, SZ_INT) : NULL;
}
-INSTR(ArrayAlloc) { GWDEBUG_EXE
+INSTR(ArrayAlloc) {
const ArrayInfo* info = (ArrayInfo*)instr->m_val;
m_uint num_obj = 1;
m_int idx = 0;
#include "import.h"
#define describe(name, op) \
-static INSTR(Complex##name) { GWDEBUG_EXE \
+static INSTR(Complex##name) {\
POP_REG(shred, SZ_COMPLEX); \
*(m_complex*)REG(-SZ_COMPLEX) op##= *(m_complex*)REG(0); \
}
describe(Mul, *)
describe(Div, /)
-static INSTR(ComplexRAssign) { GWDEBUG_EXE
+static INSTR(ComplexRAssign) {
POP_REG(shred, SZ_INT);
**(m_complex**)REG(0) = *(m_complex*)REG(-SZ_COMPLEX);
}
#define describe_r(name, op) \
-static INSTR(ComplexR##name) { GWDEBUG_EXE \
+static INSTR(ComplexR##name) {\
POP_REG(shred, SZ_INT); \
*(m_complex*)REG(-SZ_COMPLEX) = (**(m_complex**)REG(0) op##= (*(m_complex*)REG(-SZ_COMPLEX))); \
}
describe_r(Mul, *)
describe_r(Div, /)
-INSTR(ComplexReal) { GWDEBUG_EXE
+INSTR(ComplexReal) {
// if(!instr->m_val) { // other case skipped in emit.c
*(m_float*)REG(-SZ_INT) = **(m_float**)REG(-SZ_INT);
PUSH_REG(shred, SZ_FLOAT - SZ_INT);
// }
}
-INSTR(ComplexImag) { GWDEBUG_EXE
+INSTR(ComplexImag) {
if(instr->m_val) {
const m_float* f = *(m_float**)REG(-SZ_INT);
*(const m_float**)REG(-SZ_INT) = (f + 1);
}
#define polar_def1(name, op) \
-static INSTR(Polar##name) { GWDEBUG_EXE \
+static INSTR(Polar##name) {\
POP_REG(shred, SZ_COMPLEX); \
const m_complex a = *(m_complex*)REG(-SZ_COMPLEX); \
const m_complex b = *(m_complex*)REG(0); \
polar_def1(Sub, -)
#define polar_def2(name, op1, op2) \
-static INSTR(Polar##name) { GWDEBUG_EXE \
+static INSTR(Polar##name) {\
POP_REG(shred, SZ_COMPLEX); \
const m_complex a = *(m_complex*)REG(-SZ_COMPLEX); \
const m_complex b = *(m_complex*)REG(0); \
polar_def2(Div, /, -)
#define polar_def1_r(name, op) \
-static INSTR(PolarR##name) { GWDEBUG_EXE \
+static INSTR(PolarR##name) {\
POP_REG(shred, SZ_INT); \
const m_complex a = *(m_complex*)REG(-SZ_COMPLEX); \
const m_complex b = **(m_complex**)REG(0); \
polar_def1_r(Sub, -)
#define polar_def2_r(name, op1, op2) \
-static INSTR(PolarR##name) { GWDEBUG_EXE \
+static INSTR(PolarR##name) {\
POP_REG(shred, SZ_INT); \
const m_complex a = *(m_complex*)REG(-SZ_COMPLEX); \
const m_complex b = **(m_complex**)REG(0); \
return t_int;
}
-static INSTR(EventWait) { GWDEBUG_EXE
+static INSTR(EventWait) {
POP_REG(shred, SZ_FLOAT);
const M_Object event = *(M_Object*)REG(-SZ_INT);
if(!event)
ANN Type check_exp_call1(const Env env, const Exp_Call *exp);
ANN m_bool emit_exp_spork(const Emitter, const Exp_Unary*);
-static INSTR(LambdaAssign) { GWDEBUG_EXE
+static INSTR(LambdaAssign) {
POP_REG(shred, SZ_INT)
*(Func*)REG(-SZ_INT) = *(Func*)REG(0);
}
#include "nspc.h"
#include "shreduler_private.h"
-INSTR(EOC) { GWDEBUG_EXE
+INSTR(EOC) {
vm_shred_exit(shred);
}
#include "gwion.h"
-INSTR(DTOR_EOC) { GWDEBUG_EXE
+INSTR(DTOR_EOC) {
// TODO: we should be able to use shred->info->mp directly
shred->info->mp = (MemPool)instr->m_val;
const M_Object o = *(M_Object*)MEM(0);
map_set((Map)instr->m_val2, *(vtype*)REG((i) * SZ_INT), vector_at(v, i));
}
-INSTR(SwitchBranch) { GWDEBUG_EXE
+INSTR(SwitchBranch) {
POP_REG(shred, SZ_INT);
const Map map = *(Map*)REG(SZ_INT);
shred->pc = map_get(map, *(m_uint*)REG(0)) ?: instr->m_val;
}
#ifdef OPTIMIZE
-INSTR(PutArgsInMem) { GWDEBUG_EXE
+INSTR(PutArgsInMem) {
POP_REG(shred, instr->m_val)
for(m_uint i = 0; i < instr->m_val; i += SZ_INT)
*(m_uint*)(shred->mem + i) = *(m_uint*)(shred->reg + i);
#include "value.h"
#include "template.h"
-INSTR(PopArrayClass) { GWDEBUG_EXE
+INSTR(PopArrayClass) {
POP_REG(shred, SZ_INT);
const M_Object obj = *(M_Object*)REG(-SZ_INT);
const M_Object tmp = *(M_Object*)REG(0);
}
#define describe_logical(name, op) \
-static INSTR(name##Object) { GWDEBUG_EXE \
+static INSTR(name##Object) {\
POP_REG(shred, SZ_INT); \
const M_Object lhs = *(M_Object*)REG(-SZ_INT); \
const M_Object rhs = *(M_Object*)REG(0); \
return t_null;
}
-static INSTR(instr_ptr_assign) { GWDEBUG_EXE
+static INSTR(instr_ptr_assign) {
POP_REG(shred, SZ_INT)
const M_Object o = *(M_Object*)REG(0);
*(m_uint**)o->data = *(m_uint**)REG(-SZ_INT);
return NULL;
}
-static INSTR(instr_ptr_deref) { GWDEBUG_EXE
+static INSTR(instr_ptr_deref) {
const M_Object o = *(M_Object*)REG(-SZ_INT);
if(instr->m_val2)
memcpy(REG(-SZ_INT), o->data, SZ_INT);
return GW_OK;
}
-static INSTR(Cast2Ptr) { GWDEBUG_EXE
+static INSTR(Cast2Ptr) {
const M_Object o = new_object(shred->info->mp, shred, t_ptr);
*(m_uint**)o->data = *(m_uint**)REG(-SZ_INT);
*(M_Object*)REG(-SZ_INT) = o;
}
#define describe_string_logical(name, action) \
-static INSTR(String_##name) { GWDEBUG_EXE \
+static INSTR(String_##name) {\
POP_REG(shred, SZ_INT); \
const M_Object lhs = *(M_Object*)REG(-SZ_INT); \
const M_Object rhs = *(M_Object*)REG(0); \
(lhs && !rhs) || (!lhs && rhs))
#define describe_string_assign(name, type, offset, opt, len, format, ...) \
-static INSTR(name##String_Assign) { GWDEBUG_EXE \
+static INSTR(name##String_Assign) {\
POP_REG(shred, offset); \
const type lhs = *(type*)REG(-SZ_INT); \
const M_Object rhs = *(M_Object*)REG(offset - SZ_INT); \
push_string(shred, rhs, str); \
}
-static INSTR(String_Assign) { GWDEBUG_EXE
+static INSTR(String_Assign) {
POP_REG(shred, SZ_INT);
const M_Object lhs = *(M_Object*)REG(-SZ_INT);
const M_Object rhs = *(M_Object*)REG(0);
16,
"%p", (void*)lhs)
-static INSTR(String_String) { GWDEBUG_EXE
+static INSTR(String_String) {
POP_REG(shred, SZ_INT);
const M_Object lhs = *(M_Object*)REG(-SZ_INT);
const M_Object rhs = *(M_Object*)REG(0);
}
#define describe_string(name, type, offset, len, opt, format, ...) \
-static INSTR(name##_String) { GWDEBUG_EXE \
+static INSTR(name##_String) {\
POP_REG(shred, offset); \
const type lhs = *(type*)REG(-SZ_INT);\
const M_Object rhs = *(M_Object*)REG(offset-SZ_INT);\
#define describe_string_plus(name, offset, type, opt, len, format, ...) \
-static INSTR(name##String_Plus) { GWDEBUG_EXE \
+static INSTR(name##String_Plus) {\
POP_REG(shred, offset); \
const type lhs = *(type*)REG(-SZ_INT); \
const M_Object rhs = *(M_Object*)REG(offset - SZ_INT); \
Except(shred, "NonTriggerException"); \
}
#define describe_connect_instr(name, func, opt) \
-static INSTR(name##func) { GWDEBUG_EXE \
+static INSTR(name##func) {\
M_Object lhs, rhs; \
if(connect_init(shred, &lhs, &rhs) > 0) { \
opt \
mp_free(p, Vararg, arg);
}
-INSTR(VarargTop) { GWDEBUG_EXE
+INSTR(VarargTop) {
struct Vararg_* arg = *(struct Vararg_**)MEM(instr->m_val);
if(arg) {
if(arg->d)
shred->pc = instr->m_val2 + 1;
}
-INSTR(VarargIni) { GWDEBUG_EXE
+INSTR(VarargIni) {
struct Vararg_* arg = mp_alloc(shred->info->mp, Vararg);
POP_REG(shred, instr->m_val - SZ_INT)
arg->d = (m_bit*)xmalloc(instr->m_val);
*(struct Vararg_**)REG(-SZ_INT) = arg;
}
-INSTR(VarargEnd) { GWDEBUG_EXE
+INSTR(VarargEnd) {
struct Vararg_* arg = *(struct Vararg_**)MEM(instr->m_val);
PUSH_REG(shred, SZ_INT);
arg->o += arg->k[arg->i];
free_vararg(shred->info->mp, arg);
}
-INSTR(VarargMember) { GWDEBUG_EXE
+INSTR(VarargMember) {
const struct Vararg_* arg = *(struct Vararg_**)MEM(instr->m_val);
for(m_uint i = 0; i < instr->m_val2; i += SZ_INT)
*(m_uint*)REG(i) = *(m_uint*)(arg->d + arg->o + i);
return bin->rhs->type;
}
-static INSTR(VarargAssign) { GWDEBUG_EXE
+static INSTR(VarargAssign) {
POP_REG(shred, SZ_INT);
*(M_Object**)REG(0) = &*(M_Object*)REG(-SZ_INT);
}
*(m_bit**)(shred->mem + instr->m_val) = (shred->mem + instr->m_val - instr->m_val2);
}
-INSTR(VecMember) { GWDEBUG_EXE
+INSTR(VecMember) {
if(instr->m_val)
*(m_float**)REG(-SZ_INT) = (m_float*)(*(m_bit**)REG(-SZ_INT) + instr->m_val2);
else {
}
#define describe_vec3(name, op) \
-static INSTR(Vec3##name) { GWDEBUG_EXE \
+static INSTR(Vec3##name) {\
POP_REG(shred, SZ_VEC3); \
m_vec3 r, * t = (m_vec3*)REG(-SZ_VEC3); \
r.x = t->x op (t + 1)->x; \
#define describe_float_vec3(func) \
-static INSTR(Float##func##Vec3) { GWDEBUG_EXE \
+static INSTR(Float##func##Vec3) {\
POP_REG(shred, SZ_FLOAT); \
const m_float f = *(m_float*)REG(-SZ_VEC3); \
const m_vec3 r = *(m_vec3*)REG(-SZ_COMPLEX); \
describe_float_vec3(Div)
#define describe_vec3_float(func) \
-static INSTR(Vec3##func##Float) { GWDEBUG_EXE \
+static INSTR(Vec3##func##Float) {\
POP_REG(shred, SZ_FLOAT); \
const m_vec3 r = *(m_vec3*)REG(-SZ_VEC3); \
const m_float f = *(m_float*)REG(0); \
describe_vec3_float(Mul)
describe_vec3_float(Div)
-static INSTR(Vec3RAssign) { GWDEBUG_EXE
+static INSTR(Vec3RAssign) {
POP_REG(shred, SZ_INT);
m_vec3* r = *(m_vec3**)REG(0);
r->x = *(m_float*)REG(-SZ_VEC3);
}
#define describe_vec4(name, op) \
-static INSTR(Vec4##name) { GWDEBUG_EXE \
+static INSTR(Vec4##name) {\
POP_REG(shred, SZ_VEC4); \
m_vec4 r, * t = (m_vec4*)REG(-SZ_VEC4); \
r.x = t->x op (t + 1)->x; \
describe_vec4(Div, /)
#define describe_float_vec4(func) \
-static INSTR(Float##func##Vec4) { GWDEBUG_EXE \
+static INSTR(Float##func##Vec4) {\
POP_REG(shred, SZ_FLOAT); \
m_float f = *(m_float*)REG(-SZ_VEC4); \
m_vec4 r = *(m_vec4*)REG(-SZ_VEC3); \
describe_float_vec4(Div)
#define describe_vec4_float(func) \
-static INSTR(Vec4##func##Float) { GWDEBUG_EXE \
+static INSTR(Vec4##func##Float) {\
POP_REG(shred, SZ_FLOAT); \
m_vec4 r = *(m_vec4*)REG(-SZ_VEC4); \
m_float f = *(m_float*)REG(0); \
describe_vec4_float(Mul)
describe_vec4_float(Div)
-static INSTR(Vec4RAssign) { GWDEBUG_EXE
+static INSTR(Vec4RAssign) {
POP_REG(shred, SZ_INT);
m_vec4* r = *(m_vec4**)REG(0);
r->x = *(m_float*)REG(-SZ_VEC4);
ANN static m_bool check_stmt_list(const Env env, Stmt_List list);
ANN m_bool check_class_def(const Env env, const Class_Def class_def);
-ANN m_bool check_exp_array_subscripts(Env env, Exp exp) { GWDEBUG_EXE
+ANN m_bool check_exp_array_subscripts(Env env, Exp exp) {
CHECK_OB(check_exp(env, exp))
do if(isa(exp->type, t_int) < 0)
ERR_B(exp->pos, "incompatible array subscript type '%s' ...", exp->type->name)
return GW_OK;
}
-ANN static inline m_bool check_exp_decl_parent(const Env env, const Var_Decl var) { GWDEBUG_EXE
+ANN static inline m_bool check_exp_decl_parent(const Env env, const Var_Decl var) {
const Value value = find_value(env->class_def->parent, var->xid);
if(value)
ERR_B(var->pos,
return t;
}
-ANN Type check_exp_decl(const Env env, const Exp_Decl* decl) { GWDEBUG_EXE
+ANN Type check_exp_decl(const Env env, const Exp_Decl* decl) {
Var_Decl_List list = decl->list;
CHECK_BO(switch_decl(env, exp_self(decl)->pos))
if(!decl->td->xid) {
(_type_func)prim_vec, (_type_func)prim_num, (_type_func)prim_nil,
};
-ANN static Type check_exp_primary(const Env env, const Exp_Primary* primary) { GWDEBUG_EXE
+ANN static Type check_exp_primary(const Env env, const Exp_Primary* primary) {
return exp_self(primary)->type = prim_func[primary->primary_type](env, primary);
}
-ANN Type check_exp_array(const Env env, const Exp_Array* array) { GWDEBUG_EXE
+ANN Type check_exp_array(const Env env, const Exp_Array* array) {
Type t_base = check_exp(env, array->base);
CHECK_OO(t_base)
Exp e = array->array->exp;
func->def->base->ret_type : function_alternative(env, exp->func->type, exp->args, exp_self(exp)->pos);
}
-ANN static Type check_exp_binary(const Env env, const Exp_Binary* bin) { GWDEBUG_EXE
+ANN static Type check_exp_binary(const Env env, const Exp_Binary* bin) {
if(bin->lhs->exp_type == ae_exp_unary && bin->lhs->d.exp_unary.op == op_fork &&
bin->rhs->exp_type == ae_exp_decl)
bin->lhs->d.exp_unary.fork_ok = 1;
return op_check(env, &opi);
}
-ANN static Type check_exp_cast(const Env env, const Exp_Cast* cast) { GWDEBUG_EXE
+ANN static Type check_exp_cast(const Env env, const Exp_Cast* cast) {
const Type t = check_exp(env, cast->exp);
CHECK_OO(t)
CHECK_OO((exp_self(cast)->type = cast->td->xid ? known_type(env, cast->td) : check_td(env, cast->td)))
return op_check(env, &opi);
}
-ANN static Type check_exp_post(const Env env, const Exp_Postfix* post) { GWDEBUG_EXE
+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)
return op_check(env, &opi);
}
-ANN static Type check_exp_call(const Env env, Exp_Call* exp) { GWDEBUG_EXE
+ANN static Type check_exp_call(const Env env, Exp_Call* exp) {
if(exp->tmpl) {
CHECK_OO(check_exp(env, exp->func))
const Type t = actual_type(exp->func->type);
return check_exp_call1(env, exp);
}
-ANN static Type check_exp_unary(const Env env, const Exp_Unary* unary) { GWDEBUG_EXE
+ANN static Type check_exp_unary(const Env env, const Exp_Unary* unary) {
struct Op_Import opi = { .op=unary->op, .rhs=unary->exp ? check_exp(env, unary->exp) : NULL,
.data=(uintptr_t)unary, .pos=exp_self(unary)->pos };
if(unary->exp && !opi.rhs)
return op_check(env, &opi);
}
-ANN static Type check_exp_if(const Env env, const Exp_If* exp_if) { GWDEBUG_EXE
+ANN static Type check_exp_if(const Env env, const Exp_If* exp_if) {
const Type cond = check_exp(env, exp_if->cond);
CHECK_OO(cond)
const Type if_exp = check_exp(env, exp_if->if_exp);
return ret;
}
-ANN static Type check_exp_dot(const Env env, Exp_Dot* member) { GWDEBUG_EXE
+ANN static Type check_exp_dot(const Env env, Exp_Dot* member) {
const m_str str = s_name(member->xid);
CHECK_OO((member->t_base = check_exp(env, member->base)))
const m_bool base_static = isa(member->t_base, t_class) > 0;
return value->type;
}
-ANN static m_bool check_stmt_type(const Env env, const Stmt_Type stmt) { GWDEBUG_EXE
+ANN static m_bool check_stmt_type(const Env env, const Stmt_Type stmt) {
return stmt->type->def ? check_class_def(env, stmt->type->def) : 1;
}
ANN static Type check_exp_lambda(const Env env NUSED,
(_type_func)check_exp_dot, (_type_func)check_exp_lambda, (_type_func)check_exp_typeof
};
-ANN static inline Type check_exp(const Env env, const Exp exp) { GWDEBUG_EXE
+ANN static inline Type check_exp(const Env env, const Exp exp) {
Exp curr = exp;
do {
CHECK_OO((curr->type = exp_func[curr->exp_type](env, &curr->d)))
return exp->type;
}
-ANN m_bool check_stmt_enum(const Env env, const Stmt_Enum stmt) { GWDEBUG_EXE
+ANN m_bool check_stmt_enum(const Env env, const Stmt_Enum stmt) {
if(env->class_def) {
ID_List list = stmt->list;
do decl_static(env->curr, nspc_lookup_value0(env->curr, list->xid));
return GW_OK;
}
-ANN static m_bool check_stmt_code(const Env env, const Stmt_Code stmt) { GWDEBUG_EXE
+ANN static m_bool check_stmt_code(const Env env, const Stmt_Code stmt) {
if(stmt->stmt_list) { RET_NSPC(check_stmt_list(env, stmt->stmt_list)) }
return GW_OK;
}
-ANN static m_bool check_flow(const Env env, const Exp exp, const m_str orig) { GWDEBUG_EXE
+ANN static m_bool check_flow(const Env env, const Exp exp, const m_str orig) {
if(isa(exp->type, t_object) > 0 || isa(exp->type, t_int) > 0 || isa(exp->type, t_float) > 0 ||
isa(exp->type, t_dur) > 0 || isa(exp->type, t_time) > 0)
return GW_OK;
ERR_B(exp->pos, "invalid type '%s' (in '%s' condition)", exp->type->name, orig)
}
-ANN static m_bool check_breaks(const Env env, const Stmt a, const Stmt b) { GWDEBUG_EXE
+ANN static m_bool check_breaks(const Env env, const Stmt a, const Stmt b) {
vector_add(&env->scope->breaks, (vtype)a);
RET_NSPC(check_stmt(env, b))
vector_pop(&env->scope->breaks);
return ret;
}
-ANN static m_bool check_conts(const Env env, const Stmt a, const Stmt b) { GWDEBUG_EXE
+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))
vector_pop(&env->scope->conts);
return GW_OK;
}
-ANN static m_bool do_stmt_auto(const Env env, const Stmt_Auto stmt) { GWDEBUG_EXE
+ANN static m_bool do_stmt_auto(const Env env, const Stmt_Auto stmt) {
Type t = check_exp(env, stmt->exp);
CHECK_OB(t)
Type ptr = array_base(t);
check_breaks(env, stmt_self(stmt), stmt->stmt) < 0 || switch_pop(env) < 0) ? 1 : -1)
stmt_func_xxx(auto, Stmt_Auto,, do_stmt_auto(env, stmt))
-ANN static m_bool check_stmt_return(const Env env, const Stmt_Exp stmt) { GWDEBUG_EXE
+ANN static m_bool check_stmt_return(const Env env, const Stmt_Exp stmt) {
if(!env->func)
ERR_B(stmt_self(stmt)->pos, "'return' statement found outside function definition")
const Type ret_type = stmt->val ? check_exp(env, stmt->val) : t_void;
}
#define describe_check_stmt_stack(stack, name) \
-ANN static m_bool check_stmt_##name(const Env env, const Stmt stmt) { GWDEBUG_EXE \
+ANN static m_bool check_stmt_##name(const Env env, const Stmt stmt) {\
if(!vector_size(&env->scope->stack)) \
ERR_B(stmt->pos, "'"#name"' found outside of for/while/until...") \
return GW_OK; \
describe_check_stmt_stack(breaks, break)
ANN Value case_value(const Exp exp);
-ANN static m_bool check_stmt_case(const Env env, const Stmt_Exp stmt) { GWDEBUG_EXE
+ANN static m_bool check_stmt_case(const Env env, const Stmt_Exp stmt) {
CHECK_BB(switch_inside(env, stmt_self(stmt)->pos));
const Type t = check_exp(env, stmt->val);
CHECK_OB(t);
return GW_OK;
}
-ANN static m_bool check_stmt_jump(const Env env, const Stmt_Jump stmt) { GWDEBUG_EXE
+ANN static m_bool check_stmt_jump(const Env env, const Stmt_Jump stmt) {
if(stmt->is_label)
return GW_OK;
const Map label = env_label(env);
return GW_OK;
}
-ANN m_bool check_stmt_union(const Env env, const Stmt_Union stmt) { GWDEBUG_EXE
+ANN m_bool check_stmt_union(const Env env, const Stmt_Union stmt) {
if(stmt->xid) {
if(env->class_def)
(!GET_FLAG(stmt, static) ? decl_member : decl_static)(env->curr, stmt->value);
(_exp_func)dummy_func, (_exp_func)check_stmt_type, (_exp_func)check_stmt_union,
};
-ANN m_bool check_stmt(const Env env, const Stmt stmt) { GWDEBUG_EXE
+ANN m_bool check_stmt(const Env env, const Stmt stmt) {
return stmt_func[stmt->stmt_type](env, &stmt->d);
}
-ANN static m_bool check_stmt_list(const Env env, Stmt_List l) { GWDEBUG_EXE
+ANN static m_bool check_stmt_list(const Env env, Stmt_List l) {
do CHECK_BB(check_stmt(env, l->stmt))
while((l = l->next));
return GW_OK;
}
-ANN static m_bool check_signature_match(const Env env, const Func_Def f, const Func parent) { GWDEBUG_EXE
+ANN static m_bool check_signature_match(const Env env, const Func_Def f, const Func parent) {
if(GET_FLAG(parent->def, static) != GET_FLAG(f, static)) {
const m_str c_name = f->base->func->value_ref->owner_class->name;
const m_str p_name = parent->value_ref->owner_class->name;
return 0;
}
-ANN static m_bool check_parent_match(const Env env, const Func_Def f) { GWDEBUG_EXE
+ANN static m_bool check_parent_match(const Env env, const Func_Def f) {
const Func func = f->base->func;
const Type parent = env->class_def->parent;
if(parent) {
return GW_OK;
}
-ANN static m_bool check_func_args(const Env env, Arg_List arg_list) { GWDEBUG_EXE
+ANN static m_bool check_func_args(const Env env, Arg_List arg_list) {
do {
const Var_Decl decl = arg_list->var_decl;
const Value v = decl->value;
return GW_OK;
}
-ANN static m_bool check_func_def_override(const Env env, const Func_Def f) { GWDEBUG_EXE
+ANN static m_bool check_func_def_override(const Env env, const Func_Def f) {
const Func func = f->base->func;
if(env->class_def && env->class_def->parent) {
const Value override = find_value(env->class_def->parent, f->base->xid);
operator_set_func(&opi);
}
-ANN m_bool check_func_def(const Env env, const Func_Def f) { GWDEBUG_EXE
+ANN m_bool check_func_def(const Env env, const Func_Def f) {
const Func func = get_func(env, f);
m_bool ret = GW_OK;
if(tmpl_list_base(f->tmpl))
DECL_SECTION_FUNC(check)
-ANN static m_bool check_class_parent(const Env env, const Class_Def class_def) { GWDEBUG_EXE
+ANN static m_bool check_class_parent(const Env env, const Class_Def class_def) {
if(class_def->base.ext->array) {
CHECK_BB(check_exp_array_subscripts(env, class_def->base.ext->array->exp))
if(!GET_FLAG(class_def->base.type, check) && class_def->tmpl)
vector_copy2(&parent->info->vtable, &nspc->info->vtable);
}
-ANN m_bool check_class_def(const Env env, const Class_Def class_def) { GWDEBUG_EXE
+ANN m_bool check_class_def(const Env env, const Class_Def class_def) {
if(tmpl_class_base(class_def->tmpl))
return GW_OK;
if(class_def->base.type->parent == t_undefined) {
return GW_OK;
}
-ANN m_bool check_ast(const Env env, Ast ast) { GWDEBUG_EXE
+ANN m_bool check_ast(const Env env, Ast ast) {
do CHECK_BB(check_section(env, ast->section))
while((ast = ast->next));
return GW_OK;
#include "nspc.h"
#include "vm.h"
#include "parse.h"
-
-ANN m_bool scan0_class_def(const Env env, const Class_Def class_def);
+#include "traverse.h"
ANN static Value mk_class(const Env env, const Type base) {
const Type t = type_copy(env->gwion->p, t_class);
return already_defined(env, s, pos);
}
-ANN m_bool scan0_stmt_fptr(const Env env, const Stmt_Fptr stmt) { GWDEBUG_EXE
+ANN m_bool scan0_stmt_fptr(const Env env, const Stmt_Fptr stmt) {
CHECK_BB(env_access(env, stmt->base->td->flag, stmt_self(stmt)->pos))
CHECK_BB(scan0_defined(env, stmt->base->xid, td_pos(stmt->base->td)));
const m_str name = s_name(stmt->base->xid);
return GW_OK;
}
-ANN /*static */ m_bool scan0_stmt_type(const Env env, const Stmt_Type stmt) { GWDEBUG_EXE
+ANN m_bool scan0_stmt_type(const Env env, const Stmt_Type stmt) {
CHECK_BB(env_access(env, stmt->ext->flag, stmt_self(stmt)->pos))
const Type base = known_type(env, stmt->ext);
CHECK_OB(base)
SET_FLAG(t, empty);
} else {
const ae_flag flag = base->def ? base->def->flag : 0;
- const Class_Def def = new_class_def(env->gwion->p, flag, stmt->xid, stmt->ext, NULL,
+ const Class_Def cdef = new_class_def(env->gwion->p, flag, stmt->xid, stmt->ext, NULL,
loc_cpy(env->gwion->p, td_pos(stmt->ext)));
- CHECK_BB(scan0_class_def(env, def))
- stmt->type = def->base.type;
+ CHECK_BB(scan0_class_def(env, cdef))
+ stmt->type = cdef->base.type;
}
SET_FLAG(stmt->type, typedef);
return GW_OK;
}
-ANN m_bool scan0_stmt_enum(const Env env, const Stmt_Enum stmt) { GWDEBUG_EXE
+ANN m_bool scan0_stmt_enum(const Env env, const Stmt_Enum stmt) {
CHECK_BB(env_storage(env, stmt->flag, stmt_self(stmt)->pos))
if(stmt->xid) {
const Value v = nspc_lookup_value1(env->curr, stmt->xid);
if(v)
ERR_B(stmt_self(stmt)->pos, "'%s' already declared as variable of type '%s'.",
s_name(stmt->xid), v->type->name)
- CHECK_BB(scan0_defined(env, stmt->xid, stmt_self(stmt)->pos)) // test for type ?
+ CHECK_BB(scan0_defined(env, stmt->xid, stmt_self(stmt)->pos))
}
const Type t = type_copy(env->gwion->p, t_int);
t->xid = ++env->scope->type_xid;
return t;
}
-ANN /* static */m_bool scan0_stmt_union(const Env env, const Stmt_Union stmt) { GWDEBUG_EXE
+ANN m_bool scan0_stmt_union(const Env env, const Stmt_Union stmt) {
CHECK_BB(env_storage(env, stmt->flag, stmt_self(stmt)->pos))
if(stmt->xid) {
CHECK_BB(scan0_defined(env, stmt->xid, stmt_self(stmt)->pos))
ANN static m_bool scan0_stmt_switch(const Env env, const Stmt_Switch stmt);
ANN static m_bool scan0_stmt_code(const Env env, const Stmt_Code stmt);
-ANN static m_bool scan0_stmt(const Env env, const Stmt stmt) { GWDEBUG_EXE
+ANN static m_bool scan0_stmt(const Env env, const Stmt stmt) {
if(stmt->stmt_type == ae_stmt_fptr)
return scan0_stmt_fptr(env, &stmt->d.stmt_fptr);
if(stmt->stmt_type == ae_stmt_type)
ANN static m_bool scan0_stmt_list(const Env env, Stmt_List l);
ANN static m_bool scan0_stmt_switch(const Env env, const Stmt_Switch stmt) {
-// CHECK_BB(scan0_exp(env, stmt->val))
return scan0_stmt(env, stmt->stmt);
}
-ANN static m_bool scan0_stmt_code(const Env env, const Stmt_Code stmt) { GWDEBUG_EXE
+ANN static m_bool scan0_stmt_code(const Env env, const Stmt_Code stmt) {
return stmt->stmt_list ? scan0_stmt_list(env, stmt->stmt_list) : GW_OK;
}
-ANN static m_bool scan0_stmt_list(const Env env, Stmt_List l) { GWDEBUG_EXE
+ANN static m_bool scan0_stmt_list(const Env env, Stmt_List l) {
do CHECK_BB(scan0_stmt(env, l->stmt))
while((l = l->next));
return GW_OK;
}
-ANN static m_bool scan0_class_def_pre(const Env env, const Class_Def class_def) { GWDEBUG_EXE
- CHECK_BB(env_storage(env, class_def->flag, class_def->pos))
- if(GET_FLAG(class_def, global)) {
+ANN static m_bool scan0_class_def_pre(const Env env, const Class_Def cdef) {
+ CHECK_BB(env_storage(env, cdef->flag, cdef->pos))
+ if(GET_FLAG(cdef, global)) {
vector_add(&env->scope->nspc_stack, (vtype)env->curr);
env->curr = env->global_nspc;
}
- CHECK_BB(scan0_defined(env, class_def->base.xid, class_def->pos)) // test for type ?
- CHECK_BB(isres(env, class_def->base.xid, class_def->pos))
+ CHECK_BB(scan0_defined(env, cdef->base.xid, cdef->pos))
+ CHECK_BB(isres(env, cdef->base.xid, cdef->pos))
return GW_OK;
}
-ANN static Type scan0_class_def_init(const Env env, const Class_Def class_def) { GWDEBUG_EXE
- const Type t = new_type(env->gwion->p, ++env->scope->type_xid, s_name(class_def->base.xid), t_object);
+ANN static Type scan0_class_def_init(const Env env, const Class_Def cdef) {
+ const Type t = new_type(env->gwion->p, ++env->scope->type_xid, s_name(cdef->base.xid), t_object);
t->owner = env->curr;
t->nspc = new_nspc(env->gwion->p, t->name);
- t->nspc->parent = GET_FLAG(class_def, global) ? env_nspc(env) : env->curr;
- t->def = class_def;
- t->flag = class_def->flag;
+ t->nspc->parent = GET_FLAG(cdef, global) ? env_nspc(env) : env->curr;
+ t->def = cdef;
+ t->flag = cdef->flag;
if(!strstr(t->name, "<"))
- nspc_add_type(env->curr, class_def->base.xid, t);
- if(class_def->tmpl) {
+ nspc_add_type(env->curr, cdef->base.xid, t);
+ if(cdef->tmpl) {
SET_FLAG(t, template);
- SET_FLAG(class_def, template);
+ SET_FLAG(cdef, template);
}
- if(class_def->base.ext && class_def->base.ext->array)
+ if(cdef->base.ext && cdef->base.ext->array)
SET_FLAG(t, typedef);
return t;
}
-ANN static m_bool scan0_func_def(const Env env, const Func_Def def) {
- return def->d.code ? scan0_stmt(env, def->d.code) : GW_OK;
+ANN static m_bool scan0_func_def(const Env env, const Func_Def fdef) {
+ return fdef->d.code ? scan0_stmt(env, fdef->d.code) : GW_OK;
}
-ANN static m_bool scan0_section(const Env env, const Section* section) { GWDEBUG_EXE
+ANN static m_bool scan0_section(const Env env, const Section* section) {
if(section->section_type == ae_section_stmt)
return scan0_stmt_list(env, section->d.stmt_list);
if(section->section_type == ae_section_class)
return GW_OK;
}
-ANN m_bool scan0_class_def(const Env env, const Class_Def class_def) { GWDEBUG_EXE
- CHECK_BB(scan0_class_def_pre(env, class_def))
- CHECK_OB((class_def->base.type = scan0_class_def_init(env, class_def)))
- if(class_def->body) {
- Class_Body body = class_def->body;
- const m_uint scope = env_push_type(env, class_def->base.type);
+ANN m_bool scan0_class_def(const Env env, const Class_Def cdef) {
+ CHECK_BB(scan0_class_def_pre(env, cdef))
+ CHECK_OB((cdef->base.type = scan0_class_def_init(env, cdef)))
+ if(cdef->body) {
+ Class_Body body = cdef->body;
+ const m_uint scope = env_push_type(env, cdef->base.type);
do CHECK_BB(scan0_section(env, body->section))
while((body = body->next));
env_pop(env, scope);
}
- (void)mk_class(env, class_def->base.type);
- if(GET_FLAG(class_def, global))
+ (void)mk_class(env, cdef->base.type);
+ if(GET_FLAG(cdef, global))
env->curr = (Nspc)vector_pop(&env->scope->nspc_stack);
return GW_OK;
}
-ANN m_bool scan0_ast(const Env env, Ast prog) { GWDEBUG_EXE
- do CHECK_BB(scan0_section(env, prog->section))
- while((prog = prog->next));
+ANN m_bool scan0_ast(const Env env, Ast ast) {
+ do CHECK_BB(scan0_section(env, ast->section))
+ while((ast = ast->next));
return GW_OK;
}
return t;
}
-ANN m_bool scan1_exp_decl(const Env env, const Exp_Decl* decl) { GWDEBUG_EXE
+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))
Var_Decl_List list = decl->list;
((Exp_Decl*)decl)->type = scan1_exp_decl_type(env, (Exp_Decl*)decl);
return GW_OK;
}
-ANN static inline m_bool scan1_exp_binary(const Env env, const Exp_Binary* bin) { GWDEBUG_EXE
+ANN static inline m_bool scan1_exp_binary(const Env env, const Exp_Binary* bin) {
CHECK_BB(scan1_exp(env, bin->lhs))
return scan1_exp(env, bin->rhs);
}
-ANN static inline m_bool scan1_exp_primary(const Env env, const Exp_Primary* prim) { GWDEBUG_EXE
+ANN static inline m_bool scan1_exp_primary(const Env env, const Exp_Primary* prim) {
if(prim->primary_type == ae_primary_hack)
return scan1_exp(env, prim->d.exp);
if(prim->primary_type == ae_primary_array && prim->d.array->exp)
return GW_OK;
}
-ANN static inline m_bool scan1_exp_array(const Env env, const Exp_Array* array) { GWDEBUG_EXE
+ANN static inline m_bool scan1_exp_array(const Env env, const Exp_Array* array) {
CHECK_BB(scan1_exp(env, array->base))
return scan1_exp(env, array->array->exp);
}
-ANN static inline m_bool scan1_exp_cast(const Env env, const Exp_Cast* cast) { GWDEBUG_EXE
+ANN static inline m_bool scan1_exp_cast(const Env env, const Exp_Cast* cast) {
return scan1_exp(env, cast->exp);
}
-ANN static m_bool scan1_exp_post(const Env env, const Exp_Postfix* post) { GWDEBUG_EXE
+ANN static m_bool scan1_exp_post(const Env env, const Exp_Postfix* post) {
CHECK_BB(scan1_exp(env, post->exp))
if(post->exp->meta == ae_meta_var)
return GW_OK;
return GW_ERROR;
}
-ANN static m_bool scan1_exp_call(const Env env, const Exp_Call* exp_call) { GWDEBUG_EXE
+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))
return args ? scan1_exp(env, args) : 1;
}
-ANN static inline m_bool scan1_exp_dot(const Env env, const Exp_Dot* member) { GWDEBUG_EXE
+ANN static inline m_bool scan1_exp_dot(const Env env, const Exp_Dot* member) {
return scan1_exp(env, member->base);
}
-ANN static m_bool scan1_exp_if(const Env env, const Exp_If* exp_if) { GWDEBUG_EXE
+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))
return scan1_exp(env, exp_if->else_exp);
scan1_stmt(env, stmt->if_body) < 0 ||
(stmt->else_body && scan1_stmt(env, stmt->else_body) < 0)) ? 1 : -1)
-ANN static inline m_bool scan1_stmt_code(const Env env, const Stmt_Code stmt) { GWDEBUG_EXE
+ANN static inline m_bool scan1_stmt_code(const Env env, const Stmt_Code stmt) {
if(stmt->stmt_list) {
RET_NSPC(scan1_stmt_list(env, stmt->stmt_list))
}
return GW_OK;
}
-ANN static inline m_bool scan1_stmt_exp(const Env env, const Stmt_Exp stmt) { GWDEBUG_EXE
+ANN static inline m_bool scan1_stmt_exp(const Env env, const Stmt_Exp stmt) {
return stmt->val ? scan1_exp(env, stmt->val) : 1;
}
-ANN static inline m_bool scan1_stmt_case(const Env env, const Stmt_Exp stmt) { GWDEBUG_EXE
+ANN static inline m_bool scan1_stmt_case(const Env env, const Stmt_Exp stmt) {
return scan1_exp(env, stmt->val);
}
-ANN m_bool scan1_stmt_enum(const Env env, const Stmt_Enum stmt) { GWDEBUG_EXE
+ANN m_bool scan1_stmt_enum(const Env env, const Stmt_Enum stmt) {
if(!stmt->t)
CHECK_BB(scan0_stmt_enum(env, stmt))
ID_List list = stmt->list;
return GW_OK;
}
#include "func.h"
-ANN static m_bool scan1_args(const Env env, Arg_List list) { GWDEBUG_EXE
+ANN static m_bool scan1_args(const Env env, Arg_List list) {
do {
const Var_Decl var = list->var_decl;
if(var->xid)
return GW_OK;
}
-ANN m_bool scan1_stmt_fptr(const Env env, const Stmt_Fptr stmt) { GWDEBUG_EXE
+ANN m_bool scan1_stmt_fptr(const Env env, const Stmt_Fptr stmt) {
if(!stmt->type)
CHECK_BB(scan0_stmt_fptr(env, stmt))
CHECK_OB((stmt->base->ret_type = known_type(env, stmt->base->td)))
return stmt->base->args ? scan1_args(env, stmt->base->args) : GW_OK;
}
-ANN static inline m_bool scan1_stmt_type(const Env env, const Stmt_Type stmt) { GWDEBUG_EXE
+ANN static inline m_bool scan1_stmt_type(const Env env, const Stmt_Type stmt) {
if(!stmt->type)
CHECK_BB(scan0_stmt_type(env, stmt))
return stmt->type->def ? scan1_class_def(env, stmt->type->def) : 1;
}
-ANN m_bool scan1_stmt_union(const Env env, const Stmt_Union stmt) { GWDEBUG_EXE
+ANN m_bool scan1_stmt_union(const Env env, const Stmt_Union stmt) {
if(!stmt->value)
CHECK_BB(scan0_stmt_union(env, stmt))
Decl_List l = stmt->l;
(_exp_func)scan1_stmt_fptr, (_exp_func)scan1_stmt_type, (_exp_func)scan1_stmt_union,
};
-ANN static inline m_bool scan1_stmt(const Env env, const Stmt stmt) { GWDEBUG_EXE
+ANN static inline m_bool scan1_stmt(const Env env, const Stmt stmt) {
return stmt_func[stmt->stmt_type](env, &stmt->d);
}
-ANN static m_bool scan1_stmt_list(const Env env, Stmt_List l) { GWDEBUG_EXE
+ANN static m_bool scan1_stmt_list(const Env env, Stmt_List l) {
do {
CHECK_BB(scan1_stmt(env, l->stmt))
if(l->next) {
return GW_OK;
}
-ANN m_bool scan1_func_def(const Env env, const Func_Def fdef) { GWDEBUG_EXE
+ANN m_bool scan1_func_def(const Env env, const Func_Def fdef) {
if(fdef->base->td)
CHECK_BB(env_storage(env, fdef->flag, td_pos(fdef->base->td)))
if(tmpl_list_base(fdef->tmpl))
return GW_OK;
}
-ANN m_bool scan1_class_def(const Env env, const Class_Def cdef) { GWDEBUG_EXE
+ANN m_bool scan1_class_def(const Env env, const Class_Def cdef) {
if(!cdef->base.type)
CHECK_BB(scan0_class_def(env, cdef))
if(tmpl_class_base(cdef->tmpl))
return GW_OK;
}
-ANN m_bool scan1_ast(const Env env, Ast ast) { GWDEBUG_EXE
+ANN m_bool scan1_ast(const Env env, Ast ast) {
do CHECK_BB(scan1_section(env, ast->section))
while((ast = ast->next));
return GW_OK;
extern ANN m_bool scan1_class_def(const Env, const Class_Def);
ANN m_bool scan2_class_def(const Env, const Class_Def);
-ANN static m_bool scan2_exp_decl_template(const Env env, const Exp_Decl* decl) { GWDEBUG_EXE
+ANN static m_bool scan2_exp_decl_template(const Env env, const Exp_Decl* decl) {
CHECK_BB(template_push_types(env, decl->base->tmpl->list.list, decl->td->types));
CHECK_BB(scan1_class_def(env, decl->type->def))
CHECK_BB(scan2_class_def(env, decl->type->def))
return GW_OK;
}
-ANN m_bool scan2_exp_decl(const Env env, const Exp_Decl* decl) { GWDEBUG_EXE
+ANN m_bool scan2_exp_decl(const Env env, const Exp_Decl* decl) {
Var_Decl_List list = decl->list;
const Type type = decl->type;
if(GET_FLAG(type, template) && !GET_FLAG(type, scan2))
return var->value;
}
-ANN static m_bool scan2_args(const Env env, const Func_Def f) { GWDEBUG_EXE
+ANN static m_bool scan2_args(const Env env, const Func_Def f) {
Arg_List list = f->base->args;
do {
const Var_Decl var = list->var_decl;
return f->value_ref = v;
}
-ANN m_bool scan2_stmt_fptr(const Env env, const Stmt_Fptr ptr) { GWDEBUG_EXE
+ANN m_bool scan2_stmt_fptr(const Env env, const Stmt_Fptr ptr) {
const Func_Def def = new_func_def(env->gwion->p, new_func_base(env->gwion->p, ptr->base->td, ptr->base->xid, ptr->base->args),
NULL,ptr->base->td->flag, loc_cpy(env->gwion->p, stmt_self(ptr)->pos));
def->base->ret_type = ptr->base->ret_type;
return GW_OK;
}
-ANN static inline m_bool scan2_stmt_type(const Env env, const Stmt_Type stmt) { GWDEBUG_EXE
+ANN static inline m_bool scan2_stmt_type(const Env env, const Stmt_Type stmt) {
return stmt->type->def ? scan2_class_def(env, stmt->type->def) : 1;
}
return value;
}
-ANN static inline m_bool scan2_exp_primary(const Env env, const Exp_Primary* prim) { GWDEBUG_EXE
+ANN static inline m_bool scan2_exp_primary(const Env env, const Exp_Primary* prim) {
if(prim->primary_type == ae_primary_hack) {
CHECK_BB(scan2_exp(env, prim->d.exp))
Exp e = prim->d.exp;
return GW_OK;
}
-ANN static inline m_bool scan2_exp_array(const Env env, const Exp_Array* array) { GWDEBUG_EXE
+ANN static inline m_bool scan2_exp_array(const Env env, const Exp_Array* array) {
CHECK_BB(scan2_exp(env, array->base))
return scan2_exp(env, array->array->exp);
}
return GW_OK;
}
-ANN static inline m_bool scan2_exp_binary(const Env env, const Exp_Binary* bin) { GWDEBUG_EXE
+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))
return multi_decl(env, bin->rhs, bin->op);
}
-ANN static inline m_bool scan2_exp_cast(const Env env, const Exp_Cast* cast) { GWDEBUG_EXE
+ANN static inline m_bool scan2_exp_cast(const Env env, const Exp_Cast* cast) {
return scan2_exp(env, cast->exp);
}
-ANN static inline m_bool scan2_exp_post(const Env env, const Exp_Postfix* post) { GWDEBUG_EXE
+ANN static inline m_bool scan2_exp_post(const Env env, const Exp_Postfix* post) {
return scan2_exp(env, post->exp);
}
ANN2(1,2) static inline m_bool scan2_exp_call1(const Env env, const restrict Exp func,
- const restrict Exp args) { GWDEBUG_EXE
+ const restrict Exp args) {
CHECK_BB(scan2_exp(env, func))
return args ? scan2_exp(env, args) : 1;
}
-ANN static inline m_bool scan2_exp_call(const Env env, const Exp_Call* exp_call) { GWDEBUG_EXE
+ANN static inline m_bool scan2_exp_call(const Env env, const Exp_Call* exp_call) {
return scan2_exp_call1(env, exp_call->func, exp_call->args);
}
-ANN static inline m_bool scan2_exp_dot(const Env env, const Exp_Dot* member) { GWDEBUG_EXE
+ANN static inline m_bool scan2_exp_dot(const Env env, const Exp_Dot* member) {
return scan2_exp(env, member->base);
}
-ANN static inline m_bool scan2_exp_if(const Env env, const Exp_If* exp_if) { GWDEBUG_EXE
+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))
return scan2_exp(env, exp_if->else_exp);
scan2_stmt(env, stmt->if_body) < 0 ||
(stmt->else_body && scan2_stmt(env, stmt->else_body) < 0)) ? 1 : -1)
-ANN static inline m_bool scan2_stmt_code(const Env env, const Stmt_Code stmt) { GWDEBUG_EXE
+ANN static inline m_bool scan2_stmt_code(const Env env, const Stmt_Code stmt) {
if(stmt->stmt_list)
{ RET_NSPC(scan2_stmt_list(env, stmt->stmt_list)) }
return GW_OK;
}
-ANN static inline m_bool scan2_stmt_exp(const Env env, const Stmt_Exp stmt) { GWDEBUG_EXE
+ANN static inline m_bool scan2_stmt_exp(const Env env, const Stmt_Exp stmt) {
return stmt->val ? scan2_exp(env, stmt->val) : 1;
}
-ANN static inline m_bool scan2_stmt_case(const Env env, const Stmt_Exp stmt) { GWDEBUG_EXE
+ANN static inline m_bool scan2_stmt_case(const Env env, const Stmt_Exp stmt) {
return scan2_exp(env, stmt->val);
}
__attribute__((returns_nonnull))
-ANN static Map scan2_label_map(const Env env) { GWDEBUG_EXE
+ANN static Map scan2_label_map(const Env env) {
Map m, label = env_label(env);
const m_uint* key = env->class_def && !env->func ?
(m_uint*)env->class_def : (m_uint*)env->func;
return m;
}
-ANN static m_bool scan2_stmt_jump(const Env env, const Stmt_Jump stmt) { GWDEBUG_EXE
+ANN static m_bool scan2_stmt_jump(const Env env, const Stmt_Jump stmt) {
if(stmt->is_label) {
const Map m = scan2_label_map(env);
if(map_get(m, (vtype)stmt->name))
return GW_OK;
}
-ANN m_bool scan2_stmt_union(const Env env, const Stmt_Union stmt) { GWDEBUG_EXE
+ANN m_bool scan2_stmt_union(const Env env, const Stmt_Union stmt) {
const m_uint scope = union_push(env, stmt);
Decl_List l = stmt->l;
do CHECK_BB(scan2_exp(env, l->self))
(_exp_func)scan2_stmt_fptr, (_exp_func)scan2_stmt_type, (_exp_func)scan2_stmt_union,
};
-ANN static m_bool scan2_stmt(const Env env, const Stmt stmt) { GWDEBUG_EXE
+ANN static m_bool scan2_stmt(const Env env, const Stmt stmt) {
return stmt_func[stmt->stmt_type](env, &stmt->d);
}
-ANN static m_bool scan2_stmt_list(const Env env, Stmt_List list) { GWDEBUG_EXE
+ANN static m_bool scan2_stmt_list(const Env env, Stmt_List list) {
do CHECK_BB(scan2_stmt(env, list->stmt))
while((list = list->next));
return GW_OK;
}
-ANN static m_bool scan2_func_def_overload(const Env env, const Func_Def f, const Value overload) { GWDEBUG_EXE
+ANN static m_bool scan2_func_def_overload(const Env env, const Func_Def f, const Value overload) {
const m_bool base = tmpl_list_base(f->tmpl);
const m_bool tmpl = GET_FLAG(overload, template);
if(isa(overload->type, t_function) < 0 || isa(overload->type, t_fptr) > 0)
return v;
}
-ANN2(1, 2) static m_bool scan2_func_def_template(const Env env, const Func_Def f, const Value overload) { GWDEBUG_EXE
+ANN2(1, 2) static m_bool scan2_func_def_template(const Env env, const Func_Def f, const Value overload) {
const m_str func_name = s_name(f->base->xid);
const Func func = scan_new_func(env, f, func_name);
const Value value = func_value(env, func, overload);
return GW_OK;
}
-ANN static m_bool scan2_func_def_builtin(MemPool p, const Func func, const m_str name) { GWDEBUG_EXE
+ANN static m_bool scan2_func_def_builtin(MemPool p, const Func func, const m_str name) {
SET_FLAG(func, builtin);
func->code = new_vm_code(p, NULL, func->def->stack_depth, func->flag, name);
func->code->native_func = (m_uint)func->def->d.dl_func_ptr;
return GW_OK;
}
-ANN static m_bool scan2_func_def_op(const Env env, const Func_Def f) { GWDEBUG_EXE
+ANN static m_bool scan2_func_def_op(const Env env, const Func_Def f) {
assert(f->base->args);
const Operator op = name2op(s_name(f->base->xid));
const Type l = GET_FLAG(f, unary) ? NULL :
return GW_OK;
}
-ANN static m_bool scan2_func_def_code(const Env env, const Func_Def f) { GWDEBUG_EXE
+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))
return GW_OK;
}
-ANN static void scan2_func_def_flag(const Env env, const Func_Def f) { GWDEBUG_EXE
+ANN static void scan2_func_def_flag(const Env env, const Func_Def f) {
if(!GET_FLAG(f, builtin))
SET_FLAG(f->base->func, pure);
if(GET_FLAG(f, dtor)) {
return v;
}
-ANN m_bool scan2_func_def(const Env env, const Func_Def f) { GWDEBUG_EXE
+ANN m_bool scan2_func_def(const Env env, const Func_Def f) {
Value value = NULL;
f->stack_depth = 0;
m_uint scope = env->scope->depth;
return GW_OK;
}
-ANN m_bool scan2_class_def(const Env env, const Class_Def cdef) { GWDEBUG_EXE
+ANN m_bool scan2_class_def(const Env env, const Class_Def cdef) {
if(tmpl_class_base(cdef->tmpl))
return GW_OK;
if(cdef->base.ext)
return GW_OK;
}
-ANN m_bool scan2_ast(const Env env, Ast ast) { GWDEBUG_EXE
+ANN m_bool scan2_ast(const Env env, Ast ast) {
do CHECK_BB(scan2_section(env, ast->section))
while((ast = ast->next));
return GW_OK;
size_t pc;
};
-static INSTR(my_ret) { GWDEBUG_EXE
+static INSTR(my_ret) {
struct ret_info* info = (struct ret_info*)instr->m_val;
POP_MEM(shred, info->offset);
vector_set(shred->code->instr, shred->pc, (vtype)info->instr);