From: fennecdjay Date: Sat, 18 May 2019 19:01:08 +0000 (+0200) Subject: :art: Few fixes X-Git-Tag: nightly~2454^2~4 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=d59c51da9e32e070677990c24576be435ce7ecb3;p=gwion.git :art: Few fixes --- diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 95728044..57d75ac7 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -226,8 +226,13 @@ ANN static m_bool scan0_section(const Env env, const Section* section) { ANN m_bool scan0_class_def(const Env env, const Class_Def cdef) { CHECK_BB(scan0_class_def_pre(env, cdef)) CHECK_OB((cdef->base.type = scan0_class_def_init(env, cdef))) - if(cdef->body) + if(cdef->body) { +int call = cdef->tmpl && !cdef->tmpl->base; +if(call)cdef->tmpl->base = 1; +// assert(cdef->tmpl->base); CHECK_BB(env_body(env, cdef, scan0_section)) +if(call)cdef->tmpl->base = NULL; +} (void)mk_class(env, cdef->base.type); if(GET_FLAG(cdef, global)) env->curr = (Nspc)vector_pop(&env->scope->nspc_stack); diff --git a/src/parse/scanx.c b/src/parse/scanx.c index 6d127b10..ab0e1eef 100644 --- a/src/parse/scanx.c +++ b/src/parse/scanx.c @@ -21,14 +21,19 @@ ANN static inline m_int _push(const Env env, const Class_Def c) { if(!c->tmpl->base) ERR_B(c->pos, "you must provide template types for type '%s'", s_name(c->base.xid)) - CHECK_BB(template_push_types(env, c->tmpl->list.list, c->tmpl->base)) + if(c->tmpl->base != 1) + CHECK_BB(template_push_types(env, c->tmpl->list.list, c->tmpl->base)) } return scope; } ANN static inline void _pop(const Env e, const Class_Def c, const m_uint s) { - if(c->tmpl) - nspc_pop_type(e->gwion->mp, e->curr); + if(c->tmpl) { + if(c->tmpl->base != 1) + nspc_pop_type(e->gwion->mp, e->curr); + else + c->tmpl->base = NULL; + } env_pop(e, s); } diff --git a/src/parse/template.c b/src/parse/template.c index c9e75c26..1193968c 100644 --- a/src/parse/template.c +++ b/src/parse/template.c @@ -146,6 +146,9 @@ ANN Type scan_type(const Env env, const Type t, const Type_Decl* type) { if(GET_FLAG(t, template)) { if(GET_FLAG(t, ref)) return t; + if(!type->types) + ERR_O(t->e->def->pos, + "you must provide template types for type '%s'", t->name) if(template_match(t->e->def->tmpl->list.list, type->types) < 0) ERR_O(type->xid->pos, "invalid template types number") const Class_Def a = template_class(env, t->e->def, type->types);