Labeled Breaks (not the G-word)
| From: | Sara Golemon | Date: | Wed, 23 Nov 2005 22:39:30 +0000 |
| Subject: | Labeled Breaks (not the G-word) | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-20277@lists.php.net to get a copy of this message | ||
http://libssh2.org/patches/labeled_break.diff
A few notes about the implementation:
* The parser is modified slightly to catch T_BREAK T_LNUMBER ';' and T_BREAK
T_STRING ';' specifically. This is in-line with the decision to remove the
ability to jump to variable targets. e.g.
break $foo; will result in an
E_PARSE.
* current break container is moved from op1.u.opline_num to extended_value
(This means updating continue; as well)
* op1 is used to store the label's name until pass_two(), at that point it's
converted to a jmp_addr. Non-labeled breaks leave op1 unused and jmp_addr
explicitly set to NULL
* zend_brk opcode handler updated to use op1->u.jmp_addr if available
(labeled breaks), or el->brk (numbered breaks) if not. zend_brk and
zend_cont both updated per current break container change above.
* Labeled breaks must target the same break container or higher within the
same op_array, and must only jump "forward" in execution. These checks are
handled in pass_two() which is the earliest point at which all labeled are
declared.
* Label hash is only allocated/initialized if labels are declared.
Known Issues:
* When an error is thrown from pass_two(), the error message states it's in
Unknown on line 0. Gotta find a better way to handle that....
* This adds an element to zend_op_array so be sure to either make clean or
at least touch Zend/*.c after applying it otherwise you'll be in segfault
country.
-Sara