From 5905161a8da0bf95b5aad7a79a89b4e33e4a3a77 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 14 Jun 2020 08:57:53 +0200 Subject: [PATCH] :bug: Fix unemitted member call (and add tests) --- examples/member_func.gw | 1 + src/emit/emit.c | 16 ++++++++-------- tests/struct/member_func.gw | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/member_func.gw b/examples/member_func.gw index c60623a7..06ab956c 100644 --- a/examples/member_func.gw +++ b/examples/member_func.gw @@ -1,5 +1,6 @@ class C { + testf(); fun float testf() { return 1.1; } diff --git a/src/emit/emit.c b/src/emit/emit.c index 132a5046..8ee02546 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1088,16 +1088,16 @@ ANN Instr emit_exp_call1(const Emitter emit, const Func f) { instr->m_val2 = val2; } else if(f != emit->env->func && !f->code && !is_fptr(emit->gwion, f->value_ref->type)){ // not yet emitted static func -/* if(f->value_ref->from->owner_class) { const Instr instr = vector_size(&emit->code->instr) ? - (Instr)vector_back(&emit->code->instr) : emit_add_instr(emit, PushStaticCode); - assert(instr->opcode == ePushStaticCode); - instr->opcode = eRegPushImm; - } else*/ - const Instr instr = emit_add_instr(emit, SetFunc); - instr->m_val = (m_uint)f; -// emit_mod_func(emit, f); + (Instr)vector_back(&emit->code->instr) : emit_add_instr(emit, SetFunc); + instr->opcode = eOP_MAX; + instr->execute = SetFunc; + instr->m_val = (m_uint)f; + } else { + const Instr instr = emit_add_instr(emit, SetFunc); + instr->m_val = (m_uint)f; + } } const m_uint offset = emit_code_offset(emit); regseti(emit, offset); diff --git a/tests/struct/member_func.gw b/tests/struct/member_func.gw index 80de97ed..60ac1a98 100644 --- a/tests/struct/member_func.gw +++ b/tests/struct/member_func.gw @@ -1,4 +1,5 @@ class C { + 1 => test; fun int test(int i) { 13 => int j; return j; -- 2.43.0