}
ANN void env_add_type(const Env env, const Type type) {
- const Type v_type = type_copy(env->gwion->mp, env->gwion->type[et_class]);
- type_addref(v_type);
- v_type->e->d.base_type = type;
+ type->e->owner = env->curr;
+ type->e->owner_class = env->class_def; // t owner_class ?
const Symbol sym = insert_symbol(type->name);
nspc_add_type_front(env->curr, sym, type);
- const Value v = new_value(env->gwion->mp, v_type, s_name(sym));
- SET_FLAG(v, const | ae_flag_global);
- set_vflag(v, vflag_valid | vflag_builtin);
- nspc_add_value(env->curr, insert_symbol(type->name), v);
- v->from->owner = type->e->owner = env->curr;
- v->from->owner_class = type->e->owner_class = env->class_def; // t owner_class ?
+ const Value v = mk_class(env, type);
+ SET_FLAG(v, global);
+ set_vflag(v, vflag_builtin);
+ set_tflag(type, tflag_scan0 | tflag_scan1 | tflag_scan2 | tflag_check | tflag_emit);
type->xid = ++env->scope->type_xid;
}
ANN Type str2type(const Gwion gwion, const m_str str, const loc_t pos) {
DECL_OO(Type_Decl *, td, = str2decl(gwion, str, pos))
const Type t = known_type(gwion->env, td);
- if(t)
- return t;
free_type_decl(gwion->mp, td);
- return NULL;
+ return t;
}
ANN static inline m_bool ac_finish(const Gwion gwion, const struct AC *ac) {
gwi->ck->tmpl = NULL;
const m_bool ret = traverse_type_def(gwi->gwion->env, tdef);
const Type t = tdef->type;
+ set_tflag(t, tflag_scan0 | tflag_scan1 | tflag_scan2 | tflag_check | tflag_emit);
free_type_def(gwi->gwion->mp, tdef);
ck_end(gwi);
return ret > 0 ? t : NULL;
set_tflag(t_class, tflag_infer);
GWI_BB(gwi_set_global_type(gwi, t_class, et_class))
GWI_BB(gwi_gack(gwi, t_class, gack_class)) // not working yet
- GWI_BB(gwi_add_type(gwi, t_class))
GWI_BB(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, (m_str)OP_ANY_TYPE, NULL))
GWI_BB(gwi_oper_add(gwi, opck_object_dot))
GWI_BB(gwi_oper_emi(gwi, opem_object_dot))
GWI_BB(gwi_func_end(gwi, shred_now, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
SET_FLAG(t_shred, abstract | ae_flag_final);
- gwi_set_global_type(gwi, t_shred, et_shred);
+ gwi->gwion->type[et_shred] = t_shred;
struct SpecialId_ spid = { .type=t_shred, .exec=RegPushMe, .is_const=1 };
gwi_specialid(gwi, "me", &spid);
GWION_IMPORT(string) {
const Type t_string = gwi_class_ini(gwi, "string", NULL);
+ gwi->gwion->type[et_string] = t_string; // use func
gwi_class_xtor(gwi, string_ctor, NULL);
GWI_BB(gwi_gack(gwi, t_string, gack_string))
- gwi->gwion->type[et_string] = t_string; // use func
gwi_item_ini(gwi, "@internal", "@data");
GWI_BB(gwi_item_end(gwi, ae_flag_const, NULL))
GWI_BB(gwi_func_end(gwi, mfun_vararg_cpy, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
SET_FLAG(t_vararg, abstract | ae_flag_final);
- GWI_BB(gwi_set_global_type(gwi, t_vararg, et_vararg))
+ gwi->gwion->type[et_vararg] = t_vararg;
GWI_BB(gwi_oper_ini(gwi, "nonnull Vararg", (m_str)OP_ANY_TYPE, NULL))
GWI_BB(gwi_oper_add(gwi, opck_vararg_cast))
GWI_BB(gwi_oper_emi(gwi, opem_vararg_cast))