]> Nishi Git Mirror - gwion.git/commitdiff
:Bug: Preliminary fixes
authorfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 24 Feb 2019 21:31:04 +0000 (22:31 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 24 Feb 2019 21:31:04 +0000 (22:31 +0100)
src/emit/emit.c
src/lib/func.c
src/parse/scan2.c
src/vm/vm.c

index 6dab88398a5e885e3b27d86637d469b21313d8f1..e425fbfacd4e71957c5203ca74afcbdd4e5f5c50 100644 (file)
@@ -752,6 +752,16 @@ ANN m_bool emit_exp_call1(const Emitter emit, const Func f) { GWDEBUG_EXE
     if((f_instr)back->opcode == DotFunc)
       back->m_val = f->vt_index;
   }
+  if(GET_FLAG(f, member) && isa(actual_type(f->value_ref->type), t_fptr) > 0) {
+    const Instr back = (Instr)vector_back(&emit->code->instr);
+    m_bit exec = back->opcode;
+    m_uint val = back->m_val;
+    m_uint val2 = back->m_val2;
+    back->opcode = RegDup;
+    const Instr instr = emit_add_instr(emit, exec);
+    instr->m_val = val;
+    instr->m_val2 = val2;
+  }
   const Instr offset = emit_add_instr(emit, RegSetImm);
   offset->m_val = emit_code_offset(emit);
   const Instr instr = emit_call(emit, f);
index 6a8bdbd03e4583517ccd9d636ac7e004beea646a..907fa8db17fbaa33f60fb622b4706eb271b5ac16 100644 (file)
@@ -20,6 +20,8 @@ ANN m_bool emit_exp_spork(const Emitter, const Exp_Unary*);
 static INSTR(FuncAssign) { GWDEBUG_EXE
   POP_REG(shred, SZ_INT)
   **(Func**)REG(0) = *(Func*)REG(-SZ_INT);
+  if(GET_FLAG(*(Func*)REG(-SZ_INT), member))
+    POP_REG(shred, SZ_INT)
 }
 
 static OP_CHECK(opck_func_call) {
index 0246c64c3430066b5ef4d7a76dd11dbb8014ae36..c215813c6e05da247c156564ac9bac3d94130768 100644 (file)
@@ -95,6 +95,7 @@ ANN m_bool scan2_stmt_fptr(const Env env, const Stmt_Fptr ptr) { GWDEBUG_EXE
     CHECK_BB(scan2_args(env, &d))
   const Func_Def def = new_func_def(ptr->td, ptr->xid, ptr->args, NULL, ptr->td->flag);
   def->ret_type = ptr->ret_type;
+  def->stack_depth = d.stack_depth;
   ptr->func = new_func(s_name(ptr->xid), def);
   ptr->value->d.func_ref = ptr->func;
   ptr->func->value_ref = ptr->value;
index b297d8477df46584817640ae6321c740c18123c7..c8fc3022ffe86d7735f708fbfcc05d40e29e8e18 100644 (file)
@@ -376,9 +376,9 @@ regpushmaybe:
   reg += SZ_INT;
   DISPATCH();
 funcreturn:
-  pc = *(m_uint*)(mem-SZ_INT);
-  code = *(VM_Code*)(mem-SZ_INT*2);
-  mem -= (*(m_uint*)(mem-SZ_INT*3) + SZ_INT*3);
+  pc = *(m_uint*)(mem-SZ_INT*2);
+  code = *(VM_Code*)(mem-SZ_INT*3);
+  mem -= (*(m_uint*)(mem-SZ_INT*4) + SZ_INT*4);
   ip = code->instr->ptr + OFFSET;
   DISPATCH();
 _goto:
@@ -562,6 +562,7 @@ funcusr:
   code = *(VM_Code*)reg;
   ip = code->instr->ptr + OFFSET;
   m_uint stack_depth = code->stack_depth;
+  *(m_uint*)  mem = stack_depth; mem += SZ_INT;
   if(stack_depth) {
     register const m_uint f = GET_FLAG(code, member) ? SZ_INT : 0;
     if(f) {