From a2d6bc15d9446e0b4b85273d4f68e16c060a81a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sat, 30 Nov 2019 22:09:55 +0100 Subject: [PATCH] :art: split emit_pre_ctor --- src/emit/emit.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 4894ed2d..be0a7460 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -143,26 +143,24 @@ ANN m_uint emit_local(const Emitter emit, const m_uint size, const m_bool is_obj return frame_local(emit->gwion->mp, emit->code->frame, size, is_obj); } +ANN static inline void maybe_ctor(const Emitter emit, const Type type) { + if(type->nspc && type->nspc->pre_ctor && !GET_FLAG(type, nonnull)) + emit_ext_ctor(emit, type->nspc->pre_ctor); +} + +ANN static inline void tmpl_ctor(const Emitter emit, const Type type) { + const Type t = template_parent(emit->env, type); + maybe_ctor(emit, t); +} + ANN static void emit_pre_ctor(const Emitter emit, const Type type) { if(type->e->parent) emit_pre_ctor(emit, type->e->parent); - if(type->nspc && type->nspc->pre_ctor && !GET_FLAG(type, nonnull)) - emit_ext_ctor(emit, type->nspc->pre_ctor); -/* - if(type->nspc && !GET_FLAG(type, nonnull)) { - if(type->nspc->pre_ctor) - emit_ext_ctor(emit, type->nspc->pre_ctor); - if(type->nspc->ctor) - emit_ext_ctor(emit, type->nspc->ctor); - } -*/ + maybe_ctor(emit, type); if(GET_FLAG(type, typedef) && type->e->parent->array_depth) emit_array_extend(emit, type->e->parent, type->e->def->base.ext->array->exp); - if(GET_FLAG(type, template) && GET_FLAG(type, builtin)) { - const Type t = template_parent(emit->env, type); - if(t->nspc->pre_ctor) - emit_ext_ctor(emit, t->nspc->pre_ctor); - } + if(GET_FLAG(type, template) && GET_FLAG(type, builtin)) + tmpl_ctor(emit, type); } #define regxxx(name, instr) \ -- 2.43.0