[bugfix] pic_trampoline was broken

This commit is contained in:
Yuichi Nishiwaki 2014-02-07 09:49:49 +09:00
parent 85512d9ec0
commit 67a856b1db
1 changed files with 8 additions and 7 deletions

View File

@ -816,25 +816,26 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
} }
struct pic_code trampoline_iseq[] = { struct pic_code trampoline_iseq[] = {
{ OP_NOP, {0} }, { OP_NOP, {0} },
{ OP_CALL, {0} }, { OP_TAILCALL, {0} },
{ OP_RET, {0} },
}; };
pic_value pic_value
pic_trampoline(pic_state *pic, struct pic_proc *proc, pic_value args) pic_trampoline(pic_state *pic, struct pic_proc *proc, pic_value args)
{ {
pic_value v, call_list; pic_value v, call_list, *fp = pic->ci->fp;
pic_callinfo *ci;
call_list = pic_cons(pic, pic_obj_value(proc), args); call_list = pic_cons(pic, pic_obj_value(proc), args);
pic_for_each (v, call_list) { pic_for_each (v, call_list) {
*pic->ci->fp++ = v; *fp++ = v;
} }
trampoline_iseq[1].u.i = pic_length(pic, call_list); trampoline_iseq[1].u.i = pic_length(pic, call_list);
pic->ci->ip = trampoline_iseq; ci = PUSHCI();
pic->ci->fp--; /* the last argument is pushed by the VM */ ci->ip = trampoline_iseq;
ci->fp = fp - 1; /* the last argument is pushed by the VM */
return v; return v;
} }