cvs: ZendEngine2 / zend_compile.c zend_constants.c zend_language_parser.y
| From: | Stanislav Malyshev | Date: | Sun, 15 Jun 2003 13:58:50 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c zend_constants.c zend_language_parser.y | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1369@lists.php.net to get a copy of this message | ||
stas Sun Jun 15 09:58:50 2003 EDT
Modified files:
/ZendEngine2 zend_compile.c zend_constants.c zend_language_parser.y
Log:
Fix bug #23384 - static class::constant constants should now
work in static & array expressions.
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.427 ZendEngine2/zend_compile.c:1.428
--- ZendEngine2/zend_compile.c:1.427 Tue Jun 10 16:03:24 2003
+++ ZendEngine2/zend_compile.c Sun Jun 15 09:58:50 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.427 2003/06/10 20:03:24 imajes Exp $ */
+/* $Id: zend_compile.c,v 1.428 2003/06/15 13:58:50 stas Exp $ */
#include "zend_language_parser.h"
#include "zend.h"
@@ -2641,6 +2641,7 @@
switch (mode) {
case ZEND_CT:
if (constant_container) {
+ zend_str_tolower(constant_container->u.constant.value.str.val,
constant_container->u.constant.value.str.len);
zend_do_fetch_class_name(NULL, constant_container, constant_name, 1 TSRMLS_CC);
*result = *constant_container;
} else {
Index: ZendEngine2/zend_constants.c
diff -u ZendEngine2/zend_constants.c:1.53 ZendEngine2/zend_constants.c:1.54
--- ZendEngine2/zend_constants.c:1.53 Tue Jun 10 16:03:24 2003
+++ ZendEngine2/zend_constants.c Sun Jun 15 09:58:50 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_constants.c,v 1.53 2003/06/10 20:03:24 imajes Exp $ */
+/* $Id: zend_constants.c,v 1.54 2003/06/15 13:58:50 stas Exp $ */
#include "zend.h"
#include "zend_constants.h"
@@ -212,11 +212,41 @@
zend_constant *c;
char *lookup_name;
int retval = 1;
+ char *colon;
+ if((colon = memchr(name, ':', name_len)) && colon[1] == ':') {
+ /* class constant */
+ zend_class_entry **ce;
+ int class_name_len = colon-name;
+ int const_name_len = name_len - class_name_len - 2;
+ char *constant_name = colon+2;
+ zval **ret_constant;
+
+ lookup_name = do_alloca(class_name_len+1);
+ zend_str_tolower_copy(lookup_name, name, class_name_len);
+ lookup_name[class_name_len] = '\0';
+ if(zend_lookup_class(lookup_name, class_name_len, &ce) != SUCCESS) {
+ retval = 0;
+ } else {
+ if (zend_hash_find(&((*ce)->constants_table), constant_name, const_name_len+1, (void **)
&ret_constant) != SUCCESS) {
+ retval = 0;
+ }
+
+ }
+
+ if(retval) {
+ *result = **ret_constant;
+ zval_copy_ctor(result);
+ }
+
+ free_alloca(lookup_name);
+ return retval;
+ }
+
if (zend_hash_find(EG(zend_constants), name, name_len+1, (void **) &c) == FAILURE) {
lookup_name = do_alloca(name_len+1);
zend_str_tolower_copy(lookup_name, name, name_len);
-
+
if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, (void **) &c)==SUCCESS) {
if ((c->flags & CONST_CS) && memcmp(c->name, name, name_len)!=0) {
retval=0;
Index: ZendEngine2/zend_language_parser.y
diff -u ZendEngine2/zend_language_parser.y:1.118 ZendEngine2/zend_language_parser.y:1.119
--- ZendEngine2/zend_language_parser.y:1.118 Tue Jun 10 16:03:25 2003
+++ ZendEngine2/zend_language_parser.y Sun Jun 15 09:58:50 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_language_parser.y,v 1.118 2003/06/10 20:03:25 imajes Exp $ */
+/* $Id: zend_language_parser.y,v 1.119 2003/06/15 13:58:50 stas Exp $ */
/*
* LALR shift/reduce conflicts and how they are resolved:
@@ -658,7 +658,7 @@
| '+' const_scalar { $$ = $2; }
| '-' const_scalar { zval minus_one; minus_one.type = IS_LONG; minus_one.value.lval =
-1; mul_function(&$2.u.constant, &$2.u.constant, &minus_one TSRMLS_CC); $$ = $2; }
| T_ARRAY '(' static_array_pair_list ')' { $$ = $3; $$.u.constant.type =
IS_CONSTANT_ARRAY; }
- | class_constant { /* FIXME */ }
+ | static_class_constant { $$ = $1; }
;
static_scalar: /* compile-time evaluated scalars */
@@ -667,7 +667,11 @@
| '+' static_scalar { $$ = $2; }
| '-' static_scalar { zval minus_one; minus_one.type = IS_LONG; minus_one.value.lval =
-1; mul_function(&$2.u.constant, &$2.u.constant, &minus_one TSRMLS_CC); $$ = $2; }
| T_ARRAY '(' static_array_pair_list ')' { $$ = $3; $$.u.constant.type =
IS_CONSTANT_ARRAY; }
- | class_constant { /* FIXME */ }
+ | static_class_constant { $$ = $1; }
+;
+
+static_class_constant:
+ T_STRING T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3,
ZEND_CT TSRMLS_CC); }
;
scalar: