};
ANN Type tmpl_exists(const Env env, struct tmpl_info *const info);
+ANN bool tmpl_global(const Env env, Type_List tl);
#endif
#include "traverse.h"
#include "gwi.h"
-ANN bool tmpl_global(const Env env, Type_List tl);
-
ANN static bool is_base(const Env env, const Type_List tl) {
for(uint32_t i = 0; i < tl->len; i++) {
Type_Decl *td = *mp_vector_at(tl, Type_Decl*, i);
cdef->base.xid = info.name;
cdef->base.tmpl->call = cpy_type_list(env->gwion->mp, info.td->types);
+ const bool is_global = tmpl_global(env, ts->td->types);
+ const m_uint scope = is_global ? env_push_global(env) : env->scope->depth;
(void)scan0_class_def(env, cdef);
const Type t = cdef->base.type;
t->nspc->class_data_size = sizeof(struct HMapInfo);
const m_bool ret = traverse_cdef(env, t);
+ if(is_global) {
+ env_pop(env, scope);
+ type_addref(t);
+ }
HMapInfo *const hinfo = (HMapInfo*)t->nspc->class_data;
hmapinfo_init(hinfo, env->gwion->type, key, val);
if(hinfo->keyk + hinfo->valk) {
return info->ret;
}
-ANN Type tmpl_exists(const Env env, struct tmpl_info *const info);
-
-ANN bool tmpl_global(const Env env, Type_List tl) {
- for(uint32_t i = 0; i < tl->len; i++) {
- Type_Decl *td = *mp_vector_at(tl, Type_Decl*, i);
- if(!type_global(env, known_type(env, td)))
- return false;
- };
- return true;
-}
-
ANN Type scan_class(const Env env, const Type t, const Type_Decl *td) {
struct tmpl_info info = {
.base = t, .td = td, .list = t->info->cdef->base.tmpl->list};
info->name = template_id(env, info);
return _tmpl_exists(env, info->name);
}
+
+ANN bool tmpl_global(const Env env, Type_List tl) {
+ for(uint32_t i = 0; i < tl->len; i++) {
+ Type_Decl *td = *mp_vector_at(tl, Type_Decl*, i);
+ if(!type_global(env, known_type(env, td)))
+ return false;
+ }
+ return true;
+}