summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2012-05-30 02:44:06 +0200
committerNikita Popov <nikic@php.net>2012-05-30 02:44:06 +0200
commitbc08c2cf9485e20fea0eef7ab149cefdf9a3662e (patch)
tree902abf875287ba8842600cc5e84557ee30bfc2f4 /Zend/zend_compile.c
parent72a91d08e7d70d5524feb6cc7c8e32b3bd68f1df (diff)
downloadphp-git-bc08c2cf9485e20fea0eef7ab149cefdf9a3662e.tar.gz
Add support for yielding keys
Keys are yielded using the yield $key => $value syntax. Currently this is implemented as a statement only and not as an expression, because conflicts arise considering nesting and use in arrays: yield yield $a => $b; // could be either yield (yield $a) => $b; // or yield (yield $a => $b); Once I find some way to resolve these conflicts this should be available as an expression too. Also the key yielding code is rather copy-and-past-y for the value yielding code, so that should be factored out.
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 89549bb6ed..da61b76662 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -2662,7 +2662,7 @@ void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC) /* {{{ */
}
/* }}} */
-void zend_do_yield(znode *result, const znode *expr TSRMLS_DC) /* {{{ */
+void zend_do_yield(znode *result, const znode *value, const znode *key TSRMLS_DC) /* {{{ */
{
zend_op *opline;
@@ -2674,8 +2674,14 @@ void zend_do_yield(znode *result, const znode *expr TSRMLS_DC) /* {{{ */
opline->opcode = ZEND_YIELD;
- if (expr) {
- SET_NODE(opline->op1, expr);
+ if (value) {
+ SET_NODE(opline->op1, value);
+ } else {
+ SET_UNUSED(opline->op1);
+ }
+
+ if (key) {
+ SET_NODE(opline->op2, key);
} else {
SET_UNUSED(opline->op2);
}