]> granicus.if.org Git - php/commitdiff
Reimplemented support for namespaces in indexes id constant arrays (removed zval...
authorDmitry Stogov <dmitry@php.net>
Fri, 2 Nov 2007 10:11:42 +0000 (10:11 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 2 Nov 2007 10:11:42 +0000 (10:11 +0000)
Zend/zend.h
Zend/zend_compile.c
Zend/zend_execute_API.c

index d2d54a36d5f0e7512e860515d3a9b2e519f10528..5c869495c393c1684812f86f69142cb9edbf6d20 100644 (file)
@@ -298,7 +298,6 @@ struct _zval_struct {
        zend_uint refcount__gc;
        zend_uchar type;        /* active type */
        zend_uchar is_ref__gc;
-       zend_uchar idx_type;    /* type of element's index in constant array */
 };
 
 #define Z_REFCOUNT_PP(ppz)             Z_REFCOUNT_P(*(ppz))
index 2b97eb0de0c991d2c3276166fdc4d3a5cb462061..64520cdba20191c15cb58e7e14fc3851ddd3e7fb 100644 (file)
@@ -3643,8 +3643,12 @@ void zend_do_add_static_array_element(znode *result, znode *offset, znode *expr)
                        case IS_CONSTANT:
                                /* Ugly hack to denote that this value has a constant index */
                                Z_TYPE_P(element) |= IS_CONSTANT_INDEX;
-                               element->idx_type = Z_TYPE(offset->u.constant);
-                               /* break missing intentionally */
+                               Z_STRVAL(offset->u.constant) = erealloc(Z_STRVAL(offset->u.constant), Z_STRLEN(offset->u.constant)+3);
+                               Z_STRVAL(offset->u.constant)[Z_STRLEN(offset->u.constant)+1] = Z_TYPE(offset->u.constant);
+                               Z_STRVAL(offset->u.constant)[Z_STRLEN(offset->u.constant)+2] = 0;
+                               zend_symtable_update(result->u.constant.value.ht, Z_STRVAL(offset->u.constant), Z_STRLEN(offset->u.constant)+3, &element, sizeof(zval *), NULL);
+                               zval_dtor(&offset->u.constant);
+                               break;
                        case IS_STRING:
                                zend_symtable_update(result->u.constant.value.ht, offset->u.constant.value.str.val, offset->u.constant.value.str.len+1, &element, sizeof(zval *), NULL);
                                zval_dtor(&offset->u.constant);
index 5bddc4dcc552ae29341302d4be8abfee45a64f56..8993c1bf4e82b4e3a485603c7480ed713142e1ba 100644 (file)
@@ -517,34 +517,27 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco
                                zend_hash_move_forward(Z_ARRVAL_P(p));
                                continue;
                        }
-                       if (!zend_get_constant_ex(str_index, str_index_len-1, &const_value, scope, (*element)->idx_type TSRMLS_CC)) {
-                               if ((colon = memchr(str_index, ':', str_index_len-1)) && colon[1] == ':') {
+                       if (!zend_get_constant_ex(str_index, str_index_len-3, &const_value, scope, str_index[str_index_len-2] TSRMLS_CC)) {
+                               if ((colon = memchr(str_index, ':', str_index_len-3)) && colon[1] == ':') {
                                        zend_error(E_ERROR, "Undefined class constant '%s'", str_index);
                                }
                                zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",     str_index, str_index);
-                               zend_hash_move_forward(Z_ARRVAL_P(p));
-                               continue;
+                               ZVAL_STRINGL(&const_value, str_index, str_index_len-3, 1);
                        }
 
-                       if (const_value.type == IS_STRING && const_value.value.str.len == (int)str_index_len-1 &&
-                          !strncmp(const_value.value.str.val, str_index, str_index_len)) {
-                               /* constant value is the same as its name */
-                               zval_dtor(&const_value);
-                               zend_hash_move_forward(p->value.ht);
-                               continue;
+                       if (Z_REFCOUNT_PP(element) > 1) {
+                               ALLOC_ZVAL(new_val);
+                               *new_val = **element;
+                               zval_copy_ctor(new_val);
+                               Z_SET_REFCOUNT_P(new_val, 1);
+                               Z_UNSET_ISREF_P(new_val);
+
+                               /* preserve this bit for inheritance */
+                               Z_TYPE_PP(element) |= IS_CONSTANT_INDEX;
+                               zval_ptr_dtor(element);
+                               *element = new_val;
                        }
 
-                       ALLOC_ZVAL(new_val);
-                       *new_val = **element;
-                       zval_copy_ctor(new_val);
-                       Z_SET_REFCOUNT_P(new_val, 1);
-                       Z_UNSET_ISREF_P(new_val);
-
-                       /* preserve this bit for inheritance */
-                       Z_TYPE_PP(element) |= IS_CONSTANT_INDEX;
-                       zval_ptr_dtor(element);
-                       *element = new_val;
-
                        switch (Z_TYPE(const_value)) {
                                case IS_STRING:
                                        zend_symtable_update_current_key(Z_ARRVAL_P(p), const_value.value.str.val, const_value.value.str.len+1);