return GW_OK;
}
-#define scan0_nspc(env, a) \
- GET_FLAG(a, global) ? !env->class_def ? env->global_nspc : NULL : env->curr
-
#include "gack.h"
static GACK(gack_enum) {
const Map m = &t->nspc->info->value->map;
}
ANN static inline Type scan0_final(const Env env, Type_Decl *td) {
- DECL_OO(const Type, t, = known_type(env, td));
- if (!GET_FLAG(t, final)) return t;
- ERR_O(td->pos, _("can't inherit from final parent class '%s'\n."), t->name);
+ const Type t = find_type(env, td);
+ if(!t) ERR_O(td->pos, _("can't find parent class %s\n."), s_name(td->xid));
+ return t;
}
ANN static Type cdef_parent(const Env env, const Class_Def cdef) {
if (tmpl) template_push_types(env, cdef->base.tmpl);
const Type t = scan0_final(env, cdef->base.ext);
if (tmpl) nspc_pop_type(env->gwion->mp, env->curr);
- return t ?: (Type)GW_ERROR;
+ return t;
}
ANN static m_bool find_traits(const Env env, ID_List traits, const loc_t pos) {
ANN static Type scan0_class_def_init(const Env env, const Class_Def cdef) {
CHECK_BO(scan0_defined(env, cdef->base.xid, cdef->pos));
- const Type parent = cdef_parent(env, cdef);
- if (parent == (Type)GW_ERROR) return NULL;
+ DECL_OO(const Type, parent, = cdef_parent(env, cdef));
if(GET_FLAG(cdef, global) && isa(parent, env->gwion->type[et_closure]) < 0 && !type_global(env, parent)) {
gwerr_basic(_("parent type is not global"), NULL, NULL, env->name, cdef->base.ext ? cdef->base.ext->pos : cdef->base.pos, 0);
const Value v = parent->info->value;
return ret;
}
-
-
ANN Ast spread_class(const Env env, const Ast body);
+
ANN m_bool scan0_class_def(const Env env, const Class_Def c) {
CHECK_BB(scan0_global(env, c->flag, c->pos));
const Ast old_extend = env->context ? env->context->extend : NULL;
} else set_vflag(v, vflag_fglobal); // file global
} else if (GET_FLAG(decl->td, global))
SET_FLAG(v, global);
- else if(v->type != env->gwion->type[et_auto] && v->type != env->class_def) {
- type_addref(v->type);
+ else if(v->type != env->gwion->type[et_auto] && v->type != env->class_def) {
+ type_addref(v->type);
set_vflag(v, vflag_inner); // file global
}
((Exp_Decl *)decl)->type = decl->vd.value->type;
return GW_OK;
}
+ANN static inline Type scan1_final(const Env env, Type_Decl *td, const bool tdef) {
+ DECL_OO(const Type, t, = known_type(env, td));
+ if (!GET_FLAG(t, final) || tdef) return t;
+ ERR_O(td->pos, _("can't inherit from final parent class '%s'\n."), t->name);
+}
+
ANN static m_bool cdef_parent(const Env env, const Class_Def cdef) {
+ CHECK_OB((cdef->base.type->info->parent = scan1_final(env, cdef->base.ext, tflag(cdef->base.type, tflag_typedef))));
const bool tmpl = !!cdef->base.tmpl;
if (tmpl) CHECK_BB(template_push_types(env, cdef->base.tmpl));
const m_bool ret = scan1_parent(env, cdef);
if (tmpl_base(cdef->base.tmpl)) return GW_OK;
const Type t = cdef->base.type;
if (tflag(t, tflag_scan1)) return GW_OK;
- const Class_Def c = t->info->cdef;
set_tflag(t, tflag_scan1);
+ const Class_Def c = t->info->cdef;
if (c->base.ext) CHECK_BB(cdef_parent(env, c));
if (c->body) CHECK_BB(env_body(env, c, scan1_section));
return GW_OK;