}
ANN m_bool not_from_owner_class(const Env env, const Type t, const Value v, const loc_t pos);
+
+ANN static inline Value get_value(const Env env, const Exp_Dot *member, const Type t) {
+ const Value value = find_value(t, member->xid);
+ if(value)
+ return value;
+ if(env->func && env->func->def->base->values)
+ return (Value)scope_lookup1(env->func->def->base->values, (m_uint)member->xid);
+ return NULL;
+}
+
OP_CHECK(opck_object_dot) {
const Exp_Dot *member = (Exp_Dot*)data;
const m_str str = s_name(member->xid);
if(member->xid == insert_symbol(env->gwion->st, "this") && base_static)
ERR_N(exp_self(member)->pos,
_("keyword 'this' must be associated with object instance..."))
- const Value value = find_value(the_base, member->xid);
+ const Value value = get_value(env, member, the_base);
if(!value) {
env_err(env, exp_self(member)->pos,
_("class '%s' has no member '%s'"), the_base->name, str);
}
}
+ANN static Type prim_owned(const Env env, const Symbol *data) {
+ const Exp exp = exp_self(prim_exp(data));
+ const Value v = exp->d.prim.value;
+ const m_str name = !GET_FLAG(v, static) ? "this" : v->from->owner_class->name;
+ const Exp base = new_prim_id(env->gwion->mp, insert_symbol(name), loc_cpy(env->gwion->mp, prim_pos(data)));
+ exp->exp_type = ae_exp_dot;
+ exp->d.exp_dot.base = base;
+ exp->d.exp_dot.xid = *data;
+ return check_exp(env, exp);
+}
+
ANN static Type prim_id_non_res(const Env env, const Symbol *data) {
const Symbol sym = *data;
const Value v = check_non_res_value(env, data);
return NULL;
}
prim_self(data)->value = v;
+ if(v->from->owner_class)
+ return prim_owned(env, data);
+ if(GET_FLAG(v, const))
+ exp_setmeta(prim_exp(data), 1);
if(env->func) {
+ if(!GET_FLAG(v, const) && v->from->owner)
+ unset_fflag(env->func, fflag_pure);
if(fbflag(env->func->def->base, fbflag_lambda))
check_upvalue(env, prim_self(data));
- if(env->func && !GET_FLAG(v, const) && v->from->owner)
- unset_fflag(env->func, fflag_pure);
}
//set_vflag(v->vflag, vflag_used);
- if(GET_FLAG(v, const))
- exp_setmeta(prim_exp(data), 1);
- if(v->from->owner_class) {
- const Exp exp = exp_self(prim_exp(data));
- const m_str name = !GET_FLAG(v, static) ? "this" : v->from->owner_class->name;
- const Exp base = new_prim_id(env->gwion->mp, insert_symbol(name), loc_cpy(env->gwion->mp, prim_pos(data)));
- exp->exp_type = ae_exp_dot;
- exp->d.exp_dot.base = base;
- exp->d.exp_dot.xid = sym;
- return check_exp(env, exp);
- }
return v->type;
}