Hi:
Further investigation on this topic suggest that this might be a
platform dependent issue.
My Traits code works fine under Linux, but not under OS X Snow Leopard.
As described the result i.e. $$ of a grammar rule does not survive
long enough.
Its altered/overwritten on the stack before the outer grammar rule can
use it.
Any thoughts what might be the problem here?
Does that seem to be a re2c issue, or might there still be problems
with my code?
Best regards
Stefan
PS: I would be grateful for a hint on how I can share this code using
git.
I followed the instructions for git on the wiki[1] but am not familiar
with git/github.
[1]http://wiki.php.net/vcs/svnfaq#git
On 27 Aug 2009, at 13:01, Stefan Marr wrote:
Hi internals:
I still have not solved this problem.
An alternative solution would be to introduce additional state into
the compiler globals. Are there any standards or common practices
for such things?
Thanks and best regards
Stefan
On 23 Aug 2009, at 22:47, Stefan Marr wrote:
Hi internals:
Currently, I try to port my Traits patch to the latest version of
trunk.
Thought about giving you people the chance to play with it again.
Unfortunately, I have some trouble with the parser.
Think, there must have changed quite something in its internal
working.
The last time I touched it, I had no problems handing around
pointers in $$.u.var,
but nowadays, it looks like it is overwritten before it can be used
by the other grammar rule.
The original idea was to construct as many data during the
compilation phase to avoid introducing a whole of a lot new opcodes.
But, I am grateful for all suggestion about alternative
implementation strategies.
For the problem at hand, here some code:
<code>
trait_adaptation_statement:
/* here I emit a opcode to add a new alias or precedence rule to a
class */
trait_precedence ';' { zend_add_trait_precedence(&$1 TSRMLS_CC); }
| trait_alias ';' { zend_add_trait_alias(&$1 TSRMLS_CC); }
;
trait_precedence:
/* This rule constructs a struct with the necessary data and should
return
a pointer to it in $$.u.var */
trait_method_reference_fully_qualified T_INSTEAD
trait_reference_list
{ zend_prepare_trait_precedence(&$$, &$1, &$3 TSRMLS_CC); }
;
trait_reference_list:
fully_qualified_class_name
{ zend_init_list(&$$.u.var, Z_STRVAL($1.u.constant) TSRMLS_CC); }
| trait_reference_list ',' fully_qualified_class_name
{ zend_add_to_list(&$1.u.var, Z_STRVAL($3.u.constant) TSRMLS_CC);
$$ = $1; }
;
trait_method_reference_fully_qualified:
fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING
{ zend_prepare_reference(&$$, &$1, &$3 TSRMLS_CC); }
;
</code>
The code is basically unchanged from
http://www.stefan-marr.de/traits/traits.patch
My problem starts already with
trait_method_reference_fully_qualified.
I am not able to get the struct which I assigned to $$.u.var in
trait_precedence.
From what XCode tells me, the memory location of $$ gets
overwritten before.
Think, it is on the stack somewhere and does not survive long
enough to be
available in trait_precedence.
Any thoughts on that?
Many thanks and best regards
Stefan
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
--
Stefan Marr
Software Languages Lab
Former Programming Technology Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://prog.vub.ac.be/~smarr
Phone: +32 2 629 3956
Fax: +32 2 629 3525
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php