use pic_trampoline in pic_proc_apply
This commit is contained in:
parent
2ef426d90b
commit
66ac29519e
18
src/proc.c
18
src/proc.c
|
@ -85,11 +85,10 @@ pic_proc_proc_p(pic_state *pic)
|
||||||
static pic_value
|
static pic_value
|
||||||
pic_proc_apply(pic_state *pic)
|
pic_proc_apply(pic_state *pic)
|
||||||
{
|
{
|
||||||
static struct pic_code iseq[3];
|
|
||||||
struct pic_proc *proc;
|
struct pic_proc *proc;
|
||||||
pic_value *args;
|
pic_value *args;
|
||||||
size_t argc;
|
size_t argc;
|
||||||
pic_value v, arg_list, call_list;
|
pic_value arg_list;
|
||||||
|
|
||||||
pic_get_args(pic, "l*", &proc, &argc, &args);
|
pic_get_args(pic, "l*", &proc, &argc, &args);
|
||||||
|
|
||||||
|
@ -102,20 +101,7 @@ pic_proc_apply(pic_state *pic)
|
||||||
arg_list = pic_cons(pic, args[argc], arg_list);
|
arg_list = pic_cons(pic, args[argc], arg_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
call_list = pic_cons(pic, pic_obj_value(proc), arg_list);
|
return pic_trampoline(pic, proc, arg_list);
|
||||||
pic_for_each (v, call_list) {
|
|
||||||
*pic->ci->fp++ = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
iseq[0].insn = OP_NOP;
|
|
||||||
iseq[1].insn = OP_CALL;
|
|
||||||
iseq[1].u.i = pic_length(pic, call_list);
|
|
||||||
iseq[2].insn = OP_RET;
|
|
||||||
pic->ci->ip = iseq;
|
|
||||||
|
|
||||||
/* the last argument is pushed by the VM */
|
|
||||||
pic->ci->fp--;
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
|
Loading…
Reference in New Issue