Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PHP-DEV] Labeled Breaks (not the G-word) [RSS Feed]

#1 Nov. 23, 2005 22:40:26

Sara G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Labeled Breaks (not the G-word)


http://libssh2.org/patches/labeled_break.diffA 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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#2 Nov. 28, 2005 08:19:09

Marcus B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Labeled Breaks (not the G-word)


Hello Sara,

sorry to jump in, i didn'T read the thread but i have more ideas.
From my point of view view should have the whole thing support any
target. So idefinitively want to call it goto and if it cannot be
goto i want to favor log_jump or long_goto or hey what about 'bad'.
Also can't we do goto as an operator? I would suggest one of '==>'
or '>>>' or '=>>'.

Just kidding. But the only way to drop this feature down seems to
be the bulshitting tactics that was used for other features like
the thing called ifsetor. Further more goto would only be for the
advantage of very skillfulled people. To everyone else it simply
would make the code bad n the sense of not understandabele,
unmaintainable and error prone.

best regards
marcus

p.s.: '=>>' would be a conflict.


Wednesday, November 23, 2005, 11:39:30 PM, you wrote:

>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




Best regards,
Marcus

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

  • Root
  • » PHP
  • » [PHP-DEV] Labeled Breaks (not the G-word) [RSS Feed]

Board footer

Moderator control

Enjoy the 23rd of April
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support