From: fennecdjay Date: Fri, 29 Mar 2024 13:37:27 +0000 (+0100) Subject: :art: mk_dtor is now public X-Git-Tag: nightly~23 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=26f4f01387c5d4f60194525ec750b335da15e76f;p=gwion.git :art: mk_dtor is now public --- diff --git a/include/import/cdef.h b/include/import/cdef.h index 255ba710..1486f2ee 100644 --- a/include/import/cdef.h +++ b/include/import/cdef.h @@ -4,6 +4,7 @@ ANN2(1, 2) Type gwi_class_ini(const Gwi gwi, const m_str, const m_str parent); 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); diff --git a/src/import/import_cdef.c b/src/import/import_cdef.c index b7e22703..d453bf9c 100644 --- a/src/import/import_cdef.c +++ b/src/import/import_cdef.c @@ -17,7 +17,7 @@ #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); @@ -43,7 +43,7 @@ ANN2(1) void add_template(const Env env, const Type 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 (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); diff --git a/src/lib/array.c b/src/lib/array.c index 2d414251..ad81b138 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -861,12 +861,8 @@ static OP_CHECK(opck_array_scan) { 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; } diff --git a/src/lib/dict.c b/src/lib/dict.c index a0fd7dfe..3864b3e3 100644 --- a/src/lib/dict.c +++ b/src/lib/dict.c @@ -584,11 +584,8 @@ static OP_CHECK(opck_dict_scan) { } 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);