def->base->func = fptr->base->func;
}
-ANN static m_bool check_tmpl_args(const Env env, const Func_Base *base) {
- ID_List id = base->tmpl->list;
- do nspc_add_type(env->curr, id->xid, env->gwion->type[et_undefined]);
- while((id = id->next));
- Arg_List arg = base->args;
- do CHECK_OB(known_type(env, arg->td))
- while((arg = arg->next));
- return GW_OK;
-}
-
-ANN static m_bool scan0_fptr_args(const Env env, const Fptr_Def fptr) {
- nspc_push_type(env->gwion->mp, env->curr);
- const m_bool ret = check_tmpl_args(env, fptr->base);
- nspc_pop_type(env->gwion->mp, env->curr);
- return ret;
-}
-
ANN m_bool scan0_fptr_def(const Env env, const Fptr_Def fptr) {
CHECK_BB(env_access(env, fptr->base->td->flag, td_pos(fptr->base->td)))
- CHECK_OB(known_type(env, fptr->base->td))
CHECK_BB(scan0_defined(env, fptr->base->xid, td_pos(fptr->base->td)));
const m_str name = s_name(fptr->base->xid);
- if(fptr->base->tmpl && fptr->base->args)
- CHECK_BB(scan0_fptr_args(env, fptr))
const Type t = scan0_type(env, env->gwion->type[et_fptr]->xid, name, env->gwion->type[et_fptr]);
t->e->owner = !(!env->class_def && GET_FLAG(fptr->base->td, global)) ?
env->curr : env->global_nspc;
return GW_OK;
}
+ANN static m_bool _scan1_fdef_base_tmpl(const Env env, Func_Base *base) {
+ ID_List id = base->tmpl->list;
+ do nspc_add_type(env->curr, id->xid, env->gwion->type[et_undefined]);
+ while((id = id->next));
+ 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))
+ while((arg = arg->next));
+ }
+ return GW_OK;
+}
+
+ANN static m_bool scan1_fdef_base_tmpl(const Env env, Func_Base *base) {
+ nspc_push_type(env->gwion->mp, env->curr);
+ const m_bool ret = _scan1_fdef_base_tmpl(env, base);
+ nspc_pop_type(env->gwion->mp, env->curr);
+ return ret;
+}
+
ANN m_bool scan1_fptr_def(const Env env, const Fptr_Def fptr) {
if(tmpl_base(fptr->base->tmpl))
- return GW_OK;
+ return scan1_fdef_base_tmpl(env, fptr->base);
if(!fptr->base->func) {
fptr->base->func = nspc_lookup_value0(env->curr, fptr->base->xid)->d.func_ref;
fptr->type = nspc_lookup_type0(env->curr, fptr->base->xid);
if(fdef->base->td)
CHECK_BB(env_storage(env, fdef->flag, td_pos(fdef->base->td)))
if(tmpl_base(fdef->base->tmpl))
- return GW_OK;
+ return scan1_fdef_base_tmpl(env, fdef->base);
struct Func_ fake = { .name=s_name(fdef->base->xid) }, *const former = env->func;
env->func = &fake;
++env->scope->depth;