- Notifications
You must be signed in to change notification settings - Fork7.9k
Add generators support#177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
74 commits Select commitHold shift + click to select a range
9b101ac
Add T_YIELD "yield" keyword
nikic252f623
Add flag for generator functions
nikic9b51a3b
Minor code cleanup
nikicfd2a109
Add error if yield is used outside a generator
nikice14cfaf
Add zend_do_suspend_if_generator calls
nikic1cec3f1
Add ZEND_SUSPEND_AND_RETURN_GENERATOR opcode
nikicca59e54
Add empty Generator class
nikic40b7533
Add some boilerplate code for Generator class
nikic46fa26a
Make generator functions return a Generator object
nikic5e763d9
Allocate execute_data using malloc for generators
nikic9ce9a7e
Add initial code for suspending execution
nikic2c5ecb4
Add dummy Iterator implementation
nikicececcbc
Allow calling zend_vm_gen from everywhere
nikicf627be5
Add support for executing a zend_execute_data
nikic1a99d1c
Add way to pass generator object to opcode handlers
nikicfafce58
Add YIELD opcode implementation
nikic5bb3a99
Implement return for generators
nikicd49d397
Close generator on return
nikiccbfa96c
Remove wrong dtor call
nikic39d3d5e
Add first real generator test
nikic247bb73
Add support for generator methods
nikic64a643a
Free loop variables
nikic9f52c5c
Fix generator creation when execute_data is not nested
nikicbcc7d97
Set EG(current_execute_data)
nikic4aab08b
Properly free resources when generator return value not used
nikicb770b22
Make the GOTO and SWITCH VMs work again
nikic3600914
Add support for $generator->send()
nikicad525c2
Allow to use yield without value
nikic12e9283
Fix segfault when send()ing to a closed generator
nikic72a91d0
Add $generator->close() method
nikicbc08c2c
Add support for yielding keys
nikic8790160
Add auto-increment keys
nikic0033a52
Allow throwing exceptions from generators
nikicee89e22
Allow yielding during function calls
nikic1477be9
Make $generator->send() return the current value
nikic6117f4c
Add cloning support for generators
nikic7b3bfa5
Improve backtraces from generators
nikicbf82f46
Properly handle yield during method calls
nikic40760ec
Fix cloning of generator methods
nikicf169b26
Fix backtraces and func_get_args()
nikicd939d2d
Add sceleton for yield* expression
nikic6233408
Fix thread safe build
nikic1d3f37d
Fix segfault in method test
nikic04e781f
Implement get_iterator
nikic14766e1
Pass zend_generator directly to Zend VM
nikicab75ed6
Disallow closing a generator during its execution
nikic5a9bddb
Forgot to git add two tests
nikic85f077c
Add support by yielding by-reference
nikicc9709bf
Remove asterix modifier (*) for generators
nikic612c249
Move a variable
nikic1f70a4c
Add some more tests
nikic8074863
Require parenthesis around yield expressions
nikicde80e3c
Remove reference restrictions from foreach
nikic94b2cca
Fix throwing of exceptions within a generator
nikic1340893
Throw error also for return occuring before yield
nikic99f93dd
Add T_YIELD in tokenizer_data.c
nikic268740d
Fix implementation of Iterator interface
nikicf4ce364
Merge remote-tracking branch 'php-src/master' into addGeneratorsSupport
nikicae71693
Support trivial finally in generators (no yield, no return)
nikic7195a5b
Forgot to add test
nikic05f1048
Drop Generator::close() method
nikic9003cd1
Fix zts build (typo)
nikic1823b16
Merge remote-tracking branch 'php-src/master' into addGeneratorsSupport
nikicf45a0f3
Disallow serialization and unserialization
nikic6517ed0
Merge remote-tracking branch 'php-src/master' into addGeneratorsSupport
nikic68c1e1c
Add dedicated opcode for returns from a generator
nikic7cdf636
Finally with return now works in generators too
nikic4d8edda
Run finally if generator is closed before finishing
nikicf53225a
Fix several issues and allow rewind only at/before first yield
nikicbd70d15
Remove implementation stubs for yield delegation
nikicd60e3c6
Merge remote-tracking branch 'php-src/master' into addGeneratorsSupport
nikiccc07038
Make sure that exception is thrown on rewind() after closing too
nikicbef7958
Fix segfault when traversing a by-ref generator twice
nikicdbc7809
Fix typos
nikicFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Fix segfault when send()ing to a closed generator
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit12e928314fb270db31adc361ac4993b4f0fe000a
There are no files selected for viewing
14 changes: 14 additions & 0 deletionsZend/tests/generators/send_after_close.phpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--TEST-- | ||
Calls to send() after close should do nothing | ||
--FILE-- | ||
<?php | ||
function *gen() { } | ||
$gen = gen(); | ||
$gen->send("Test"); | ||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |
5 changes: 5 additions & 0 deletionsZend/zend_generators.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.