if(!decl->type)
ERR_O(td_pos(decl->td), _("can't infer type."));
if(GET_FLAG(decl->type , template) && !GET_FLAG(decl->type, check))
- CHECK_BO(traverse_cdef(env, decl->type->e->def))
+ CHECK_BO(check_cdef(env, decl->type->e->def))
const m_bool global = GET_FLAG(decl->td, global);
const m_uint scope = !global ? env->scope->depth : env_push_global(env);
do {
const Type_Decl *td = cdef->base.ext;
if(td->array)
CHECK_BB(check_exp_array_subscripts(env, td->array->exp))
- if(parent->e->def && (!GET_FLAG(parent, check) || GET_FLAG(parent, template)))
+ if(parent->e->def && !GET_FLAG(parent, check))
CHECK_BB(scanx_parent(parent, traverse_cdef, env))
if(GET_FLAG(parent, typedef))
SET_FLAG(cdef->base.type, typedef);
udef->value->owner = nspc;
nspc_add_value(nspc, udef->xid, udef->value);
add_type(env, nspc, t);
+ SET_FLAG(t, scan1);
SET_FLAG(udef->value, checked | udef->flag);
if(env->class_def && !GET_FLAG(udef, static)) {
SET_FLAG(udef->value, member);
env->curr : env->global_nspc;
udef->type = union_type(env, nspc, udef->type_xid, 1);
SET_FLAG(udef->type, checked);
+ SET_FLAG(udef->type, scan1);
} else {
const Nspc nspc = !GET_FLAG(udef, global) ?
env->curr : env->global_nspc;
sprintf(c, "%p", udef);
nspc_add_type(nspc, insert_symbol(c), t);
SET_FLAG(udef->value, checked | udef->flag);
+ SET_FLAG(t, scan1);
}
if(udef->tmpl) {
if(tmpl_base(udef->tmpl)) {
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) */&&
- (!env->class_def || !(GET_FLAG(env->class_def, template) || GET_FLAG(env->class_def, scan1))))
+ if(former)
ERR_B(var->pos, _("variable %s has already been defined in the same scope..."),
s_name(var->xid))
if(var->array) {
}
t = array_type(env, decl->type, var->array->depth);
}
- const Value v = var->value = former ?: new_value(env->gwion->mp, t, s_name(var->xid));
+ assert(!var->value);
+ const Value v = var->value = new_value(env->gwion->mp, t, s_name(var->xid));
nspc_add_value(nspc, var->xid, v);
v->flag = decl->td->flag;
if(var->array && !var->array->exp)
SET_FLAG(v, ref);
if(!env->scope->depth && !env->class_def)
SET_FLAG(v, global);
- v->type = t;
v->d.ptr = var->addr;
v->owner = !env->func ? env->curr : NULL;
v->owner_class = env->scope->depth ? NULL : env->class_def;
SET_FLAG(decl.td, global);
} while((l = l->next));
union_pop(env, udef, scope);
+ SET_FLAG(udef, scan1);
return GW_OK;
}
} while((t = t->e->parent));
if(isa(parent, t_object) < 0)
ERR_B(pos, _("cannot extend primitive type '%s'"), parent->name)
- if(parent->e->def && (!GET_FLAG(parent, scan1) || GET_FLAG(parent, template)))
+ if(parent->e->def && !GET_FLAG(parent, scan1))
CHECK_BB(scanx_parent(parent, scan1_cdef, env))
if(type_ref(parent))
ERR_B(pos, _("can't use ref type in class extend"))
CHECK_BB(env_ext(env, cdef, scan1_parent))
if(cdef->body)
CHECK_BB(env_body(env, cdef, scan1_section))
+ SET_FLAG(cdef, scan1);
return GW_OK;
}
ANN static m_bool scan2_stmt(const Env, const Stmt);
ANN static m_bool scan2_stmt_list(const Env, Stmt_List);
-ANN static m_bool scan2_exp_decl_template(const Env env, const Exp_Decl* decl) {
- CHECK_BB(scan1_cdef(env, decl->type->e->def))
- return scan2_cdef(env, decl->type->e->def);
-}
-
ANN m_bool scan2_exp_decl(const Env env, const Exp_Decl* decl) {
const m_bool global = GET_FLAG(decl->td, global);
const m_uint scope = !global ? env->scope->depth : env_push_global(env);
const Type type = decl->type;
if(GET_FLAG(type, template) && !GET_FLAG(type, scan2))
- CHECK_BB(scan2_exp_decl_template(env, decl))
+ CHECK_BB(scan2_cdef(env, decl->type->e->def))
Var_Decl_List list = decl->list;
do {
const Var_Decl var = list->self;
ANN static m_bool scan2_class_parent(const Env env, const Class_Def cdef) {
const Type parent = cdef->base.type->e->parent;
- if(parent->e->def && (!GET_FLAG(parent, scan2) || GET_FLAG(parent, template)))
+ if(parent->e->def && !GET_FLAG(parent, scan2))
CHECK_BB(scanx_parent(parent, scan2_cdef, env))
if(cdef->base.ext->array)
CHECK_BB(scan2_exp(env, cdef->base.ext->array->exp))
ANN m_bool traverse_func_def(const Env env, const Func_Def def) {
const Func former = env->func;
- if(scan1_func_def(env, def) > 0 && scan2_func_def(env, def) > 0 &&
- check_func_def(env, def) > 0)
+ if(scan1_func_def(env, def) > 0 &&
+ scan2_func_def(env, def) > 0 &&
+ check_func_def(env, def) > 0)
return GW_OK;
env->func = former;
return GW_ERROR;
}
ANN m_bool traverse_union_def(const Env env, const Union_Def def) {
- CHECK_BB(scan1_union_def(env, def))
+ if(!GET_FLAG(def, scan1))
+ CHECK_BB(scan1_union_def(env, def))
CHECK_BB(scan2_union_def(env, def))
return check_union_def(env, def);
}
ANN m_bool traverse_enum_def(const Env env, const Enum_Def def) {
CHECK_BB(scan0_enum_def(env, def))
CHECK_BB(scan1_enum_def(env, def))
-// CHECK_BBscan2_enum_def(env, def))
+// CHECK_BB(scan2_enum_def(env, def))
return check_enum_def(env, def);
}
}
ANN m_bool traverse_class_def(const Env env, const Class_Def def) {
- CHECK_BB(scan1_class_def(env, def))
+ if(!GET_FLAG(def, scan1))
+ CHECK_BB(scan1_class_def(env, def))
CHECK_BB(scan2_class_def(env, def))
return check_class_def(env, def);
}