From: Jérémie Astor Date: Sun, 5 Sep 2021 21:23:48 +0000 (+0200) Subject: :art: Add Object conditionnal X-Git-Tag: nightly~470^2~8 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=5bd7aaf7323475a8318855d96ee81968590e4bad;p=gwion.git :art: Add Object conditionnal --- 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); } }