return emit_vararg(emit, member);
}
-ANN static m_bool emit_member_func(const Emitter emit, const Exp_Dot* member, const Func func) {
+ANN static m_bool emit_member_func(const Emitter emit, const Exp_Dot* member) {
+ const Func f = exp_self(member)->type->e->d.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);
+ const Instr func_i = emit_add_instr(emit, f->code ? RegPushImm : PushStaticCode);
+ func_i->m_val = (m_uint)(f->code ?: (VM_Code)f);
return GW_OK;
}
- if(func->def->base->tmpl)
+ if(f->def->base->tmpl)
emit_add_instr(emit, DotTmplVal);
else {
- const Instr instr = emit_add_instr(emit, GET_FLAG(func, member) ? DotFunc : DotStaticFunc);
- instr->m_val = exp_self(member)->type->e->d.func->vt_index;
+ const Instr instr = emit_add_instr(emit, GET_FLAG(f, member) ? DotFunc : DotStaticFunc);
+ instr->m_val = f->vt_index;
}
return GW_OK;
}
emit_add_instr(emit, GWOP_EXCEPT);
}
if(isa(exp_self(member)->type, t_function) > 0 && isa(exp_self(member)->type, t_fptr) < 0)
- return emit_member_func(emit, member, value->d.func_ref);
+ return emit_member_func(emit, member);
return (GET_FLAG(value, member) ? emit_member : emit_dot_static_import_data) (emit, value, exp_self(member)->emit_var);
}
while((e = e->next) && gw_err(","));
}
-ANN2(1) static void* function_alternative(const Env env, const Type f, const Exp args, const loc_t pos){
+ANN2(1) static void function_alternative(const Env env, const Type f, const Exp args, const loc_t pos){
env_err(env, pos, _("argument type(s) do not match for function. should be :"));
Func up = f->e->d.func;
do {
gw_err("\n");
} while((up = up->next));
args ? print_current_args(args) : (void)gw_err(_("and not:\n \033[32mvoid\033[0m\n"));
- return NULL;
}
ANN static m_uint get_type_number(ID_List list) {
if(GET_FLAG(exp->func->type, func))
return check_exp_call_template(env, (Exp_Call*)exp);
const Func func = find_func_match(env, exp->func->type->e->d.func, exp->args);
- return (exp_self(exp)->d.exp_call.m_func = func) ?
- func->def->base->ret_type : function_alternative(env, exp->func->type, exp->args, exp_self(exp)->pos);
+ if((exp_self(exp)->d.exp_call.m_func = func)) {
+ exp->func->type = func->value_ref->type;
+ return func->def->base->ret_type;
+ }
+ function_alternative(env, exp->func->type, exp->args, exp_self(exp)->pos);
+ return GW_ERROR;
}
ANN static Type check_exp_binary(const Env env, const Exp_Binary* bin) {