Lines Matching refs:generator

32 static void zend_generator_cleanup_unfinished_execution(zend_generator *generator TSRMLS_DC) /* {{{…  in zend_generator_cleanup_unfinished_execution()
34 zend_execute_data *execute_data = generator->execute_data; in zend_generator_cleanup_unfinished_execution()
37 if (generator->send_target) { in zend_generator_cleanup_unfinished_execution()
38 Z_DELREF_PP(generator->send_target); in zend_generator_cleanup_unfinished_execution()
39 generator->send_target = NULL; in zend_generator_cleanup_unfinished_execution()
80 void **ptr = generator->stack->top - 1; in zend_generator_cleanup_unfinished_execution()
99 ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished_execution TSRMLS_D… in zend_generator_close() argument
101 if (generator->value) { in zend_generator_close()
102 zval_ptr_dtor(&generator->value); in zend_generator_close()
103 generator->value = NULL; in zend_generator_close()
106 if (generator->key) { in zend_generator_close()
107 zval_ptr_dtor(&generator->key); in zend_generator_close()
108 generator->key = NULL; in zend_generator_close()
111 if (generator->execute_data) { in zend_generator_close()
112 zend_execute_data *execute_data = generator->execute_data; in zend_generator_close()
128 generator->execute_data = NULL; in zend_generator_close()
153 zend_generator_cleanup_unfinished_execution(generator TSRMLS_CC); in zend_generator_close()
162 efree(generator->stack); in zend_generator_close()
163 generator->execute_data = NULL; in zend_generator_close()
168 static void zend_generator_dtor_storage(zend_generator *generator, zend_object_handle handle TSRMLS… in zend_generator_dtor_storage() argument
170 zend_execute_data *ex = generator->execute_data; in zend_generator_dtor_storage()
204 generator->flags |= ZEND_GENERATOR_FORCED_CLOSE; in zend_generator_dtor_storage()
205 zend_generator_resume(generator TSRMLS_CC); in zend_generator_dtor_storage()
210 static void zend_generator_free_storage(zend_generator *generator TSRMLS_DC) /* {{{ */ in zend_generator_free_storage()
212 zend_generator_close(generator, 0 TSRMLS_CC); in zend_generator_free_storage()
214 zend_object_std_dtor(&generator->std TSRMLS_CC); in zend_generator_free_storage()
215 efree(generator); in zend_generator_free_storage()
221 zend_generator *generator; in zend_generator_create() local
224 generator = emalloc(sizeof(zend_generator)); in zend_generator_create()
225 memset(generator, 0, sizeof(zend_generator)); in zend_generator_create()
228 generator->largest_used_integer_key = -1; in zend_generator_create()
230 zend_object_std_init(&generator->std, class_type TSRMLS_CC); in zend_generator_create()
232 object.handle = zend_objects_store_put(generator, in zend_generator_create()
258 zend_generator *generator; in zend_generator_create_zval() local
315 generator = (zend_generator *) zend_object_store_get_object(return_value TSRMLS_CC); in zend_generator_create_zval()
316 generator->execute_data = execute_data; in zend_generator_create_zval()
317 generator->stack = EG(argument_stack); in zend_generator_create_zval()
332 ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ */ in zend_generator_resume()
335 if (!generator->execute_data) { in zend_generator_resume()
339 if (generator->flags & ZEND_GENERATOR_CURRENTLY_RUNNING) { in zend_generator_resume()
344 generator->flags &= ~ZEND_GENERATOR_AT_FIRST_YIELD; in zend_generator_resume()
360 EG(return_value_ptr_ptr) = (zval **) generator; in zend_generator_resume()
363 EG(current_execute_data) = generator->execute_data; in zend_generator_resume()
364 EG(opline_ptr) = &generator->execute_data->opline; in zend_generator_resume()
365 EG(active_op_array) = generator->execute_data->op_array; in zend_generator_resume()
366 EG(active_symbol_table) = generator->execute_data->symbol_table; in zend_generator_resume()
367 EG(This) = generator->execute_data->current_this; in zend_generator_resume()
368 EG(scope) = generator->execute_data->current_scope; in zend_generator_resume()
369 EG(called_scope) = generator->execute_data->current_called_scope; in zend_generator_resume()
370 EG(argument_stack) = generator->stack; in zend_generator_resume()
378 generator->execute_data->prev_execute_data->prev_execute_data = original_execute_data; in zend_generator_resume()
381 generator->flags |= ZEND_GENERATOR_CURRENTLY_RUNNING; in zend_generator_resume()
382 zend_execute_ex(generator->execute_data TSRMLS_CC); in zend_generator_resume()
383 generator->flags &= ~ZEND_GENERATOR_CURRENTLY_RUNNING; in zend_generator_resume()
405 static void zend_generator_ensure_initialized(zend_generator *generator TSRMLS_DC) /* {{{ */ in zend_generator_ensure_initialized()
407 if (generator->execute_data && !generator->value) { in zend_generator_ensure_initialized()
408 zend_generator_resume(generator TSRMLS_CC); in zend_generator_ensure_initialized()
409 generator->flags |= ZEND_GENERATOR_AT_FIRST_YIELD; in zend_generator_ensure_initialized()
414 static void zend_generator_rewind(zend_generator *generator TSRMLS_DC) /* {{{ */ in zend_generator_rewind()
416 zend_generator_ensure_initialized(generator TSRMLS_CC); in zend_generator_rewind()
418 if (!(generator->flags & ZEND_GENERATOR_AT_FIRST_YIELD)) { in zend_generator_rewind()
428 zend_generator *generator; in ZEND_METHOD() local
434 generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); in ZEND_METHOD()
436 zend_generator_rewind(generator TSRMLS_CC); in ZEND_METHOD()
444 zend_generator *generator; in ZEND_METHOD() local
450 generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); in ZEND_METHOD()
452 zend_generator_ensure_initialized(generator TSRMLS_CC); in ZEND_METHOD()
454 RETURN_BOOL(generator->value != NULL); in ZEND_METHOD()
462 zend_generator *generator; in ZEND_METHOD() local
468 generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); in ZEND_METHOD()
470 zend_generator_ensure_initialized(generator TSRMLS_CC); in ZEND_METHOD()
472 if (generator->value) { in ZEND_METHOD()
473 RETURN_ZVAL_FAST(generator->value); in ZEND_METHOD()
482 zend_generator *generator; in ZEND_METHOD() local
488 generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); in ZEND_METHOD()
490 zend_generator_ensure_initialized(generator TSRMLS_CC); in ZEND_METHOD()
492 if (generator->key) { in ZEND_METHOD()
493 RETURN_ZVAL_FAST(generator->key); in ZEND_METHOD()
502 zend_generator *generator; in ZEND_METHOD() local
508 generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); in ZEND_METHOD()
510 zend_generator_ensure_initialized(generator TSRMLS_CC); in ZEND_METHOD()
512 zend_generator_resume(generator TSRMLS_CC); in ZEND_METHOD()
521 zend_generator *generator; in ZEND_METHOD() local
527 generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); in ZEND_METHOD()
529 zend_generator_ensure_initialized(generator TSRMLS_CC); in ZEND_METHOD()
532 if (!generator->execute_data) { in ZEND_METHOD()
537 if (generator->send_target) { in ZEND_METHOD()
538 Z_DELREF_PP(generator->send_target); in ZEND_METHOD()
540 *generator->send_target = value; in ZEND_METHOD()
543 zend_generator_resume(generator TSRMLS_CC); in ZEND_METHOD()
545 if (generator->value) { in ZEND_METHOD()
546 RETURN_ZVAL_FAST(generator->value); in ZEND_METHOD()
556 zend_generator *generator; in ZEND_METHOD() local
565 generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); in ZEND_METHOD()
567 zend_generator_ensure_initialized(generator TSRMLS_CC); in ZEND_METHOD()
569 if (generator->execute_data) { in ZEND_METHOD()
572 EG(current_execute_data) = generator->execute_data; in ZEND_METHOD()
578 zend_generator_resume(generator TSRMLS_CC); in ZEND_METHOD()
580 if (generator->value) { in ZEND_METHOD()
581 RETURN_ZVAL_FAST(generator->value); in ZEND_METHOD()
619 zend_generator *generator = (zend_generator *) iterator->data; in zend_generator_iterator_valid() local
621 zend_generator_ensure_initialized(generator TSRMLS_CC); in zend_generator_iterator_valid()
623 return generator->value != NULL ? SUCCESS : FAILURE; in zend_generator_iterator_valid()
629 zend_generator *generator = (zend_generator *) iterator->data; in zend_generator_iterator_get_data() local
631 zend_generator_ensure_initialized(generator TSRMLS_CC); in zend_generator_iterator_get_data()
633 if (generator->value) { in zend_generator_iterator_get_data()
634 *data = &generator->value; in zend_generator_iterator_get_data()
643 zend_generator *generator = (zend_generator *) iterator->data; in zend_generator_iterator_get_key() local
645 zend_generator_ensure_initialized(generator TSRMLS_CC); in zend_generator_iterator_get_key()
647 if (generator->key) { in zend_generator_iterator_get_key()
648 ZVAL_ZVAL(key, generator->key, 1, 0); in zend_generator_iterator_get_key()
657 zend_generator *generator = (zend_generator *) iterator->data; in zend_generator_iterator_move_forward() local
659 zend_generator_ensure_initialized(generator TSRMLS_CC); in zend_generator_iterator_move_forward()
661 zend_generator_resume(generator TSRMLS_CC); in zend_generator_iterator_move_forward()
667 zend_generator *generator = (zend_generator *) iterator->data; in zend_generator_iterator_rewind() local
669 zend_generator_rewind(generator TSRMLS_CC); in zend_generator_iterator_rewind()
685 zend_generator *generator; in zend_generator_get_iterator() local
687 generator = (zend_generator *) zend_object_store_get_object(object TSRMLS_CC); in zend_generator_get_iterator()
689 if (!generator->execute_data) { in zend_generator_get_iterator()
694 if (by_ref && !(generator->execute_data->op_array->fn_flags & ZEND_ACC_RETURN_REFERENCE)) { in zend_generator_get_iterator()
699 iterator = &generator->iterator; in zend_generator_get_iterator()
701 iterator->intern.data = (void *) generator; in zend_generator_get_iterator()