add OP_PUSHEOF

This commit is contained in:
Yuichi Nishiwaki 2016-02-06 20:43:21 +09:00
parent 5af1b44456
commit 93105dc2a6
3 changed files with 12 additions and 1 deletions

View File

@ -950,6 +950,9 @@ codegen_quote(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos)
case PIC_TT_NIL:
emit_n(pic, cxt, OP_PUSHNIL);
break;
case PIC_TT_EOF:
emit_n(pic, cxt, OP_PUSHEOF);
break;
case PIC_TT_CHAR:
check_ints_size(pic, cxt);
pidx = (int)cxt->klen++;

View File

@ -18,6 +18,7 @@ enum pic_opcode {
OP_PUSHFALSE,
OP_PUSHINT,
OP_PUSHCHAR,
OP_PUSHEOF,
OP_PUSHCONST,
OP_GREF,
OP_GSET,
@ -85,6 +86,9 @@ pic_dump_code(pic_code c)
case OP_PUSHCHAR:
printf("OP_PUSHCHAR\t%c\n", c.a);
break;
case OP_PUSHEOF:
puts("OP_PUSHEOF");
break;
case OP_PUSHCONST:
printf("OP_PUSHCONST\t%d\n", c.a);
break;

View File

@ -353,7 +353,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, int argc, pic_value *argv)
#if PIC_DIRECT_THREADED_VM
static const void *oplabels[] = {
&&L_OP_NOP, &&L_OP_POP, &&L_OP_PUSHUNDEF, &&L_OP_PUSHNIL, &&L_OP_PUSHTRUE,
&&L_OP_PUSHFALSE, &&L_OP_PUSHINT, &&L_OP_PUSHCHAR, &&L_OP_PUSHCONST,
&&L_OP_PUSHFALSE, &&L_OP_PUSHINT, &&L_OP_PUSHCHAR, &&L_OP_PUSHEOF, &&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,
&&L_OP_LAMBDA, &&L_OP_CONS, &&L_OP_CAR, &&L_OP_CDR, &&L_OP_NILP,
@ -414,6 +414,10 @@ pic_apply(pic_state *pic, struct pic_proc *proc, int argc, pic_value *argv)
PUSH(pic_char_value(pic->ci->irep->u.s.ints[c.a]));
NEXT;
}
CASE(OP_PUSHEOF) {
PUSH(pic_eof_object());
NEXT;
}
CASE(OP_PUSHCONST) {
PUSH(pic->ci->irep->pool[c.a]);
NEXT;