From: Jérémie Astor Date: Sat, 9 May 2020 19:21:25 +0000 (+0200) Subject: :art: Introduce class_def_cleaner X-Git-Tag: nightly~1618 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=d08fdf179f456563103aa205e31c6e8593b7de82;p=gwion.git :art: Introduce class_def_cleaner --- diff --git a/include/clean.h b/include/clean.h index 5e64850e..bda9062f 100644 --- a/include/clean.h +++ b/include/clean.h @@ -2,6 +2,7 @@ #define __CLEAN void ast_cleaner(const Gwion, Ast); +void class_def_cleaner(const Gwion, Class_Def); void func_def_cleaner(const Gwion, Func_Def); #ifdef __CLEAN_IMPL typedef struct { diff --git a/src/clean.c b/src/clean.c index 19bb6d91..361bcfd1 100644 --- a/src/clean.c +++ b/src/clean.c @@ -297,6 +297,12 @@ ANN static void clean_class_def(Clean *a, Class_Def b) { clean_ast(a, b->body); } +ANN void class_def_cleaner(const Gwion gwion, Class_Def b) { + Clean a = { .gwion=gwion }; + clean_class_def(&a, b); + free_class_def(gwion->mp, b); +} + ANN static void clean_enum_def(Clean *a, Enum_Def b) { clean_id_list(a, b->list); } diff --git a/src/env/type.c b/src/env/type.c index 391bad44..3b28a68d 100644 --- a/src/env/type.c +++ b/src/env/type.c @@ -5,6 +5,7 @@ #include "traverse.h" #include "parse.h" #include "gwion.h" +#include "clean.h" ANN static inline m_bool freeable(const Type a) { return !GET_FLAG(a, nonnull) && GET_FLAG(a, template); @@ -22,7 +23,7 @@ ANN static void free_type(Type a, Gwion gwion) { a->e->def->union_def = NULL; } if(a->e->def) - free_class_def(gwion->mp, a->e->def); + class_def_cleaner(gwion, a->e->def); } if(a->nspc) REM_REF(a->nspc, gwion);