[refactor] proceed return values from C functions in OP_RET block
This commit is contained in:
parent
29b2d84268
commit
c9331fb59e
16
src/vm.c
16
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->fp = pic->sp - c.u.i;
|
||||||
ci->env = NULL;
|
ci->env = NULL;
|
||||||
if (pic_proc_cfunc_p(x)) {
|
if (pic_proc_cfunc_p(x)) {
|
||||||
int i, retc;
|
|
||||||
pic_value *retv;
|
|
||||||
|
|
||||||
/* invoke! */
|
/* invoke! */
|
||||||
v = proc->u.cfunc(pic);
|
v = proc->u.cfunc(pic);
|
||||||
|
@ -580,17 +578,8 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
|
||||||
ci->retc = 1;
|
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);
|
pic_gc_arena_restore(pic, ai);
|
||||||
NEXT;
|
goto L_RET;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int i;
|
int i;
|
||||||
|
@ -665,7 +654,8 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
|
||||||
|
|
||||||
pic->ci->retc = c.u.i;
|
pic->ci->retc = c.u.i;
|
||||||
|
|
||||||
retc = c.u.i;
|
L_RET:
|
||||||
|
retc = pic->ci->retc;
|
||||||
retv = pic->sp - retc;
|
retv = pic->sp - retc;
|
||||||
for (i = 0; i < retc; ++i) {
|
for (i = 0; i < retc; ++i) {
|
||||||
pic->ci->fp[i] = retv[i];
|
pic->ci->fp[i] = retv[i];
|
||||||
|
|
Loading…
Reference in New Issue