Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45435 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89810 invoked from network); 30 Aug 2009 17:04:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Aug 2009 17:04:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@stefan-marr.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@stefan-marr.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain stefan-marr.de from 85.88.12.247 cause and error) X-PHP-List-Original-Sender: php@stefan-marr.de X-Host-Fingerprint: 85.88.12.247 toolslave.net Received: from [85.88.12.247] ([85.88.12.247:56671] helo=uhweb12247.united-hoster.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FC/C4-56114-D11BA9A4 for ; Sun, 30 Aug 2009 13:04:30 -0400 Received: from cust194-138.dsl.versadsl.be ([62.166.194.138] helo=[192.168.0.17]) by uhweb12247.united-hoster.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1Mhnp7-0001T0-1f for internals@lists.php.net; Sun, 30 Aug 2009 19:04:24 +0200 Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Mime-Version: 1.0 (Apple Message framework v1074) In-Reply-To: Date: Sun, 30 Aug 2009 19:03:57 +0200 Content-Transfer-Encoding: 7bit Message-ID: References: To: internals@lists.php.net X-Mailer: Apple Mail (2.1074) Subject: Re: [PHP-DEV] How to hand along data in PHP's parser? From: php@stefan-marr.de (Stefan Marr) 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: >> >> >> 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); } >> ; >> >> >> 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