CHECK_BB(isres(env, var->xid, exp_self(decl)->pos))
Type t = decl->type;
const Value former = nspc_lookup_value0(env->curr, var->xid);
- if(former && !(decl->td->exp || decl->td->xid)&&
+ if(former /* && !(decl->td->exp || decl->td->xid) */&&
(!env->class_def || !(GET_FLAG(env->class_def, template) || GET_FLAG(env->class_def, scan1))))
ERR_B(var->pos, _("variable %s has already been defined in the same scope..."),
s_name(var->xid))
GwText text;
};
-ANEW ANN static m_str td2str(const Env env, const Type_Decl* td);
ANN static m_bool td_info_run(const Env env, struct td_info* info) {
Type_List tl = info->tl;
do {
- DECL_OB(m_str, name, = td2str(env, tl->td))
- text_add(&info->text, name);
- free_mstr(env->gwion->mp, name);
+ DECL_OB(const Type, t, = known_type(env, tl->td))
+ text_add(&info->text, t->name);
if(tl->next)
text_add(&info->text, ",");
} while((tl = tl->next));
return GW_OK;
}
-ANN static ssize_t id_list_len2(const Nspc nspc, ID_List l) {
- ssize_t len = 0;
- do {
- DECL_OB(const Type, t, = nspc_lookup_type1(nspc, l->xid))
- len += strlen(t->name);
- } while((l = l->next) && ++len);
- return len + 1;
-}
-
-ANN static void type_path2(const Nspc nspc, const m_str str, ID_List l) {
- m_str s = str;
- do {
- const Type t = nspc_lookup_type1(nspc, l->xid);
- const m_str name = t->name;
- strcpy(s, name);
- s += strlen(name);
- if(l->next)
- strcpy(s++, ".");
- }
- while((l = l->next));
-}
-
-ANEW ANN static m_str td2str(const Env env, const Type_Decl* td) {
- m_uint depth = td->array ? td->array->depth : 0;
- DECL_BO(const ssize_t, len, = id_list_len2(env->curr, td->xid) + depth * 2);
- const size_t cap = round2szint(len);
- struct td_info info = { td->types,
- { (m_str)mp_malloc2(env->gwion->mp, cap), cap, len, env->gwion->mp }
- };
- type_path2(env->curr, info.text.str, td->xid);
- while(depth--) { text_add(&info.text, "[]"); }
- Type_List tl = td->types;
- if(tl) {
- text_add(&info.text, "<");
- CHECK_BO(td_info_run(env, &info))
- text_add(&info.text, ">");
- }
- return info.text.str;
-}
-
ANEW ANN m_str tl2str(const Env env, Type_List tl) {
struct td_info info = { .tl=tl, { .mp=env->gwion->mp} };
CHECK_BO(td_info_run(env, &info))