Skip to content

Commit

Permalink
🔥 move const gen func
Browse files Browse the repository at this point in the history
  • Loading branch information
fennecdjay committed Feb 7, 2024
1 parent d45895b commit 87e5f90
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
15 changes: 0 additions & 15 deletions src/parse/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -1871,21 +1871,6 @@ ANN static void fdef_const_generic_value(const Env env, const Type owner, const
v->from->owner_class = owner;
}

ANN m_bool const_generic_typecheck(const Env env, const Specialized *spec, const TmplArg *targ) {
CHECK_OB(check_exp(env, targ->d.exp));
// check implicits?
const Type target = known_type(env, spec->td);
if(isa(targ->d.exp->type, target) < 0) {
char msg[256];
tcol_snprintf(msg, 255, "expected {G+}%s{0}", target->name);
gwerr_basic("invalid type for const generic argument", msg, NULL, env->name, spec->tag.loc, 0);
tcol_snprintf(msg, 255, "got {G+}%s{0}", targ->d.exp->type->name);
gwerr_secondary(msg, env->name, targ->d.exp->loc);
return GW_ERROR;
}
return GW_OK;
}

ANN static m_bool check_fdef_const_generic(const Env env, const Func_Def fdef) {
const Tmpl *tmpl = fdef->base->tmpl;
if(tmplarg_ntypes(tmpl->call) == tmpl->call->len) return GW_OK;
Expand Down
15 changes: 15 additions & 0 deletions src/parse/template.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ else if(spec->tag.sym == targ->d.td->tag.sym) {
}
}

ANN m_bool const_generic_typecheck(const Env env, const Specialized *spec, const TmplArg *targ) {
CHECK_OB(check_exp(env, targ->d.exp));
// check implicits?
const Type target = known_type(env, spec->td);
if(isa(targ->d.exp->type, target) < 0) {
char msg[256];
tcol_snprintf(msg, 255, "expected {G+}%s{0}", target->name);
gwerr_basic("invalid type for const generic argument", msg, NULL, env->name, spec->tag.loc, 0);
tcol_snprintf(msg, 255, "got {G+}%s{0}", targ->d.exp->type->name);
gwerr_secondary(msg, env->name, targ->d.exp->loc);
return GW_ERROR;
}
return GW_OK;
}

ANN m_bool template_push_types(const Env env, const Tmpl *tmpl) {
nspc_push_type(env->gwion->mp, env->curr);
if (tmpl->call) check_call(env, tmpl);
Expand Down

0 comments on commit 87e5f90

Please sign in to comment.