Remove temporary limitation of OP_EPOP.

After f68f5f6, the operand of `OP_EPOP` should have been `1`.
Now we have removed the limitation.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-09-12 12:41:02 +09:00
parent d6e41c3e51
commit 5760226e71
2 changed files with 20 additions and 27 deletions
-10
View File
@@ -279,20 +279,10 @@ genop_peep(codegen_scope *s, mrb_code i, int val)
}
break;
case OP_EPOP:
#if 1
if (GETARG_A(i) > 1) {
int j, len = GETARG_A(i), n;
for (j=0; j<len; j++) {
n = genop(s, MKOP_A(OP_EPOP, 1));
}
return n;
}
#else
if (c0 == OP_EPOP) {
s->iseq[s->pc-1] = MKOP_A(OP_EPOP, GETARG_A(i0)+GETARG_A(i));
return 0;
}
#endif
break;
case OP_POPERR:
if (c0 == OP_POPERR) {
+20 -17
View File
@@ -1319,31 +1319,34 @@ RETRY_TRY_BLOCK:
CASE(OP_EPOP) {
/* A A.times{ensure_pop().call} */
int a = GETARG_A(i);
int n, epos = mrb->c->ci->epos;
mrb_callinfo *ci;
mrb_value self = regs[0];
mrb_assert(a==1); /* temporary limitation */
if (mrb->c->eidx == mrb->c->ci->epos) {
if (mrb->c->eidx == epos) {
NEXT;
}
proc = mrb->c->ensure[--mrb->c->eidx];
irep = proc->body.irep;
for (n=0; n<a && mrb->c->eidx > epos; n++) {
proc = mrb->c->ensure[epos+n];
irep = proc->body.irep;
ci = cipush(mrb);
ci->mid = ci[-1].mid;
ci->argc = 0;
ci->proc = proc;
ci->stackent = mrb->c->stack;
ci->nregs = irep->nregs;
ci->target_class = proc->target_class;
ci->pc = pc + 1;
ci->acc = ci[-1].nregs;
mrb->c->stack += ci->acc;
stack_extend(mrb, ci->nregs);
regs[0] = self;
pc = irep->iseq;
}
pool = irep->pool;
syms = irep->syms;
ci = cipush(mrb);
ci->mid = ci[-1].mid;
ci->argc = 0;
ci->proc = proc;
ci->stackent = mrb->c->stack;
ci->nregs = irep->nregs;
ci->target_class = proc->target_class;
ci->pc = pc + 1;
ci->acc = ci[-1].nregs;
mrb->c->stack += ci->acc;
stack_extend(mrb, ci->nregs);
regs[0] = self;
pc = irep->iseq;
mrb->c->eidx = epos;
JUMP;
}