ANN2(1, 2) Type gwi_struct_ini(const Gwi gwi, const m_str);
ANN2(1)
void gwi_class_xtor(const Gwi gwi, const f_xtor ctor, const f_xtor dtor);
+ANN void mk_dtor(MemPool p, const Type t, const f_xtor d);
ANN bool gwi_class_end(const Gwi gwi);
#define gwi_struct_end(a) gwi_class_end(a)
ANN void inherit(const Type);
#include "specialid.h"
#include "template.h"
-ANN static void mk_dtor(MemPool p, const Type t, const m_uint d) {
+ANN void mk_dtor(MemPool p, const Type t, const f_xtor d) {
VM_Code code = t->nspc->dtor = new_vmcode(p, NULL, NULL, t->name, SZ_INT, true, false);
code->native_func = (m_uint)d;
set_tflag(t, tflag_dtor);
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 (dtor) mk_dtor(gwi->gwion->mp, t, (m_uint)dtor);
+ if (dtor) mk_dtor(gwi->gwion->mp, t, dtor);
if (ctor) {
gwi_func_ini(gwi, "void", "@ctor");
gwi_func_end(gwi, ctor, ae_flag_none);
array_func(env, t, "foldl", vm_vector_foldl);
array_func(env, t, "foldr", vm_vector_foldr);
- if (tflag(base, tflag_compound)) {
- t->nspc->dtor = new_vmcode(env->gwion->mp, NULL, NULL,
- "array component dtor", SZ_INT, true, false);
- set_tflag(t, tflag_dtor);
- t->nspc->dtor->native_func = (m_uint)get_dtor(base);
- }
+ if (tflag(base, tflag_release))
+ mk_dtor(env->gwion->mp, t, get_dtor(base));
return t;
}
}
HMapInfo *const hinfo = (HMapInfo*)t->nspc->class_data;
hmapinfo_init(hinfo, key, val);
- if(tflag(key, tflag_release) || tflag(val, tflag_release)) {
- t->nspc->dtor = new_vmcode(env->gwion->mp, NULL, NULL, "@dtor", SZ_INT, true, false);
- t->nspc->dtor->native_func = (m_uint)dict_clear_dtor;
- set_tflag(t, tflag_dtor);
- }
+ if(tflag(key, tflag_release) || tflag(val, tflag_release))
+ mk_dtor(env->gwion->mp, t, dict_clear_dtor);
struct Op_Func opfunc = { .ck = opck_dict_access, .em = opem_dict_access };
struct Op_Import opi = { .lhs = key, .rhs = t, .ret = val, .op = insert_symbol("[]"), .func = &opfunc };
add_op(env->gwion, &opi);