fix stack operation bug

This commit is contained in:
Yuichi Nishiwaki 2013-10-16 13:24:19 +09:00
parent 9b7fdb0725
commit 49e1f54195
1 changed files with 3 additions and 2 deletions

View File

@ -409,7 +409,7 @@ pic_run(pic_state *pic, struct pic_proc *proc, pic_value args)
NEXT; NEXT;
} }
CASE(OP_CALL) { CASE(OP_CALL) {
pic_value c; pic_value c, v;
struct pic_proc *proc; struct pic_proc *proc;
pic_gc_protect(pic, c = POP()); pic_gc_protect(pic, c = POP());
@ -418,10 +418,11 @@ pic_run(pic_state *pic, struct pic_proc *proc, pic_value args)
ci->proc = proc; ci->proc = proc;
ci->argc = pc->u.i; ci->argc = pc->u.i;
if (pic_proc_cfunc_p(c)) { if (pic_proc_cfunc_p(c)) {
PUSH(proc->u.cfunc(pic)); v = proc->u.cfunc(pic);
pic->sp -= ci->argc; pic->sp -= ci->argc;
POPCI(); POPCI();
ci = pic->ci - 1; ci = pic->ci - 1;
PUSH(v);
} }
else { else {
pic_raise(pic, "closure call not suppoted"); pic_raise(pic, "closure call not suppoted");