varg - operator

This commit is contained in:
Yuichi Nishiwaki 2013-11-07 12:18:00 +09:00
parent 84c1156b9d
commit 9d304be02e
1 changed files with 23 additions and 5 deletions

View File

@ -441,11 +441,26 @@ codegen(codegen_state *state, pic_value obj, bool tailpos)
break; break;
} }
else if (sym == pic->sSUB) { else if (sym == pic->sSUB) {
ARGC_ASSERT(2); pic_value args;
codegen(state, pic_car(pic, pic_cdr(pic, obj)), false);
codegen(state, pic_car(pic, pic_cdr(pic, pic_cdr(pic, obj))), false); ARGC_ASSERT_GE(1);
irep->code[irep->clen].insn = OP_SUB; switch (pic_length(pic, obj)) {
irep->clen++; case 2:
codegen(state, pic_car(pic, pic_cdr(pic, obj)), false);
irep->code[irep->clen].insn = OP_MINUS;
irep->clen++;
break;
default:
args = pic_cdr(pic, obj);
codegen(state, pic_car(pic, args), false);
while (pic_length(pic, args) >= 2) {
codegen(state, pic_car(pic, pic_cdr(pic, args)), false);
irep->code[irep->clen].insn = OP_SUB;
irep->clen++;
args = pic_cdr(pic, args);
}
break;
}
break; break;
} }
else if (sym == pic->sMUL) { else if (sym == pic->sMUL) {
@ -910,6 +925,9 @@ print_irep(pic_state *pic, struct pic_irep *irep)
case OP_DIV: case OP_DIV:
puts("OP_DIV"); puts("OP_DIV");
break; break;
case OP_MINUS:
puts("OP_MINUS");
break;
case OP_EQ: case OP_EQ:
puts("OP_EQ"); puts("OP_EQ");
break; break;