SvREFCNT_dec(cx->blk_loop.itersave); \
} \
} \
- if (cx->blk_loop.iterary && cx->blk_loop.iterary != PL_curstack)\
+ if ((CxTYPE(cx) != CXt_LOOP_STACK) && cx->blk_loop.iterary) \
SvREFCNT_dec(cx->blk_loop.iterary);
/* given/when context */
#define CXt_GIVEN 7
#define CXt_LOOP_PLAIN 8
#define CXt_LOOP_FOR 9
-#define CXt_LOOP_RES1 10
+/* Foreach on a temporary list on the stack */
+#define CXt_LOOP_STACK 10
#define CXt_LOOP_RES2 11
/* private flags for CXt_SUB and CXt_NULL
if (CxTYPE(cx) == CXt_NULL)
return -1;
break;
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
case CXt_LOOP_PLAIN:
if ( !CxLABEL(cx) || strNE(label, CxLABEL(cx)) ) {
if ((CxTYPE(cx)) == CXt_NULL)
return -1;
break;
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
case CXt_LOOP_PLAIN:
DEBUG_l( Perl_deb(aTHX_ "(Found loop #%ld)\n", (long)i));
case CXt_LOOP_PLAIN:
assert(!CxFOREACHDEF(cx));
break;
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
if (CxFOREACHDEF(cx)) {
DEBUG_l( Perl_deb(aTHX_ "(Found foreach #%ld)\n", (long)i));
case CXt_EVAL:
POPEVAL(cx);
break;
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
case CXt_LOOP_PLAIN:
POPLOOP(cx);
register PERL_CONTEXT *cx;
const I32 gimme = GIMME_V;
SV **svp;
- U16 cxtype = CXt_LOOP_FOR;
+ U16 cxtype = 0;
#ifdef USE_ITHREADS
void *iterdata;
#endif
ENTER;
+ cxtype |= (PL_op->op_flags & OPf_STACKED) ? CXt_LOOP_FOR : CXt_LOOP_STACK;
PUSHBLOCK(cx, cxtype, SP);
#ifdef USE_ITHREADS
PUSHLOOP_FOR(cx, iterdata, MARK);
}
}
else {
- cx->blk_loop.iterary = PL_curstack;
+ cx->blk_loop.iterary = (SV*)0xDEADBEEF;
if (PL_op->op_private & OPpITER_REVERSED) {
cx->blk_loop.itermax = MARK - PL_stack_base + 1;
cx->blk_loop.iterix = cx->blk_oldsp + 1;
cxstack_ix++; /* temporarily protect top context */
mark = newsp;
switch (CxTYPE(cx)) {
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
case CXt_LOOP_PLAIN:
pop2 = CxTYPE(cx);
/* Stack values are safe: */
switch (pop2) {
case CXt_LOOP_PLAIN:
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
POPLOOP(cx); /* release loop vars ... */
LEAVE;
break;
}
/* else fall through */
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
case CXt_LOOP_PLAIN:
gotoprobe = cx->blk_oldcop->op_sibling;
DIE(aTHX_ "panic: pp_iter");
itersvp = CxITERVAR(cx);
- av = cx->blk_loop.iterary;
+ av = CxTYPE(cx) == CXt_LOOP_STACK ? PL_curstack : cx->blk_loop.iterary;
if (SvTYPE(av) != SVt_PVAV) {
/* iterate ($min .. $max) */
if (cx->blk_loop.iterlval) {