From 0fec56362d0ae29c5fda8bfc0b72da450fe2dd07 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sun, 2 Feb 2014 14:54:47 +0900 Subject: [PATCH] add OP_NOT instruction --- include/picrin/irep.h | 1 + src/vm.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/picrin/irep.h b/include/picrin/irep.h index 2ef24cd7..f436dcbe 100644 --- a/include/picrin/irep.h +++ b/include/picrin/irep.h @@ -25,6 +25,7 @@ enum pic_opcode { OP_CSET, OP_JMP, OP_JMPIF, + OP_NOT, OP_CALL, OP_TAILCALL, OP_RET, diff --git a/src/vm.c b/src/vm.c index 0afeced4..6da02f41 100644 --- a/src/vm.c +++ b/src/vm.c @@ -390,8 +390,8 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) &&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_CALL, &&L_OP_TAILCALL, &&L_OP_RET, &&L_OP_LAMBDA, - &&L_OP_CONS, &&L_OP_CAR, &&L_OP_CDR, &&L_OP_NILP, + &&L_OP_JMP, &&L_OP_JMPIF, &&L_OP_NOT, &&L_OP_CALL, &&L_OP_TAILCALL, &&L_OP_RET, + &&L_OP_LAMBDA, &&L_OP_CONS, &&L_OP_CAR, &&L_OP_CDR, &&L_OP_NILP, &&L_OP_ADD, &&L_OP_SUB, &&L_OP_MUL, &&L_OP_DIV, &&L_OP_MINUS, &&L_OP_EQ, &&L_OP_LT, &&L_OP_LE, &&L_OP_STOP }; @@ -534,6 +534,13 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) } NEXT; } + CASE(OP_NOT) { + pic_value v; + + v = pic_false_p(POP()) ? pic_true_value() : pic_false_value(); + PUSH(v); + NEXT; + } CASE(OP_CALL) { pic_value x, v; pic_callinfo *ci;