#ifndef __IMPORT_CLASS
#define __IMPORT_CLASS
ANN2(1,2) Type gwi_class_ini(const Gwi gwi, const m_str, const m_str parent);
+ANN2(1,2) Type gwi_class_spe(const Gwi gwi, const m_str, const m_uint size);
ANN2(1) void gwi_class_xtor(const Gwi gwi, const f_xtor ctor, const f_xtor dtor);
ANN m_int gwi_class_end(const Gwi gwi);
#endif
-Subproject commit d0ae737367053420e17b8494a6a1922e1196758e
+Subproject commit a2fd43e0ce60fec336694a2a6be0a90d09cfc072
env_push_type(env, t);
}
-
ANN2(1) void gwi_class_xtor(const Gwi gwi, const f_xtor ctor, const f_xtor dtor) {
const Type t = gwi->gwion->env->class_def;
if(ctor)
mk_xtor(gwi->gwion->mp, t, (m_uint)dtor, ae_flag_dtor);
}
+ANN static Type type_finish(const Gwi gwi, const Type t) {
+ SET_FLAG(t, scan1 | ae_flag_scan2 | ae_flag_check | ae_flag_emit);
+ gwi_add_type(gwi, t);
+ import_class_ini(gwi->gwion->env, t);
+ return t;
+}
+
ANN2(1,2) Type gwi_class_ini(const Gwi gwi, const m_str name, const m_str parent) {
struct ImportCK ck = { .name=name };
CHECK_BO(check_typename_def(gwi, &ck))
const Type p = known_type(gwi->gwion->env, td); // check
if(tmpl)
nspc_pop_type(gwi->gwion->mp, gwi->gwion->env->curr);
- const Type t = new_type(gwi->gwion->mp, gwi->gwion->env->scope->type_xid, s_name(ck.sym), p);
+ const Type t = new_type(gwi->gwion->mp, ++gwi->gwion->env->scope->type_xid, s_name(ck.sym), p);
t->e->def = new_class_def(gwi->gwion->mp, 0, ck.sym, td, NULL, loc(gwi));
t->e->def->base.tmpl = tmpl;
t->e->def->base.type = t;
SET_FLAG(t, typedef);
if(ck.tmpl)
SET_FLAG(t, template);
- else
- SET_FLAG(t, scan1 | ae_flag_scan2 | ae_flag_check | ae_flag_emit);
- gwi_add_type(gwi, t);
- import_class_ini(gwi->gwion->env, t);
- return t;
+ return type_finish(gwi, t);
+}
+
+ANN Type gwi_class_spe(const Gwi gwi, const m_str name, const m_uint size) {
+ CHECK_OO(str2sym(gwi, name))
+ const Type t = new_type(gwi->gwion->mp, ++gwi->gwion->env->scope->type_xid, name, NULL);
+ t->size = size;
+ return type_finish(gwi, t);
}
ANN m_int gwi_class_end(const Gwi gwi) {
GWION_IMPORT(complex) {
// should be special
- const Type t_complex = gwi_class_ini(gwi, "complex", NULL);
- t_complex->e->parent = NULL;
+ const Type t_complex = gwi_class_spe(gwi, "complex", SZ_COMPLEX);
GWI_BB(gwi_gack(gwi, t_complex, gack_complex))
gwi->gwion->type[et_complex] = t_complex; // use func
gwi_item_ini(gwi, "float", "re");
GWI_BB(gwi_item_end(gwi, ae_flag_member, NULL))
GWI_BB(gwi_class_end(gwi))
// should be special
- const Type t_polar = gwi_class_ini(gwi, "polar", NULL);
- t_polar->e->parent = NULL;
+ const Type t_polar = gwi_class_spe(gwi, "polar", SZ_COMPLEX);
gwi->gwion->type[et_polar] = t_polar;
GWI_BB(gwi_gack(gwi, t_polar, gack_polar))
GWI_BB(gwi_item_ini(gwi, "float", "mod"))
}
GWION_IMPORT(vec3) {
- const Type t_vec3 = gwi_class_ini(gwi, "Vec3", NULL);
-t_vec3->size = SZ_VEC3;
-t_vec3->e->parent = NULL;
+ const Type t_vec3 = gwi_class_spe(gwi, "Vec3", SZ_VEC3);
gwi->gwion->type[et_vec3] = t_vec3;
GWI_BB(gwi_gack(gwi, t_vec3, gack_vec3))
vecx_base(gwi);
}
GWION_IMPORT(vec4) {
-// should be special (gwi, "Vec4", SZ_VEC4)
- const Type t_vec4 = gwi_class_ini(gwi, "Vec4", NULL);
-t_vec4->size = SZ_VEC4;
-t_vec4->e->parent = NULL;
+ const Type t_vec4 = gwi_class_spe(gwi, "Vec4", SZ_VEC4);
gwi->gwion->type[et_vec4] = t_vec4;
GWI_BB(gwi_gack(gwi, t_vec4, gack_vec4))
vecx_base(gwi);