Nikita Popov
3600914ced
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.
2012-05-29 17:34:33 +02:00
Nikita Popov
b770b221e0
Make the GOTO and SWITCH VMs work again
2012-05-29 02:31:56 +02:00
Nikita Popov
4aab08b64c
Properly free resources when generator return value not used
...
To keep things clean two new functions are introduced:
zend_clean_and_cache_symbol_table(HashTable *symbol_table)
zend_free_compiled_variables(zval ***CVs, int num)
2012-05-28 06:43:18 +02:00
Nikita Popov
bcc7d976f3
Set EG(current_execute_data)
...
This fixes several issues. In particular it makes method generators work
properly and also allows generators using a symbol table.
2012-05-28 06:06:30 +02:00
Nikita Popov
9f52c5c226
Fix generator creation when execute_data is not nested
...
This happens primarily when the generator is invoked from some internal
place like a dynamic function call.
2012-05-27 22:48:21 +02:00
Nikita Popov
64a643a4e3
Free loop variables
...
If the generator is closed before it has finished running, it may happen
that some FREE or SWITCH_FREE opcodes haven't been executed and memory is
leaked.
This fixes it by walking the brk_cont_array and manually freeing the
variables.
2012-05-27 17:14:20 +02:00
Nikita Popov
247bb737d5
Add support for generator methods
2012-05-27 03:50:31 +02:00
Nikita Popov
39d3d5ec13
Add first real generator test
...
The test implements an xrange() function (the generator version of range()).
2012-05-27 00:50:27 +02:00
Nikita Popov
cbfa96cad5
Remove wrong dtor call
2012-05-27 00:25:12 +02:00
Nikita Popov
d49d3971e6
Close generator on return
2012-05-26 23:59:22 +02:00
Nikita Popov
5bb3a995c2
Implement return for generators
...
For generators ZEND_RETURN directly calls ZEND_VM_RETURN(), thus passing
execution back to the caller (zend_generator_resume).
This commit also adds a check that only return; is used in generators and
not return $value;.
2012-05-26 23:07:40 +02:00
Nikita Popov
fafce58683
Add YIELD opcode implementation
2012-05-26 22:44:53 +02:00
Nikita Popov
1a99d1c887
Add way to pass generator object to opcode handlers
...
The generator zval is put into the return_value_ptr_ptr.
2012-05-26 19:40:29 +02:00
Nikita Popov
f627be5254
Add support for executing a zend_execute_data
...
This adds another function execute_ex(), which accepts a zend_execute_data
struct to run (contrary to execute(), which accepts a zend_op_array from
which it initialized the execute_data).
This needs a bit more cleanup.
2012-05-26 17:53:13 +02:00
Nikita Popov
ececcbce0e
Allow calling zend_vm_gen from everywhere
...
Before one could only call it with cwd=Zend.
2012-05-23 20:40:21 +02:00
Nikita Popov
2c5ecb4fea
Add dummy Iterator implementation
...
This simply adds dummy rewind/valid/current/key/next methods to Generator.
2012-05-23 16:44:58 +02:00
Nikita Popov
9ce9a7e639
Add initial code for suspending execution
...
This is just some initial code, which is still quite broken (and needs to be
moved so it can be reused.)
2012-05-23 14:20:25 +02:00
Nikita Popov
5e763d9420
Allocate execute_data using malloc for generators
...
Generators need to switch the execute_data very often. If the execute_data
is allocated on the VM stack this operation would require to always copy
the structure (which is quite large). That's why the execution context is
allocated on the heap instead (only for generators obviously).
2012-05-22 23:17:59 +02:00
Nikita Popov
46fa26ab85
Make generator functions return a Generator object
...
Right now generator functions simply immediately return a new Generator
object (no suspension yet).
2012-05-20 14:45:01 +02:00
Nikita Popov
40b7533576
Add some boilerplate code for Generator class
...
The Generator class now uses a zend_generator struct, so it'll be able to
store additional info.
This commit also ensures that Generator cannot be directly instantiated
and extended. The error tests are now in a separate folder from the
(yet-to-come) functional tests.
2012-05-20 14:19:16 +02:00
Nikita Popov
ca59e5464d
Add empty Generator class
2012-05-20 00:03:27 +02:00
Nikita Popov
1cec3f12cc
Add ZEND_SUSPEND_AND_RETURN_GENERATOR opcode
...
If the function is a generator this opcode will be invoked right after
receiving the function arguments.
The current implementation is just a dummy.
2012-05-19 23:19:21 +02:00
Nikita Popov
e14cfafcbf
Add zend_do_suspend_if_generator calls
...
The execution of generator functions will be suspended right after the
arguments were RECVed. This will be done in zend_do_suspend_if_generator.
2012-05-19 20:19:45 +02:00
Nikita Popov
fd2a109f86
Add error if yield is used outside a generator
...
The yield statement can only be used in generator functions, which are
marked with an asterix.
2012-05-19 18:49:27 +02:00
Nikita Popov
9b51a3b96d
Minor code cleanup
...
The block for the foreach separator was nested unnecessary. This commit
simply removes that nesting.
2012-05-19 14:21:49 +02:00
Nikita Popov
252f623464
Add flag for generator functions
...
Generator functions have to specify the * (asterix) modifier after the
function keyword. If they do so the ZEND_ACC_GENERATOR flag is added to
the fn_flags.
2012-05-19 14:18:20 +02:00
Nikita Popov
9b101ac8b3
Add T_YIELD "yield" keyword
2012-05-15 18:30:48 +02:00
Xinchen Hui
6b16f7cd69
Merge branch 'PHP-5.4'
2012-05-03 22:40:51 +08:00
Xinchen Hui
72f19e9a8b
Fixed bug #61922 (ZTS build doesn't accept zend.script_encoding config)
2012-05-03 22:39:53 +08:00
Xinchen Hui
e022bfe34a
Merge remote-tracking branch 'origin/PHP-5.4'
...
* origin/PHP-5.4:
Fixed test bug #61892
2012-05-03 20:00:10 +08:00
Xinchen Hui
d74d88fbb9
Fixed test bug #61892
2012-05-03 19:56:49 +08:00
Xinchen Hui
604d11ee6c
Merge remote-tracking branch 'origin/PHP-5.4'
2012-05-03 18:41:45 +08:00
Xinchen Hui
75d23f5714
Merge remote-tracking branch 'origin/PHP-5.3' into PHP-5.4
...
* origin/PHP-5.3:
Fix typo
2012-05-03 18:40:57 +08:00
Xinchen Hui
bbf8a50281
Fix typo
...
picked form pull request of reeze.xia@gmail.com
2012-05-03 18:39:03 +08:00
Felipe Pena
1c2c620a58
- Regenerated files
2012-04-30 15:57:09 -03:00
Felipe Pena
4deb0f1a0a
- Regenerated files
2012-04-30 15:57:00 -03:00
Felipe Pena
45ef3c759e
Merge branch 'PHP-5.4'
...
* PHP-5.4:
- Fixed Windows build
2012-04-30 15:56:15 -03:00
Felipe Pena
79961dccab
- Fixed Windows build
2012-04-30 15:55:57 -03:00
Felipe Pena
1622843162
- Regenerated files
2012-04-30 10:35:28 -03:00
Felipe Pena
ea23192910
- Regenerated files
2012-04-30 10:35:11 -03:00
Felipe Pena
73b6150992
Merge branch 'PHP-5.4'
...
* PHP-5.4:
- Changed last commit to use VK_ESCAPE on Windows
2012-04-30 10:31:59 -03:00
Felipe Pena
3120387617
- Changed last commit to use VK_ESCAPE on Windows
2012-04-30 10:31:49 -03:00
Felipe Pena
bbe9eec9a2
Merge branch 'PHP-5.4'
...
* PHP-5.4:
- Fixed bug #61827 (incorrect \e processing on Windows) patch by: ab@php.net
2012-04-29 19:36:10 -03:00
Felipe Pena
cc5b995c78
- Fixed bug #61827 (incorrect \e processing on Windows) patch by: ab@php.net
2012-04-29 19:35:52 -03:00
Xinchen Hui
6b9e88d9e6
Merge branch 'PHP-5.4'
...
* PHP-5.4:
Fixed bug #61761 ('Overriding' a private static method with a different signature causes crash)
2012-04-18 18:15:29 +08:00
Xinchen Hui
da6465a268
Fixed bug #61761 ('Overriding' a private static method with a different signature causes crash)
2012-04-18 18:13:27 +08:00
Xinchen Hui
565892d4c0
Implement const array/string dereference
...
RFC:https://wiki.php.net/rfc/constdereference
2012-04-17 10:06:17 +08:00
Stanislav Malyshev
363797e9af
Merge branch 'PHP-5.4'
...
* PHP-5.4:
Copy default properties of internal classes for different threads
2012-04-11 19:24:11 -07:00
Johannes Schlüter
82c05eeda9
Copy default properties of internal classes for different threads
2012-04-11 19:21:41 -07:00
Nikita Popov
b233de098d
Fix bug #61681 : Malformed grammar
...
Generate T_STRING_VARNAME only if it actually is one. This is only the case
for "${varname}" and "${varname[offset]}" so we can just add a check for
} or [ after the LABEL.
2012-04-09 18:26:38 +02:00