From a422189ee6267ebd228f9038cd84b0e9b320097f Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Wed, 17 Jul 2019 19:40:57 +0200 Subject: [PATCH] :bug: Fix member fptr spork --- include/opcode.h | 2 ++ opcode.txt | 1 + src/emit/emit.c | 16 ++++------------ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/include/opcode.h b/include/opcode.h index 4605b40c..49fd830a 100644 --- a/include/opcode.h +++ b/include/opcode.h @@ -132,6 +132,7 @@ enum { eSporkIni, eForkIni, eSporkFunc, + eSporkMemberFptr, eSporkExp, eForkEnd, eSporkEnd, @@ -306,6 +307,7 @@ enum { #define SporkIni (f_instr)eSporkIni #define ForkIni (f_instr)eForkIni #define SporkFunc (f_instr)eSporkFunc +#define SporkMemberFptr (f_instr)eSporkMemberFptr #define SporkExp (f_instr)eSporkExp #define ForkEnd (f_instr)eForkEnd #define SporkEnd (f_instr)eSporkEnd diff --git a/opcode.txt b/opcode.txt index f88b8c99..eb027efe 100644 --- a/opcode.txt +++ b/opcode.txt @@ -129,6 +129,7 @@ FuncMemberEnd SporkIni ForkIni SporkFunc +SporkMemberFptr SporkExp ForkEnd SporkEnd diff --git a/src/emit/emit.c b/src/emit/emit.c index ed868e06..e50b6d13 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -973,18 +973,10 @@ ANN m_bool emit_exp_spork(const Emitter emit, const Exp_Unary* unary) { } else { if(GET_FLAG(f, member) && is_fptr(f->value_ref->type)) { const m_uint depth = f->def->stack_depth; - regpop(emit, depth); - emit_add_instr(emit, RegPushMem); - const Instr arg = emit_add_instr(emit, SporkFunc); - arg->m_val = depth - SZ_INT; - const Instr cpy = emit_add_instr(emit, SporkFunc); - cpy->m_val = SZ_INT; - cpy->m_val2 = -SZ_INT; - const Instr cpy1 = emit_add_instr(emit, SporkFunc); - cpy1->m_val = SZ_INT; - cpy1->m_val2 = SZ_INT; - const Instr code = emit_add_instr(emit, DotMember); - code->m_val = f->value_ref->offset; + regpop(emit, depth -SZ_INT); + const Instr spork = emit_add_instr(emit, SporkMemberFptr); + spork->m_val = depth + SZ_INT; + spork->m_val2 = -SZ_INT*2; } else emit_exp_spork_finish(emit, f->def->stack_depth); const Instr end = emit_add_instr(emit, is_spork ? SporkEnd : ForkEnd); -- 2.43.0