add OP_NOT instruction

This commit is contained in:
Yuichi Nishiwaki 2014-02-02 14:54:47 +09:00
parent 0425dbdd1e
commit 0fec56362d
2 changed files with 10 additions and 2 deletions

View File

@ -25,6 +25,7 @@ enum pic_opcode {
OP_CSET, OP_CSET,
OP_JMP, OP_JMP,
OP_JMPIF, OP_JMPIF,
OP_NOT,
OP_CALL, OP_CALL,
OP_TAILCALL, OP_TAILCALL,
OP_RET, OP_RET,

View File

@ -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_POP, &&L_OP_PUSHNIL, &&L_OP_PUSHTRUE, &&L_OP_PUSHFALSE,
&&L_OP_PUSHINT, &&L_OP_PUSHCHAR, &&L_OP_PUSHCONST, &&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_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_JMP, &&L_OP_JMPIF, &&L_OP_NOT, &&L_OP_CALL, &&L_OP_TAILCALL, &&L_OP_RET,
&&L_OP_CONS, &&L_OP_CAR, &&L_OP_CDR, &&L_OP_NILP, &&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_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 &&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; NEXT;
} }
CASE(OP_NOT) {
pic_value v;
v = pic_false_p(POP()) ? pic_true_value() : pic_false_value();
PUSH(v);
NEXT;
}
CASE(OP_CALL) { CASE(OP_CALL) {
pic_value x, v; pic_value x, v;
pic_callinfo *ci; pic_callinfo *ci;