From c9331fb59e6e85efc21aa47d80fe2db1ed90f9f1 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 20 Feb 2014 17:14:58 +0900 Subject: [PATCH] [refactor] proceed return values from C functions in OP_RET block --- src/vm.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/vm.c b/src/vm.c index 4586af82..b3d63756 100644 --- a/src/vm.c +++ b/src/vm.c @@ -570,8 +570,6 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) ci->fp = pic->sp - c.u.i; ci->env = NULL; if (pic_proc_cfunc_p(x)) { - int i, retc; - pic_value *retv; /* invoke! */ v = proc->u.cfunc(pic); @@ -580,17 +578,8 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) ci->retc = 1; } - retc = ci->retc; - retv = pic->sp - retc; - for (i = 0; i < retc; ++i) { - pic->ci->fp[i] = retv[i]; - } - ci = POPCI(); - pic->sp = ci->fp + retc; - pic->ip = ci->ip; - - pic_gc_arena_restore(pic, ai); - NEXT; + pic_gc_arena_restore(pic, ai); + goto L_RET; } else { int i; @@ -665,7 +654,8 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) pic->ci->retc = c.u.i; - retc = c.u.i; + L_RET: + retc = pic->ci->retc; retv = pic->sp - retc; for (i = 0; i < retc; ++i) { pic->ci->fp[i] = retv[i];