From: Jérémie Astor Date: Sun, 14 Jun 2020 06:57:53 +0000 (+0200) Subject: :bug: Fix unemitted member call (and add tests) X-Git-Tag: nightly~1479 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=5905161a8da0bf95b5aad7a79a89b4e33e4a3a77;p=gwion.git :bug: Fix unemitted member call (and add tests) --- 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;