From 50f44208570ae0928a21b5f41cc4af090aa0d9ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sat, 9 May 2020 19:35:09 +0200 Subject: [PATCH] :bug: Set struct to 0 when appropriate --- src/emit/emit.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 8c21a47c..5a47b19e 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -598,6 +598,7 @@ ANN static m_bool emit_exp_decl_static(const Emitter emit, const Var_Decl var_de ANN static Instr emit_struct_decl(const Emitter emit, const Value v, const m_bool emit_addr) { emit_add_instr(emit, RegPushMem); +//regpushi(emit, 0); const Instr instr = emit_add_instr(emit, !emit_addr ? StructMember : StructMemberAddr); instr->m_val2 = v->from->offset; if(!emit_addr) @@ -619,10 +620,16 @@ ANN static m_bool emit_exp_decl_non_static(const Emitter emit, const Exp_Decl *d if(!GET_FLAG(v, member)) { v->from->offset = emit_local(emit, type); exec = (f_instr*)(allocword); - if(GET_FLAG(var_decl->value, ref)) { // ref or emit_var ? + if(GET_FLAG(v, ref)) { // ref or emit_var ? const Instr clean = emit_add_instr(emit, MemSetImm); clean->m_val = v->from->offset; } + if(!emit_addr && GET_FLAG(type, struct)) { + for(m_uint i = 0; i <= type->size; ++i) { + const Instr clean = emit_add_instr(emit, MemSetImm); + clean->m_val = v->from->offset + i; + } + } } const Instr instr = !(SAFE_FLAG(emit->env->class_def, struct) && !emit->env->scope->depth) ? emit_kind(emit, v->type->size, !struct_ctor(v) ? emit_addr : 1, exec) : emit_struct_decl(emit, v, emit_addr); -- 2.43.0