Fix static properties.

#
# There's only an errormessage missing which i'll wommit as soon as i find out
# how to do it best. But besides that damn message everything works now and all
# inheritance rules apply.
#
This commit is contained in:
Marcus Boerger 2003-09-03 16:13:40 +00:00
parent 804312c4a1
commit 1b39a5aa2c
4 changed files with 15 additions and 12 deletions

View File

@ -700,7 +700,6 @@ ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *class_type
if (!class_type->constants_updated) {
zend_hash_apply_with_argument(&class_type->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
zend_hash_apply_with_argument(class_type->static_members, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
class_type->constants_updated = 1;
}

View File

@ -1768,7 +1768,12 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro
mangle_property_name(&prot_name, &prot_name_length, "*", 1, child_info->name, child_info->name_length, ce->type & ZEND_INTERNAL_CLASS);
if (child_info->flags & ZEND_ACC_STATIC) {
zend_hash_del(ce->static_members, prot_name, prot_name_length+1);
zval **prop;
if (zend_hash_find(parent_ce->static_members, prot_name, prot_name_length+1, (void**)&prop) == SUCCESS) {
(*prop)->refcount++;
zend_hash_update(ce->static_members, child_info->name, child_info->name_length+1, (void**)prop, sizeof(zval*), NULL);
zend_hash_del(ce->static_members, prot_name, prot_name_length+1);
}
} else {
zend_hash_del(&ce->default_properties, prot_name, prot_name_length+1);
}
@ -1797,6 +1802,13 @@ ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, zend_class_entry
}
static void inherit_sttaic_prop(zval **p)
{
(*p)->refcount++;
(*p)->is_ref = 1;
}
void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce)
{
if ((ce->ce_flags & ZEND_ACC_INTERFACE)
@ -1813,10 +1825,9 @@ void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce)
/* Inherit properties */
zend_hash_merge(&ce->default_properties, &parent_ce->default_properties, (void (*)(void *)) zval_add_ref, NULL, sizeof(zval *), 0);
zend_hash_merge(ce->static_members, parent_ce->static_members, (void (*)(void *)) inherit_sttaic_prop, NULL, sizeof(zval *), 0);
zend_hash_merge_ex(&ce->properties_info, &parent_ce->properties_info, (copy_ctor_func_t) (ce->type & ZEND_INTERNAL_CLASS ? zend_duplicate_property_info_internal : zend_duplicate_property_info), sizeof(zend_property_info), (merge_checker_func_t) do_inherit_property_access_check, ce);
/* STATIC_MEMBERS_FIXME */
/* zend_hash_merge(ce->static_members, parent_ce->static_members, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0); */
zend_hash_merge(&ce->constants_table, &parent_ce->constants_table, (void (*)(void *)) zval_add_ref, NULL, sizeof(zval *), 0);
zend_hash_merge_ex(&ce->function_table, &parent_ce->function_table, (copy_ctor_func_t) do_inherit_method, sizeof(zend_function), (merge_checker_func_t) do_inherit_method_check, ce);
do_inherit_parent_constructor(ce);

View File

@ -722,7 +722,6 @@ static void zend_fetch_var_address(zend_op *opline, temp_variable *Ts, int type
FREE_OP(Ts, &opline->op1, free_op1);
break;
case ZEND_FETCH_STATIC:
zval_update_constant(retval, (void *) 1 TSRMLS_CC);
break;
}
}

View File

@ -726,12 +726,7 @@ zval **zend_std_get_static_property(zend_class_entry *ce, char *property_name, i
zend_error(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ce->name, property_name);
}
while (tmp_ce) {
if (zend_hash_quick_find(tmp_ce->static_members, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval)==SUCCESS) {
break;
}
tmp_ce = tmp_ce->parent;
}
zend_hash_quick_find(tmp_ce->static_members, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval);
if (!retval) {
if (silent) {
@ -741,7 +736,6 @@ zval **zend_std_get_static_property(zend_class_entry *ce, char *property_name, i
}
}
zval_update_constant(retval, (void *) 1 TSRMLS_CC);
return retval;
}