summaryrefslogtreecommitdiff
path: root/cop.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-01-24 09:36:05 +0000
committerNicholas Clark <nick@ccl4.org>2008-01-24 09:36:05 +0000
commit3b719c58b6800b0db9786a0d03d9b07e39a8b70f (patch)
tree9b6687e504cbc034f0940871a229a1cafb94e826 /cop.h
parent9f99c5dc9c8b58db8724fb606806e353cbf69d45 (diff)
downloadperl-3b719c58b6800b0db9786a0d03d9b07e39a8b70f.tar.gz
Split CXt_LOOP into CXt_LOOP_PLAIN and CXt_LOOP_FOR, eliminating the
CXp_FOREACH flag added as part of given/when. p4raw-id: //depot/perl@33057
Diffstat (limited to 'cop.h')
-rw-r--r--cop.h31
1 files changed, 20 insertions, 11 deletions
diff --git a/cop.h b/cop.h
index b6e35e84af..15de02f516 100644
--- a/cop.h
+++ b/cop.h
@@ -500,7 +500,15 @@ struct block_loop {
# define CX_LOOP_NEXTOP_GET(cx) ((cx)->blk_loop.next_op + 0)
#endif
-#define PUSHLOOP(cx, dat, s) \
+#define PUSHLOOP_PLAIN(cx, s) \
+ cx->blk_loop.resetsp = s - PL_stack_base; \
+ cx->blk_loop.my_op = cLOOP; \
+ PUSHLOOP_OP_NEXT; \
+ cx->blk_loop.iterlval = NULL; \
+ cx->blk_loop.iterary = NULL; \
+ CX_ITERDATA_SET(cx,NULL);
+
+#define PUSHLOOP_FOR(cx, dat, s) \
cx->blk_loop.resetsp = s - PL_stack_base; \
cx->blk_loop.my_op = cLOOP; \
PUSHLOOP_OP_NEXT; \
@@ -666,12 +674,15 @@ struct context {
#define CXt_NULL 0
#define CXt_SUB 1
#define CXt_EVAL 2
-#define CXt_LOOP 3
+#define CXt_WHEN 3
#define CXt_SUBST 4
#define CXt_BLOCK 5
#define CXt_FORMAT 6
#define CXt_GIVEN 7
-#define CXt_WHEN 8
+#define CXt_LOOP_PLAIN 8
+#define CXt_LOOP_FOR 9
+#define CXt_LOOP_RES1 10
+#define CXt_LOOP_RES2 11
/* private flags for CXt_SUB and CXt_NULL
However, this is checked in many places which do not check the type, so
@@ -689,27 +700,25 @@ struct context {
/* private flags for CXt_LOOP */
#define CXp_FOR_DEF 0x10 /* foreach using $_ */
-#define CXp_FOREACH 0x20 /* a foreach loop */
#ifdef USE_ITHREADS
-# define CXp_PADVAR 0x40 /* itervar lives on pad, iterdata has pad
+# define CXp_PADVAR 0x20 /* itervar lives on pad, iterdata has pad
offset; if not set, iterdata holds GV* */
-# define CxPADLOOP(c) (((c)->cx_type & (CXt_LOOP|CXp_PADVAR)) \
- == (CXt_LOOP|CXp_PADVAR))
+# define CxPADLOOP(c) (CxTYPE_is_LOOP(c) && ((c)->cx_type & (CXp_PADVAR)))
#endif
/* private flags for CXt_SUBST */
#define CXp_ONCE 0x10 /* What was sbu_once in struct subst */
#define CxTYPE(c) ((c)->cx_type & CXTYPEMASK)
+#define CxTYPE_is_LOOP(c) (((c)->cx_type & 0xC) == 0x8)
#define CxMULTICALL(c) (((c)->cx_type & CXp_MULTICALL) \
== CXp_MULTICALL)
#define CxREALEVAL(c) (((c)->cx_type & (CXTYPEMASK|CXp_REAL)) \
== (CXt_EVAL|CXp_REAL))
#define CxTRYBLOCK(c) (((c)->cx_type & (CXTYPEMASK|CXp_TRYBLOCK)) \
== (CXt_EVAL|CXp_TRYBLOCK))
-#define CxFOREACH(c) (((c)->cx_type & (CXTYPEMASK|CXp_FOREACH)) \
- == (CXt_LOOP|CXp_FOREACH))
-#define CxFOREACHDEF(c) (((c)->cx_type & (CXTYPEMASK|CXp_FOREACH|CXp_FOR_DEF))\
- == (CXt_LOOP|CXp_FOREACH|CXp_FOR_DEF))
+#define CxFOREACH(c) (CxTYPE_is_LOOP(c) && CxTYPE(c) != CXt_LOOP_PLAIN)
+#define CxFOREACHDEF(c) ((CxTYPE_is_LOOP(c) && CxTYPE(c) != CXt_LOOP_PLAIN) \
+ && ((c)->cx_type & CXp_FOR_DEF))
#define CXINC (cxstack_ix < cxstack_max ? ++cxstack_ix : (cxstack_ix = cxinc()))