summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-12-20 21:15:57 +0000
committerNicholas Clark <nick@ccl4.org>2007-12-20 21:15:57 +0000
commit878d132a73f5d089e821fedd49aa4835a2786d1d (patch)
tree5f489d4e731a9809ef0261bfb731eee600f3911a /op.c
parent3bdcbd26ea8ce137a02a61d6364dbbb1afb63c19 (diff)
downloadperl-878d132a73f5d089e821fedd49aa4835a2786d1d.tar.gz
Implement each @array.
Documentation needed, FIXME for proper 64 bit support of arrays longer than 2**32, re-order the new ops at the end if merging to 5.10.x. p4raw-id: //depot/perl@32680
Diffstat (limited to 'op.c')
-rw-r--r--op.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/op.c b/op.c
index e68b86fbf7..bb6ac6286c 100644
--- a/op.c
+++ b/op.c
@@ -7892,6 +7892,27 @@ Perl_ck_substr(pTHX_ OP *o)
return o;
}
+OP *
+Perl_ck_each(pTHX_ OP *o)
+{
+
+ OP *kid = cLISTOPo->op_first;
+
+ if (kid->op_type == OP_PADAV || kid->op_type == OP_RV2AV) {
+ const unsigned new_type = o->op_type == OP_EACH ? OP_AEACH
+ : o->op_type == OP_KEYS ? OP_AKEYS : OP_AVALUES;
+ o->op_type = new_type;
+ o->op_ppaddr = PL_ppaddr[new_type];
+ }
+ else if (!(kid->op_type == OP_PADHV || kid->op_type == OP_RV2HV
+ || (kid->op_type == OP_CONST && kid->op_private & OPpCONST_BARE)
+ )) {
+ bad_type(1, "hash or array", PL_op_desc[o->op_type], kid);
+ return o;
+ }
+ return ck_fun(o);
+}
+
/* A peephole optimizer. We visit the ops in the order they're to execute.
* See the comments at the top of this file for more details about when
* peep() is called */