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
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));
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);
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))
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);
}
}
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) {
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);
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);
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);
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) {