VM works with procs not terminated with OP_STOP

This commit is contained in:
Yuichi Nishiwaki 2013-10-30 15:36:28 +09:00
parent 5be1cd7092
commit d4001a70ae
2 changed files with 6 additions and 6 deletions

View File

@ -664,8 +664,8 @@ pic_codegen(pic_state *pic, pic_value obj)
}
state->irep = new_irep(pic);
state->irep->argc = 1;
codegen(state, obj, false);
state->irep->code[state->irep->clen].insn = OP_STOP;
codegen(state, pic_expand(pic, obj), false);
state->irep->code[state->irep->clen].insn = OP_RET;
state->irep->clen++;
env = (struct pic_env *)pic_obj_alloc(pic, sizeof(struct pic_env), PIC_TT_ENV);

View File

@ -185,7 +185,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
int ai = pic_gc_arena_preserve(pic);
jmp_buf jmp;
size_t argc, i;
struct pic_code boot;
struct pic_code boot[2];
#if PIC_DIRECT_THREADED_VM
static void *oplabels[] = {
@ -214,8 +214,9 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
}
/* boot! */
boot.insn = OP_CALL;
boot.u.i = argc;
boot[0].insn = OP_CALL;
boot[0].u.i = argc;
boot[1].insn = OP_STOP;
pc = &boot;
goto L_CALL;
@ -516,7 +517,6 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
L_STOP:
val = POP();
pic->sp = POPCI()->fp;
pic->jmp = NULL;
if (pic->errmsg) {