From 7837a30d538af7daee79c23147378f2125c048ac Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Tue, 4 Feb 2014 16:20:17 +0900 Subject: [PATCH] add OP_NOP --- include/picrin/irep.h | 1 + src/codegen.c | 3 +++ src/vm.c | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/picrin/irep.h b/include/picrin/irep.h index f436dcbe..7de2b5a2 100644 --- a/include/picrin/irep.h +++ b/include/picrin/irep.h @@ -10,6 +10,7 @@ extern "C" { #endif enum pic_opcode { + OP_NOP, OP_POP, OP_PUSHNIL, OP_PUSHTRUE, diff --git a/src/codegen.c b/src/codegen.c index 1dfb0e7f..14bb906f 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -1493,6 +1493,9 @@ print_code(pic_state *pic, struct pic_code c) printf("[%2d] ", c.insn); switch (c.insn) { + case OP_NOP: + puts("OP_NOP"); + break; case OP_POP: puts("OP_POP"); break; diff --git a/src/vm.c b/src/vm.c index 14d713dc..d9cd024b 100644 --- a/src/vm.c +++ b/src/vm.c @@ -387,7 +387,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) #if PIC_DIRECT_THREADED_VM static void *oplabels[] = { - &&L_OP_POP, &&L_OP_PUSHNIL, &&L_OP_PUSHTRUE, &&L_OP_PUSHFALSE, + &&L_OP_NOP, &&L_OP_POP, &&L_OP_PUSHNIL, &&L_OP_PUSHTRUE, &&L_OP_PUSHFALSE, &&L_OP_PUSHINT, &&L_OP_PUSHCHAR, &&L_OP_PUSHCONST, &&L_OP_GREF, &&L_OP_GSET, &&L_OP_LREF, &&L_OP_LSET, &&L_OP_CREF, &&L_OP_CSET, &&L_OP_JMP, &&L_OP_JMPIF, &&L_OP_NOT, &&L_OP_CALL, &&L_OP_TAILCALL, &&L_OP_RET, @@ -443,6 +443,9 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) goto L_CALL; VM_LOOP { + CASE(OP_NOP) { + NEXT; + } CASE(OP_POP) { POPN(1); NEXT;