From 5bd7aaf7323475a8318855d96ee81968590e4bad Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 5 Sep 2021 23:23:48 +0200 Subject: [PATCH] :art: Add Object conditionnal --- include/instr.h | 1 + src/vm/vm_code.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/instr.h b/include/instr.h index 82bf384f..6f268351 100644 --- a/include/instr.h +++ b/include/instr.h @@ -36,6 +36,7 @@ struct Instr_ { #define BYTECODE_SZ \ ((2 * sizeof(unsigned)) + sizeof(struct Instr_) - SZ_INT * 2) +ANN void free_instr(const Gwion, const Instr); INSTR(EOC); INSTR(DTOR_EOC); INSTR(DtorReturn); diff --git a/src/vm/vm_code.c b/src/vm/vm_code.c index 48191711..1f8906b6 100644 --- a/src/vm/vm_code.c +++ b/src/vm/vm_code.c @@ -10,14 +10,18 @@ #include "operator.h" #include "import.h" +ANN void free_instr(const Gwion gwion, const Instr instr) { + const f_freearg f = (f_freearg)( + map_get(&gwion->data->freearg, instr->opcode) + ?: map_get(&gwion->data->freearg, (vtype)instr->execute)); + if (f) f(instr, gwion); + mp_free(gwion->mp, Instr, instr); +} + ANN void free_code_instr(const Vector v, const Gwion gwion) { for (m_uint i = vector_size(v) + 1; --i;) { const Instr instr = (Instr)vector_at(v, i - 1); - const f_freearg f = (f_freearg)( - map_get(&gwion->data->freearg, instr->opcode) - ?: map_get(&gwion->data->freearg, (vtype)instr->execute)); - if (f) f(instr, gwion); - mp_free(gwion->mp, Instr, instr); + free_instr(gwion, instr); } } -- 2.43.0