History log of /PHP-7.4/Zend/zend_generators.c (Results 201 – 225 of 241)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# bef79588 29-Aug-2012 Nikita Popov

Fix segfault when traversing a by-ref generator twice

If you try to traverse an already closed generator an exception will now be
thrown.

Furthermore this changes the error for

Fix segfault when traversing a by-ref generator twice

If you try to traverse an already closed generator an exception will now be
thrown.

Furthermore this changes the error for traversing a by-val generator by-ref
from an E_ERROR to an Exception.

show more ...


# cc07038f 29-Aug-2012 Nikita Popov

Make sure that exception is thrown on rewind() after closing too


Revision tags: php-5.4.7RC1
# f53225a9 25-Aug-2012 Nikita Popov

Fix several issues and allow rewind only at/before first yield

* Trying to resume a generator while it is already running now throws a
fatal error.
* Trying to use yield in fina

Fix several issues and allow rewind only at/before first yield

* Trying to resume a generator while it is already running now throws a
fatal error.
* Trying to use yield in finally while the generator is being force-closed
(by GC) throws a fatal error.
* Rewinding after the first yield now throws an Exception

show more ...


# 4d8edda3 24-Aug-2012 Nikita Popov

Run finally if generator is closed before finishing


# f45a0f31 20-Aug-2012 Nikita Popov

Disallow serialization and unserialization


# 05f10480 20-Aug-2012 Nikita Popov

Drop Generator::close() method


Revision tags: php-5.3.16, php-5.4.6, php-5.4.6RC1
# 268740d9 26-Jul-2012 Nikita Popov

Fix implementation of Iterator interface

It looks like you have to implement the Iterator interface *before*
assigning get_iterator. Otherwise the structure for user iterators isn't

Fix implementation of Iterator interface

It looks like you have to implement the Iterator interface *before*
assigning get_iterator. Otherwise the structure for user iterators isn't
correctly zeroed out.

Additionaly I'm setting class_entry->iterator_funcs.funcs now. Not sure if
this is strictly necessary, but better safe than sorry ;)

show more ...


# 94b2ccae 22-Jul-2012 Nikita Popov

Fix throwing of exceptions within a generator

If a generator threw an exception and was iterated using foreach (i.e. not
manually) an infinite loop was triggered. The reason was that the

Fix throwing of exceptions within a generator

If a generator threw an exception and was iterated using foreach (i.e. not
manually) an infinite loop was triggered. The reason was that the exception
was not properly rethrown using zend_throw_exception_internal.

show more ...


# c9709bfb 19-Jul-2012 Nikita Popov

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_RET

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).

show more ...


Revision tags: php-5.4.5
# 85f077ce 17-Jul-2012 Nikita Popov

Add support by yielding by-reference


Revision tags: php-5.3.15, php-5.3.15RC1, php-5.4.5RC1
# ab75ed6b 23-Jun-2012 Nikita Popov

Disallow closing a generator during its execution

If a generator is closed while it is running an E_WARNING is thrown and the
call is ignored. Maybe a fatal error should be thrown instea

Disallow closing a generator during its execution

If a generator is closed while it is running an E_WARNING is thrown and the
call is ignored. Maybe a fatal error should be thrown instead?

show more ...


# 14766e14 23-Jun-2012 Nikita Popov

Pass zend_generator directly to Zend VM

Previously the zval* of the generator was passed into the VM by misusing
EG(return_value_ptr_ptr). Now the zend_generator* itself is directly pass

Pass zend_generator directly to Zend VM

Previously the zval* of the generator was passed into the VM by misusing
EG(return_value_ptr_ptr). Now the zend_generator* itself is directly passed
in. This saves us from always having to pass the zval* around everywhere.

show more ...


# 04e781f0 22-Jun-2012 Nikita Popov

Implement get_iterator

This implements the get_iterator handler for Generator objects, thus making
direct foreach() iteration significantly faster.


# 6233408a 20-Jun-2012 Nikita Popov

Fix thread safe build


Revision tags: php-5.3.14, php-5.4.4
# d939d2de 11-Jun-2012 Nikita Popov

Add sceleton for yield* expression

This does not yet actually implement any delegation.


# f169b26d 08-Jun-2012 Nikita Popov

Fix backtraces and func_get_args()

To make the generator function show up in backtraces one has to insert an
additional execute_data into the chain, as prev_execute_data->function_state

Fix backtraces and func_get_args()

To make the generator function show up in backtraces one has to insert an
additional execute_data into the chain, as prev_execute_data->function_state
is used to determine the called function.

Adding the additional stack frame is also required for func_get_args(), as
the arguments are fetched from there too. The arguments have to be copied
in order to keep them around. Due to the way they are saved doing so is
quite ugly, so I added another function zend_copy_arguments to zend_execute.c
which handles this.

show more ...


# 40760ecb 03-Jun-2012 Nikita Popov

Fix cloning of generator methods

Forgot to add a reference to the this variable


# bf82f46e 03-Jun-2012 Nikita Popov

Properly handle yield during method calls


# 7b3bfa57 03-Jun-2012 Nikita Popov

Improve backtraces from generators

The current situation is still not perfect, as the generator function itself
does not appear in the stack trace. This makes sense in some way, but it

Improve backtraces from generators

The current situation is still not perfect, as the generator function itself
does not appear in the stack trace. This makes sense in some way, but it
would probably be more helpful if it would show up (with the bound arguments)
after the $generator->xyz() call. This could be misleading too though as the
function is not *really* called there.

show more ...


# 6117f4c7 02-Jun-2012 Nikita Popov

Add cloning support for generators

Generators can now be cloned. I'm pretty sure that my current code does not
yet cover all the edge cases of cloning the execution context, so there are

Add cloning support for generators

Generators can now be cloned. I'm pretty sure that my current code does not
yet cover all the edge cases of cloning the execution context, so there are
probably a few bugs in there :)

show more ...


# 1477be9a 31-May-2012 Nikita Popov

Make $generator->send() return the current value

This makes the API easier to use (and is consistent with Python and JS).


# ee89e228 30-May-2012 Nikita Popov

Allow yielding during function calls

During function calls arguments are pushed onto the stack. Now these are
backed up on yield and restored on resume. This requires memcpy'ing them,

Allow yielding during function calls

During function calls arguments are pushed onto the stack. Now these are
backed up on yield and restored on resume. This requires memcpy'ing them,
but there doesn't seem to be any better way to do it.

Also this fixes the issue with exceptions thrown during function calls.

show more ...


Revision tags: php-5.3.14RC2, php-5.4.4RC2
# 87901602 30-May-2012 Nikita Popov

Add auto-increment keys

When no key is explicitely yielded PHP will used auto-incrementing keys
as a fallback. They behave the same as with arrays, i.e. the key is the
successor of t

Add auto-increment keys

When no key is explicitely yielded PHP will used auto-incrementing keys
as a fallback. They behave the same as with arrays, i.e. the key is the
successor of the largest previously used integer key.

show more ...


# bc08c2cf 30-May-2012 Nikita Popov

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, be

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.

show more ...


# 72a91d08 29-May-2012 Nikita Popov

Add $generator->close() method

Calling $generator->close() is equivalent to executing a return statement
at the current position in the generator.


12345678910