From d08fdf179f456563103aa205e31c6e8593b7de82 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sat, 9 May 2020 21:21:25 +0200 Subject: [PATCH] :art: Introduce class_def_cleaner --- include/clean.h | 1 + src/clean.c | 6 ++++++ src/env/type.c | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) 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); -- 2.43.0