From 4019ff1e9c258d34d298ec36777114040826bd19 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Mon, 1 Apr 2019 10:40:38 +0200 Subject: [PATCH] :art: Simplifications --- ast | 2 +- src/lib/import.c | 2 +- src/parse/scan0.c | 12 ++++++------ src/parse/template.c | 14 +++++--------- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/ast b/ast index d1459fb3..e04d8382 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit d1459fb3a76e2a75731ab77055ae57dbabfe3cd7 +Subproject commit e04d8382825ddf63f52b834dee13d8b85902fb21 diff --git a/src/lib/import.c b/src/lib/import.c index 4ae707d9..662c263d 100644 --- a/src/lib/import.c +++ b/src/lib/import.c @@ -209,7 +209,7 @@ ANN2(1,2) m_int gwi_class_ini(const Gwi gwi, const Type type, const f_xtor pre_c ERR_B(0, "during import: class '%s' already imported.", type->name) if(gwi->templater.n) { const ID_List types = templater_def(&gwi->templater); - type->def = new_class_def(0, new_id_list(insert_symbol(type->name), 0), NULL, NULL); + type->def = new_class_def(0, insert_symbol(type->name), NULL, NULL); type->def->tmpl = new_tmpl_class(types, -1); type->def->type = type; SET_FLAG(type, template); diff --git a/src/parse/scan0.c b/src/parse/scan0.c index cdd2d870..a90f5460 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -59,8 +59,7 @@ ANN static m_bool scan0_stmt_type(const Env env, const Stmt_Type stmt) { GWDEBUG SET_FLAG(t, empty); } else { const ae_flag flag = base->def ? base->def->flag : 0; - const Class_Def def = new_class_def(flag, new_id_list(stmt->xid, stmt->td->xid->pos), - stmt->td, NULL); + const Class_Def def = new_class_def(flag, stmt->xid, stmt->td, NULL); CHECK_BB(scan0_class_def(env, def)) stmt->type = def->type; } @@ -156,20 +155,21 @@ ANN static m_bool scan0_class_def_pre(const Env env, const Class_Def class_def) vector_add(&env->scope->nspc_stack, (vtype)env->curr); env->curr = env->global_nspc; } - CHECK_BB(scan0_defined(env, class_def->name->xid, class_def->name->pos)) // test for type ? - CHECK_BB(isres(class_def->name->xid)) +// CHECK_BB(scan0_defined(env, class_def->xid, class_def->name->pos)) // test for type ? + CHECK_BB(scan0_defined(env, class_def->xid, 0)) // test for type ? + CHECK_BB(isres(class_def->xid)) return GW_OK; } ANN static Type scan0_class_def_init(const Env env, const Class_Def class_def) { GWDEBUG_EXE - const Type t = new_type(++env->scope->type_xid, s_name(class_def->name->xid), t_object); + const Type t = new_type(++env->scope->type_xid, s_name(class_def->xid), t_object); t->owner = env->curr; t->nspc = new_nspc(t->name); t->nspc->parent = GET_FLAG(class_def, global) ? env_nspc(env) : env->curr; t->def = class_def; t->flag = class_def->flag; if(!strstr(t->name, "<")) - nspc_add_type(env->curr, class_def->name->xid, t); + nspc_add_type(env->curr, class_def->xid, t); if(class_def->tmpl) { SET_FLAG(t, template); SET_FLAG(class_def, template); diff --git a/src/parse/template.c b/src/parse/template.c index 4419968f..44908a69 100644 --- a/src/parse/template.c +++ b/src/parse/template.c @@ -92,7 +92,7 @@ ANN static void template_name(const Env env, struct tmpl_info* info, m_str s) { *str = '\0'; } -ANEW ANN static ID_List template_id(const Env env, const Class_Def c, const Type_List call) { +ANEW ANN static Symbol template_id(const Env env, const Class_Def c, const Type_List call) { struct tmpl_info info = { .cdef=c, .call=call }; vector_init(&info.type); vector_init(&info.size); @@ -100,7 +100,7 @@ ANEW ANN static ID_List template_id(const Env env, const Class_Def c, const Type template_name(env, &info, name); vector_release(&info.type); vector_release(&info.size); - return new_id_list(insert_symbol(name), call->td->xid->pos); + return insert_symbol(name); } ANN m_bool template_match(ID_List base, Type_List call) { @@ -109,13 +109,9 @@ ANN m_bool template_match(ID_List base, Type_List call) { } ANN static Class_Def template_class(const Env env, const Class_Def def, const Type_List call) { - const ID_List name = template_id(env, def, call); - const Type t = nspc_lookup_type1(env->curr, name->xid); - if(t) { - free_id_list(name); - return t->def; - } - return new_class_def(def->flag, name, def->ext, def->body); + const Symbol name = template_id(env, def, call); + const Type t = nspc_lookup_type1(env->curr, name); + return t ? t->def : new_class_def(def->flag, name, def->ext, def->body); } ANN m_bool template_push_types(const Env env, ID_List base, Type_List tl) { -- 2.43.0