iterary, as the two structure members are not used simultaneously.
p4raw-id: //depot/perl@33062
/* (from inspection of source code) for a .. range of strings this is the
current string. */
SV * iterlval;
+ union {
/* (from inspection of source code) for a foreach loop this is the array
being iterated over. For a .. range of numbers it's the current value.
A check is often made on the SvTYPE of iterary to determine whether
we are iterating over an array or a range. (numbers or strings) */
- AV * iterary;
+ AV * iterary;
+ /* Minimum stack index when reverse iterating as CXt_LOOP_STACK */
+ IV itermin;
+ } ary_min_u;
IV iterix;
/* (from inspection of source code) for a .. range of numbers this is the
maximum value. */
cx->blk_loop.my_op = cLOOP; \
PUSHLOOP_OP_NEXT; \
cx->blk_loop.iterlval = NULL; \
- cx->blk_loop.iterary = NULL; \
+ cx->blk_loop.ary_min_u.iterary = NULL; \
CX_ITERDATA_SET(cx,NULL);
#define PUSHLOOP_FOR(cx, dat, s) \
cx->blk_loop.my_op = cLOOP; \
PUSHLOOP_OP_NEXT; \
cx->blk_loop.iterlval = NULL; \
- cx->blk_loop.iterary = NULL; \
+ cx->blk_loop.ary_min_u.iterary = NULL; \
cx->blk_loop.iterix = -1; \
CX_ITERDATA_SET(cx,dat);
SvREFCNT_dec(cx->blk_loop.itersave); \
} \
} \
- if ((CxTYPE(cx) != CXt_LOOP_STACK) && cx->blk_loop.iterary) \
- SvREFCNT_dec(cx->blk_loop.iterary);
+ if ((CxTYPE(cx) != CXt_LOOP_STACK) && cx->blk_loop.ary_min_u.iterary) \
+ SvREFCNT_dec(cx->blk_loop.ary_min_u.iterary);
/* given/when context */
struct block_givwhen {
PUSHLOOP_FOR(cx, svp, MARK);
#endif
if (PL_op->op_flags & OPf_STACKED) {
- cx->blk_loop.iterary = (AV*)SvREFCNT_inc(POPs);
- if (SvTYPE(cx->blk_loop.iterary) != SVt_PVAV) {
+ cx->blk_loop.ary_min_u.iterary = (AV*)SvREFCNT_inc(POPs);
+ if (SvTYPE(cx->blk_loop.ary_min_u.iterary) != SVt_PVAV) {
dPOPss;
- SV * const right = (SV*)cx->blk_loop.iterary;
+ SV * const right = (SV*)cx->blk_loop.ary_min_u.iterary;
SvGETMAGIC(sv);
SvGETMAGIC(right);
if (RANGE_IS_NUMERIC(sv,right)) {
}
else if (PL_op->op_private & OPpITER_REVERSED) {
cx->blk_loop.itermax = 0xDEADBEEF;
- cx->blk_loop.iterix = AvFILL(cx->blk_loop.iterary) + 1;
+ cx->blk_loop.iterix = AvFILL(cx->blk_loop.ary_min_u.iterary) + 1;
}
}
else {
- cx->blk_loop.iterary = (AV*)0xDEADBEEF;
if (PL_op->op_private & OPpITER_REVERSED) {
- cx->blk_loop.itermax = MARK - PL_stack_base + 1;
+ cx->blk_loop.ary_min_u.itermin = MARK - PL_stack_base + 1;
cx->blk_loop.iterix = cx->blk_oldsp + 1;
}
else {
DIE(aTHX_ "panic: pp_iter");
itersvp = CxITERVAR(cx);
- av = CxTYPE(cx) == CXt_LOOP_STACK ? PL_curstack : cx->blk_loop.iterary;
+ av = (CxTYPE(cx) == CXt_LOOP_STACK)
+ ? PL_curstack : cx->blk_loop.ary_min_u.iterary;
if (SvTYPE(av) != SVt_PVAV) {
/* iterate ($min .. $max) */
if (CxTYPE(cx) != CXt_LOOP_LAZYIV) {
if (PL_op->op_private & OPpITER_REVERSED) {
/* In reverse, use itermax as the min :-) */
if (cx->blk_loop.iterix <= (CxTYPE(cx) == CXt_LOOP_STACK
- ? cx->blk_loop.itermax : 0))
+ ? cx->blk_loop.ary_min_u.itermin : 0))
RETPUSHNO;
if (SvMAGICAL(av) || AvREIFY(av)) {
PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERIX = %ld\n",
(long)cx->blk_loop.iterix);
PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERARY = 0x%"UVxf"\n",
- PTR2UV(cx->blk_loop.iterary));
+ PTR2UV(cx->blk_loop.ary_min_u.iterary));
PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERVAR = 0x%"UVxf"\n",
PTR2UV(CxITERVAR(cx)));
if (CxITERVAR(cx))
break;
case CXt_LOOP_LAZYIV:
case CXt_LOOP_FOR:
- ncx->blk_loop.iterary = av_dup_inc(ncx->blk_loop.iterary,
- param);
+ ncx->blk_loop.ary_min_u.iterary
+ = av_dup_inc(ncx->blk_loop.ary_min_u.iterary, param);
case CXt_LOOP_STACK:
case CXt_LOOP_PLAIN:
ncx->blk_loop.iterdata = (CxPADLOOP(ncx)