From: fennecdjay Date: Mon, 12 Feb 2024 22:54:59 +0000 (+0100) Subject: :fire: renaming X-Git-Tag: nightly~85 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=c379b061c48cfc879d06a7d9b4ba7f8c11dd9679;p=gwion.git :fire: renaming --- diff --git a/include/env/env.h b/include/env/env.h index 518560d7..27cea8ea 100644 --- a/include/env/env.h +++ b/include/env/env.h @@ -72,5 +72,5 @@ struct ScopeEffect { ANN void env_add_effect(const Env a, const Symbol effect, const loc_t); ANN void call_add_effect(const Env env, const Func func, const loc_t); -ANN bool already_defined(const Env env, const Symbol s, const loc_t); +ANN bool can_define(const Env env, const Symbol s, const loc_t); #endif diff --git a/include/env/type.h b/include/env/type.h index aa3b5857..a6e0b06b 100644 --- a/include/env/type.h +++ b/include/env/type.h @@ -67,7 +67,7 @@ ANN2(1, 2) ANEW Type new_type(MemPool, const m_str name, const Type); ANEW ANN Type type_copy(MemPool, const Type type); ANN Value find_value(const Type, const Symbol); ANN m_bool isa(const Type, const Type) __attribute__((pure)); -ANN bool isres(const Env, const Tag); // move me +ANN bool not_reserved(const Env, const Tag); // move me ANN Type array_type(const Env, const Type, const m_uint, const loc_t); ANN Type find_common_anc(const Type, const Type) __attribute__((pure)); ANN Type array_base(Type) __attribute__((pure)); diff --git a/src/env/env_utils.c b/src/env/env_utils.c index b74b53c2..f3e15c9f 100644 --- a/src/env/env_utils.c +++ b/src/env/env_utils.c @@ -65,7 +65,7 @@ ANN Type find_type(const Env env, Type_Decl *td) { return type; } -ANN bool already_defined(const Env env, const Symbol s, const loc_t loc) { +ANN bool can_define(const Env env, const Symbol s, const loc_t loc) { const Value v = nspc_lookup_value0(env->curr, s); if (!v || is_class(env->gwion, v->type)) return true; gwerr_basic(_("already declared as variable"), NULL, NULL, env->name, loc, 0); @@ -107,7 +107,7 @@ ANN Value global_string(const Env env, const m_str str, const loc_t loc) { return value; } -ANN bool isres(const Env env, const Tag tag) { +ANN bool not_reserved(const Env env, const Tag tag) { const Map map = &env->gwion->data->id; for (m_uint i = 0; i < map_size(map); i++) { if (tag.sym == (Symbol)VKEY(map, i)) diff --git a/src/parse/check.c b/src/parse/check.c index 033bffbc..4fb877fa 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -684,7 +684,7 @@ ANN static bool check_func_args(const Env env, Arg_List args) { Arg *arg = mp_vector_at(args, Arg, i); const Var_Decl *decl = &arg->var.vd; const Value v = decl->value; - if(decl->tag.sym && !already_defined(env, decl->tag.sym, decl->tag.loc)) + if(decl->tag.sym && !can_define(env, decl->tag.sym, decl->tag.loc)) ok = false; valid_value(env, decl->tag.sym, v); } diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 453ba3e3..b83b22be 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -25,14 +25,9 @@ static inline void add_type(const Env env, const Nspc nspc, const Type t) { } ANN static inline bool scan0_defined(const Env env, const Tag tag) { - if (nspc_lookup_type1(env->curr, tag.sym)) { -// ERR_B(tag.loc, _("type '%s' already defined"), s_name(tag.sym)); - env_err(env, tag.loc, _("type '%s' already defined"), s_name(tag.sym)); - return false; - } -// return already_defined(env, tag.sym, tag.loc); - int ret = already_defined(env, tag.sym, tag.loc); - return ret; + if (nspc_lookup_type1(env->curr, tag.sym)) + ERR_B(tag.loc, _("type '%s' already defined"), s_name(tag.sym)); + return can_define(env, tag.sym, tag.loc); } ANN static Arg_List fptr_arg_list(const Env env, const Fptr_Def fptr) { @@ -520,7 +515,7 @@ ANN static bool scan0_trait_def(const Env env, const Trait_Def pdef) { gwerr_basic("trait already defined", NULL, NULL, env->name, pdef->tag.loc, 0); gwerr_secondary("defined here", env->name, exists->loc); env_set_error(env, true); - return already_defined(env, s, pdef->tag.loc); + return can_define(env, s, pdef->tag.loc); } if (pdef->traits) CHECK_B(find_traits(env, pdef->traits, pdef->tag.loc)); _scan0_trait_def(env, pdef); @@ -544,7 +539,7 @@ ANN bool scan0_prim_def(const Env env, const Prim_Def pdef) { HANDLE_SECTION_FUNC(scan0, bool, Env) ANN static bool scan0_class_def_inner(const Env env, const Class_Def cdef) { - CHECK_B(isres(env, cdef->base.tag)); + CHECK_B(not_reserved(env, cdef->base.tag)); CHECK_B((cdef->base.type = scan0_class_def_init(env, cdef))); cdef->base.type->info->traits = cdef->traits; // should we copy the traits? set_tflag(cdef->base.type, tflag_scan0); diff --git a/src/parse/scan1.c b/src/parse/scan1.c index e5284d0b..812c3452 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -116,7 +116,7 @@ ANN bool abstract_array(const Env env, const Array_Sub array) { ANN static bool scan1_decl(const Env env, Exp_Decl *const decl) { const bool decl_ref = decl->var.td->array && !decl->var.td->array->exp; Var_Decl *const vd = &decl->var.vd; - CHECK_B(isres(env, vd->tag)); + CHECK_B(not_reserved(env, vd->tag)); Type t = decl->type; CHECK_B(scan1_defined(env, vd)); const Type base = array_base_simple(t); @@ -441,7 +441,7 @@ ANN static bool scan1_args(const Env env, Arg_List args) { Arg *arg = mp_vector_at(args, Arg, i); Var_Decl *const vd = &arg->var.vd; if (vd->tag.sym) { - if(!isres(env, vd->tag)) + if(!not_reserved(env, vd->tag)) ok = false; } if (arg->var.td) {