summaryrefslogtreecommitdiff
path: root/Zend/zend_execute_API.c
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2012-07-20 00:49:50 +0200
committerNikita Popov <nikic@php.net>2012-07-20 16:09:06 +0200
commitc9709bfbd7a71a42e0472abaf9c7d30598e264bf (patch)
tree995cb4d438093a87c887f1de4319be4d49a05136 /Zend/zend_execute_API.c
parent85f077cea13b3cb4927453b8a2f8ce51a9461bbb (diff)
downloadphp-git-c9709bfbd7a71a42e0472abaf9c7d30598e264bf.tar.gz
Remove asterix modifier (*) for generators
Generators are now automatically detected by the presence of a `yield` expression in their body. This removes the ZEND_SUSPEND_AND_RETURN_GENERATOR opcode. Instead additional checks for ZEND_ACC_GENERATOR are added to the fcall_common helper and zend_call_function. This also adds a new function zend_generator_create_zval, which handles the actual creation of the generator zval from an op array. I feel like I should deglobalize the zend_create_execute_data_from_op_array code a bit. It currently changes EG(current_execute_data) and EG(opline_ptr) which is somewhat confusing (given the name).
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r--Zend/zend_execute_API.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 1deee2a86c..fb0c18b27c 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -31,6 +31,7 @@
#include "zend_extensions.h"
#include "zend_exceptions.h"
#include "zend_closures.h"
+#include "zend_generators.h"
#include "zend_vm.h"
#include "zend_float.h"
#ifdef HAVE_SYS_TIME_H
@@ -955,7 +956,13 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
EG(return_value_ptr_ptr) = fci->retval_ptr_ptr;
EG(active_op_array) = (zend_op_array *) EX(function_state).function;
original_opline_ptr = EG(opline_ptr);
- zend_execute(EG(active_op_array) TSRMLS_CC);
+
+ if (EG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) {
+ *fci->retval_ptr_ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC);
+ } else {
+ zend_execute(EG(active_op_array) TSRMLS_CC);
+ }
+
if (!fci->symbol_table && EG(active_symbol_table)) {
if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) {
zend_hash_destroy(EG(active_symbol_table));