-Subproject commit 20493d2bc523d9c28f3b0ce7271bfe6c788b16ad
+Subproject commit db6a920ab506312eabe2835f41ca8b02ecec153f
func->code->memoize = memoize_ini(emit, func);
}
-ANN static m_bool emit_func_def(const Emitter emit, const Func_Def fdef) {
- const Func func = fdef->base->func;
+ANN static m_bool emit_func_def(const Emitter emit, const Func_Def f) {
+ const Func func = f->base->func;
+ const Func_Def fdef = func->def;
const Func former = emit->env->func;
if(tmpl_base(fdef->base->tmpl))
return GW_OK;
"template", dt->vt_index);
DECL_OO(const Value, v, = nspc_lookup_value0(nspc, sym))
const Func_Def def = cpy_func_def(env->gwion->mp, v->d.func_ref->def);
- def->base->tmpl->call = dt->tl;
+ def->base->tmpl->call = cpy_type_list(env->gwion->mp, dt->tl);
def->base->tmpl->base = dt->vt_index;
dt->def = def;
dt->owner = v->from->owner;
Func_Base *fbase = cpy_func_base(env->gwion->mp, base->base);
fbase->xid = sym;
fbase->tmpl->base = 0;
- fbase->tmpl->call = types;
+ fbase->tmpl->call = cpy_type_list(env->gwion->mp, types);
if(template_push_types(env, fbase->tmpl) > 0) {
const Fptr_Def fptr = new_fptr_def(env->gwion->mp, fbase, base->flag);
if(traverse_fptr_def(env, fptr) > 0 &&
}
const Func_Def fdef = (Func_Def)cpy_func_def(env->gwion->mp, value->d.func_ref->def);
SET_FLAG(fdef, template);
- fdef->base->tmpl->call = types;
+ fdef->base->tmpl->call = cpy_type_list(env->gwion->mp, types);
fdef->base->tmpl->base = i;
if((m_func = ensure_tmpl(env, fdef, exp)))
break;
return GW_OK;
}
-ANN m_bool check_func_def(const Env env, const Func_Def fdef) {
- const Func func = fdef->base->func;
+ANN m_bool check_func_def(const Env env, const Func_Def f) {
+ const Func func = f->base->func;
+ const Func_Def fdef = func->def;
assert(func == fdef->base->func);
if(env->class_def) // tmpl ?
CHECK_BB(check_parent_match(env, fdef))
}
static void fptr_def(const Env env, const Fptr_Def fptr) {
- const Func_Def def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, fptr->base->td, fptr->base->xid, fptr->base->args),
- NULL,fptr->base->td->flag, loc_cpy(env->gwion->mp, td_pos(fptr->base->td)));
+ const Func_Def def = new_func_def(env->gwion->mp,
+ cpy_func_base(env->gwion->mp, fptr->base),
+ NULL, fptr->base->td->flag, loc_cpy(env->gwion->mp, td_pos(fptr->base->td)));
fptr->base->func = new_func(env->gwion->mp, s_name(fptr->base->xid), def);
fptr->value->d.func_ref = fptr->base->func;
fptr->base->func->value_ref = fptr->value;
fptr->type->e->d.func = fptr->base->func;
- def->base->tmpl = fptr->base->tmpl;
def->base->func = fptr->base->func;
}
ANN m_bool scan1_fptr_def(const Env env, const Fptr_Def fptr) {
if(tmpl_base(fptr->base->tmpl))
return GW_OK;
- CHECK_OB((fptr->base->ret_type = known_type(env, fptr->base->td)))
- return fptr->base->args ? scan1_args(env, fptr->base->args) : GW_OK;
+ const Func_Def fdef = fptr->base->func->def;
+ CHECK_OB((fdef->base->ret_type = known_type(env, fdef->base->td)))
+ return fdef->base->args ? scan1_args(env, fdef->base->args) : GW_OK;
}
ANN m_bool scan1_type_def(const Env env, const Type_Def tdef) {
ANN m_bool scan2_fptr_def(const Env env, const Fptr_Def fptr) {
if(!tmpl_base(fptr->base->tmpl)) {
const Func_Def def = fptr->type->e->d.func->def;
- def->base->ret_type = fptr->base->ret_type;
- if(fptr->base->args)
+ if(def->base->args)
CHECK_BB(scan2_args(env, def))
- } else {
- CHECK_OB(fptr->type) // should happen before
+ } else
SET_FLAG(fptr->type, func);
- }
return GW_OK;
}
t->e->d.func = func;
return t;
}
+
ANN2(1,2) static Value func_value(const Env env, const Func f,
const Value overload) {
const Type t = func_type(env, f);
const m_bool ret = scanx_fdef(env, env, f, (_exp_func)scan2_fdef);
if(GET_FLAG(f, global))
env_pop(env, scope);
+ if(GET_FLAG(f, global) || (f->base->tmpl && !f->base->tmpl->call)) {
+ f->base->func->def = cpy_func_def(env->gwion->mp, f);
+ f->base->func->def->base->func = f->base->func;
+ }
return ret;
}