Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40498 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13159 invoked from network); 13 Sep 2008 00:40:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Sep 2008 00:40:00 -0000 Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 69.16.228.148 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 69.16.228.148 unknown Linux 2.4/2.6 Received: from [69.16.228.148] ([69.16.228.148:51579] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 89/42-00143-FDB0BC84 for ; Fri, 12 Sep 2008 20:40:00 -0400 Received: from [83.228.56.37] (port=3149 helo=pc) by host.fmethod.com with esmtpa (Exim 4.69) (envelope-from ) id 1KeJB6-000101-Ql for internals@lists.php.net; Fri, 12 Sep 2008 19:39:57 -0500 Message-ID: <05D058F0F7764E45B272EBAEEC7EC499@pc> To: References: <48CABEEB.9070201@chiaraquartet.net> Date: Sat, 13 Sep 2008 03:39:42 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.fmethod.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fmethod.com Subject: Re: [PHP-DEV] [PATCH] allow T_INLINE_HTML before T_NAMESPACE From: sv_forums@fmethod.com ("Stan Vassilev | FM") Hi, I just figured a problem related to this. We have multiple namespaces per file so we can merge multiple files together. We have no way to break out to global space after a namespace, and even with this patch, no *code* can exist before a namespace. So this means we can only merge files with namespaces in them. Regards, Stan Vassilev > Hi, > > This is a simple patch that allows files like this: > > main.php: > > > > template example > > > > namespace my::template; > // stuff > ?> > > > to work without parse error. > > Greg > > P.S. this is the last outstanding namespace issue that I'm aware of > aside from the bracket wars, which is 100% philosophical, all the issues > fixed by my patches are functional problems in namespaces. > -------------------------------------------------------------------------------- > Index: Zend/zend_compile.c > =================================================================== > RCS file: /repository/ZendEngine2/zend_compile.c,v > retrieving revision 1.647.2.27.2.41.2.85 > diff -u -u -r1.647.2.27.2.41.2.85 zend_compile.c > --- Zend/zend_compile.c 29 Aug 2008 10:17:08 -0000 1.647.2.27.2.41.2.85 > +++ Zend/zend_compile.c 12 Sep 2008 19:07:42 -0000 > @@ -504,13 +504,17 @@ > } > > > -void zend_do_echo(const znode *arg TSRMLS_DC) > +void zend_do_echo(const znode *arg, int is_html TSRMLS_DC) > { > zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); > > opline->opcode = ZEND_ECHO; > opline->op1 = *arg; > - SET_UNUSED(opline->op2); > + if (is_html) { > + opline->op2.op_type = IS_CONST; /* tell zend_do_namespace that > INLINE_HTML is OK */ > + } else { > + SET_UNUSED(opline->op2); > + } > } > > void zend_do_abstract_method(const znode *function_name, znode *modifiers, > const znode *body TSRMLS_DC) > @@ -5040,10 +5044,11 @@ > char *lcname; > > if (CG(active_op_array)->last > 0) { > - /* ignore ZEND_EXT_STMT and ZEND_TICKS */ > + /* ignore ZEND_EXT_STMT and ZEND_TICKS and T_INLINE_HTML */ > int num = CG(active_op_array)->last; > while (num > 0 && > (CG(active_op_array)->opcodes[num-1].opcode == ZEND_EXT_STMT || > + (CG(active_op_array)->opcodes[num-1].opcode == ZEND_ECHO && > CG(active_op_array)->opcodes[num-1].op2.op_type == IS_CONST) || > CG(active_op_array)->opcodes[num-1].opcode == ZEND_TICKS)) { > --num; > } > Index: Zend/zend_compile.h > =================================================================== > RCS file: /repository/ZendEngine2/zend_compile.h,v > retrieving revision 1.316.2.8.2.12.2.33 > diff -u -u -r1.316.2.8.2.12.2.33 zend_compile.h > --- Zend/zend_compile.h 29 Aug 2008 18:12:47 -0000 1.316.2.8.2.12.2.33 > +++ Zend/zend_compile.h 12 Sep 2008 19:07:42 -0000 > @@ -385,7 +385,7 @@ > void fetch_string_offset(znode *result, const znode *parent, const znode > *offset TSRMLS_DC); > void zend_do_fetch_static_member(znode *result, znode *class_znode > TSRMLS_DC); > void zend_do_print(znode *result, const znode *arg TSRMLS_DC); > -void zend_do_echo(const znode *arg TSRMLS_DC); > +void zend_do_echo(const znode *arg, int is_html TSRMLS_DC); > typedef int (*unary_op_type)(zval *, zval * TSRMLS_DC); > typedef int (*binary_op_type)(zval *, zval *, zval * TSRMLS_DC); > ZEND_API unary_op_type get_unary_op(int opcode); > Index: Zend/zend_language_parser.y > =================================================================== > RCS file: /repository/ZendEngine2/zend_language_parser.y,v > retrieving revision 1.160.2.4.2.8.2.26 > diff -u -u -r1.160.2.4.2.8.2.26 zend_language_parser.y > --- Zend/zend_language_parser.y 29 Aug 2008 17:54:29 -0000 > 1.160.2.4.2.8.2.26 > +++ Zend/zend_language_parser.y 12 Sep 2008 19:07:42 -0000 > @@ -236,7 +236,7 @@ > | T_GLOBAL global_var_list ';' > | T_STATIC static_var_list ';' > | T_ECHO echo_expr_list ';' > - | T_INLINE_HTML { zend_do_echo(&$1 TSRMLS_CC); } > + | T_INLINE_HTML { zend_do_echo(&$1, 1 TSRMLS_CC); } > | expr ';' { zend_do_free(&$1 TSRMLS_CC); } > | T_UNSET '(' unset_variables ')' ';' > | T_FOREACH '(' variable T_AS > @@ -556,8 +556,8 @@ > ; > > echo_expr_list: > - echo_expr_list ',' expr { zend_do_echo(&$3 TSRMLS_CC); } > - | expr { zend_do_echo(&$1 TSRMLS_CC); } > + echo_expr_list ',' expr { zend_do_echo(&$3, 0 TSRMLS_CC); } > + | expr { zend_do_echo(&$1, 0 TSRMLS_CC); } > ; > > > Index: Zend/tests/ns_076.phpt > =================================================================== > RCS file: Zend/tests/ns_076.phpt > diff -N Zend/tests/ns_076.phpt > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ Zend/tests/ns_076.phpt 12 Sep 2008 19:07:42 -0000 > @@ -0,0 +1,26 @@ > +--TEST-- > +076: T_INLINE_HTML prior to namespace declaration > +--FILE-- > +hi there > + + > +namespace foo; > + > +class Test { > + static function f() { > + var_dump((binary)__NAMESPACE__); > + include __DIR__ . '/ns_069.inc'; > + var_dump((binary)__NAMESPACE__); > + } > +} > + > +Test::f(); > + > +?> > +===DONE=== > +--EXPECT-- > +hi there > +string(3) "foo" > +string(0) "" > +string(3) "foo" > +===DONE=== > Index: Zend/tests/ns_077.phpt > =================================================================== > RCS file: Zend/tests/ns_077.phpt > diff -N Zend/tests/ns_077.phpt > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ Zend/tests/ns_077.phpt 12 Sep 2008 19:07:42 -0000 > @@ -0,0 +1,21 @@ > +--TEST-- > +076: T_ECHO prior to namespace declaration > +--FILE-- > + +echo 'oops'; > +namespace foo; > + > +class Test { > + static function f() { > + var_dump((binary)__NAMESPACE__); > + include __DIR__ . '/ns_069.inc'; > + var_dump((binary)__NAMESPACE__); > + } > +} > + > +Test::f(); > + > +?> > +===DONE=== > +--EXPECTF-- > +Fatal error: Namespace declaration statement has to be the very first > statement in the script in %sns_077.php on line %d > \ No newline at end of file > > -------------------------------------------------------------------------------- > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php