diff options
| author | Nikita Popov <nikic@php.net> | 2012-05-29 17:34:33 +0200 |
|---|---|---|
| committer | Nikita Popov <nikic@php.net> | 2012-05-29 17:34:33 +0200 |
| commit | 3600914ced52eb4f6db10410ba887c8e2a2acfe1 (patch) | |
| tree | 0ac51998ad3b771ebc10a21dfccceeb677767f8e /Zend/zend_compile.c | |
| parent | b770b221e0b3036708deb9e22dacf296402787f0 (diff) | |
| download | php-git-3600914ced52eb4f6db10410ba887c8e2a2acfe1.tar.gz | |
Add support for $generator->send()
Yield now is an expression and the return value is the value passed to
$generator->send(). By default (i.e. if ->next() is called) the value is
NULL.
Unlike in Python ->send() can be run without priming the generator with a
->next() call first.
Diffstat (limited to 'Zend/zend_compile.c')
| -rw-r--r-- | Zend/zend_compile.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 30fecf1e2e..37e49014ec 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 *expr TSRMLS_DC) /* {{{ */ +void zend_do_yield(znode *result, const znode *expr TSRMLS_DC) /* {{{ */ { zend_op *opline; @@ -2675,6 +2675,10 @@ void zend_do_yield(znode *expr TSRMLS_DC) /* {{{ */ opline->opcode = ZEND_YIELD; SET_NODE(opline->op1, expr); SET_UNUSED(opline->op2); + + opline->result_type = IS_VAR; + opline->result.var = get_temporary_variable(CG(active_op_array)); + GET_NODE(result, opline->result); } /* }}} */ |
