-Subproject commit 94e10dede128475686da71e1f35b5a89b88073fd
+Subproject commit c902b1888ae8aadcb2cdf6000308e0d55043b8ed
ANN static m_bool emit_exp_call_template(const Emitter emit, const Exp_Call* exp_call) {
if(emit->env->func && emit->env->func == exp_call->m_func)
return prepare_call(emit, exp_call);
- const m_int scope = push_tmpl_func(emit, exp_call->m_func, exp_call->tmpl->types);
+ const m_int scope = push_tmpl_func(emit, exp_call->m_func, exp_call->tmpl->call);
CHECK_BB(scope);
CHECK_BB(prepare_call(emit, exp_call))
emit_pop_type(emit);
const Func former = emit->env->func;
if(func->code)
return GW_OK;
- if(tmpl_list_base(func_def->tmpl)) {
+ if(tmpl_base(func_def->tmpl)) {
UNSET_FLAG(func_def, template);
return GW_OK;
}
ANN static m_bool emit_class_def(const Emitter emit, const Class_Def cdef) {
const Type type = cdef->base.type;
const Nspc nspc = type->nspc;
- if(tmpl_list_base(cdef->tmpl))
+ if(tmpl_base(cdef->tmpl))
return GW_OK;
if(cdef->base.ext && ((/*!GET_FLAG(type->e->parent, emit) &&*/
GET_FLAG(cdef->base.ext, typedef)) || cdef->base.ext->types)) {
if(gwi->templater.n) {
const ID_List types = templater_def(gwi->gwion->st, gwi);
type->e->def = new_class_def(gwi->gwion->mp, 0, insert_symbol(gwi->gwion->st, type->name), NULL, NULL, loc_cpy(gwi->gwion->mp, gwi->loc));
- type->e->def->tmpl = new_tmpl_list(gwi->gwion->mp, types, -1);
+ type->e->def->tmpl = new_tmpl(gwi->gwion->mp, types, -1);
type->e->def->base.type = type;
SET_FLAG(type, template);
} else
if(gwi->templater.n) {
def = new_func_def(gwi->gwion->mp, new_func_base(gwi->gwion->mp, NULL, NULL, NULL), NULL, 0, loc_cpy(gwi->gwion->mp, gwi->loc));
const ID_List list = templater_def(gwi->gwion->st, gwi);
- def->tmpl = new_tmpl_list(gwi->gwion->mp, list, -1);
+ def->tmpl = new_tmpl(gwi->gwion->mp, list, -1);
SET_FLAG(def, template);
}
if(gwi->gwion->env->class_def && GET_FLAG(gwi->gwion->env->class_def, template)) {
const Func_Def base = v->d.func_ref->def;
const Func_Def def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, base->base->td, insert_symbol(env->gwion->st, v->name),
base->base->args), base->d.code, base->flag, loc_cpy(env->gwion->mp, base->pos));
- def->tmpl = new_tmpl_list(env->gwion->mp, base->tmpl->list, dt->overload);
+ def->tmpl = new_tmpl(env->gwion->mp, base->tmpl->list, dt->overload);
SET_FLAG(def, template);
return def;
}
ANN static Func _find_template_match(const Env env, const Value v, const Exp_Call* exp) {
const Exp args = exp->args;
- const Type_List types = exp->tmpl->types;
+ const Type_List types = exp->tmpl->call;
Func m_func = exp->m_func, former = env->func;
if(types->td->types)exit(12);
const m_str tmpl_name = tl2str(env, types);
if(!(value = template_get_ready(env, v, "template", i)))
continue;
base = value->d.func_ref->def;
- def->tmpl = new_tmpl_list(env->gwion->mp, base->tmpl->list, (m_int)i);
+ def->tmpl = new_tmpl(env->gwion->mp, base->tmpl->list, (m_int)i);
}
} else {
if(!(value = template_get_ready(env, v, "template", i)))
base = value->d.func_ref->def;
def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, base->base->td, insert_symbol(v->name),
base->base->args), base->d.code, base->flag, loc_cpy(env->gwion->mp, base->pos));
- def->tmpl = new_tmpl_list(env->gwion->mp, base->tmpl->list, (m_int)i);
+ def->tmpl = new_tmpl(env->gwion->mp, base->tmpl->list, (m_int)i);
SET_FLAG(def, template);
}
if(traverse_func_template(env, def, types) > 0) {
ANN static Func get_template_func(const Env env, const Exp_Call* func, const Value v) {
const Func f = find_template_match(env, v, func);
if(f) {
- Tmpl_Call* tmpl = new_tmpl_call(env->gwion->mp, func->tmpl->types);
- tmpl->base = v->d.func_ref->def->tmpl->list;
+ Tmpl* tmpl = new_tmpl_call(env->gwion->mp, func->tmpl->call);
+ tmpl->list = v->d.func_ref->def->tmpl->list;
((Exp_Call*)func)->tmpl = tmpl;
return ((Exp_Call*)func)->m_func = f;
}
}
if(args_number < type_number)
ERR_O(call->pos, "not able to guess types for template call.")
- Tmpl_Call tmpl = { .types=tl[0] };
+ Tmpl tmpl = { .call=tl[0] };
((Exp_Call*)exp)->tmpl = &tmpl;
const Func func = get_template_func(env, exp, value);
return func ? func->def->base->ret_type : NULL;
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))
+ if(tmpl_base(f->tmpl))
return env->class_def ? check_parent_match(env, f) : 1;
if(f->base->td && !f->base->td->xid) {
f->base->ret_type = check_td(env, f->base->td);
}
ANN m_bool check_class_def(const Env env, const Class_Def cdef) {
- if(tmpl_list_base(cdef->tmpl))
+ if(tmpl_base(cdef->tmpl))
return GW_OK;
const Type type = cdef->base.type;
if(type->e->parent == t_undefined) {
ANN static void free_func(Func a, Gwion gwion) {
if(GET_FLAG(a, template)) {
- free_tmpl_list(gwion->mp, a->def->tmpl);
+ free_tmpl(gwion->mp, a->def->tmpl);
free_func_base(gwion->mp, a->def->base);
free_loc(gwion->mp, a->def->pos);
mp_free(gwion->mp, Func_Def, a->def);
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))
+ if(tmpl_base(fdef->tmpl))
return GW_OK;
struct Func_ fake = { .name=s_name(fdef->base->xid) }, *const former = env->func;
env->func = &fake;
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_list_base(cdef->tmpl))
+ if(tmpl_base(cdef->tmpl))
return GW_OK;
if(cdef->base.ext)
CHECK_BB(scan1_class_parent(env, cdef))
}
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 base = tmpl_base(f->tmpl);
const m_bool tmpl = GET_FLAG(overload, template);
if(isa(overload->type, t_function) < 0 || isa(overload->type, t_fptr) > 0)
ERR_B(f->pos, "function name '%s' is already used by another value", overload->name)
ERR_B(f->pos, "'%s' already declared as type", func_name)
if(overload)
CHECK_BB(scan2_func_def_overload(env, f, overload))
- if(tmpl_list_base(f->tmpl))
+ if(tmpl_base(f->tmpl))
return scan2_func_def_template(env, f, overload);
if(!f->tmpl) {
const Symbol sym = func_symbol(env, env->curr->name, func_name, NULL, overload ? ++overload->offset : 0);
}
ANN m_bool scan2_class_def(const Env env, const Class_Def cdef) {
- if(tmpl_list_base(cdef->tmpl))
+ if(tmpl_base(cdef->tmpl))
return GW_OK;
if(cdef->base.ext)
CHECK_BB(scan2_class_parent(env, cdef))
SET_FLAG(a, ref);
if(a->base.type)
return a->base.type;
- a->tmpl = new_tmpl_list(env->gwion->mp, get_total_type_list(env, t), 0);
+ a->tmpl = new_tmpl(env->gwion->mp, get_total_type_list(env, t), 0);
a->tmpl->call = type->types;
CHECK_BO(scan0_class_def(env, a))