version 1.1.1.2, 2012/05/29 12:34:36
|
version 1.1.1.3, 2013/07/22 01:32:16
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Zend Engine | |
| Zend Engine | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) | | | Copyright (c) 1998-2013 Zend Technologies Ltd. (http://www.zend.com) | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 2.00 of the Zend license, | |
| This source file is subject to version 2.00 of the Zend license, | |
| that is bundled with this package in the file LICENSE, and is | |
| that is bundled with this package in the file LICENSE, and is | |
Line 35
|
Line 35
|
#define Z_OBJ_P(zval_p) \ |
#define Z_OBJ_P(zval_p) \ |
((zend_object*)(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zval_p)].bucket.obj.object)) |
((zend_object*)(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zval_p)].bucket.obj.object)) |
|
|
|
#define Z_OBJ_PROTECT_RECURSION(zval_p) \ |
|
do { \ |
|
if (EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zval_p)].apply_count++ >= 3) { \ |
|
zend_error(E_ERROR, "Nesting level too deep - recursive dependency?"); \ |
|
} \ |
|
} while (0) |
|
|
|
|
|
#define Z_OBJ_UNPROTECT_RECURSION(zval_p) \ |
|
EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zval_p)].apply_count-- |
|
|
/* |
/* |
__X accessors explanation: |
__X accessors explanation: |
|
|
Line 66 ZEND_API void rebuild_object_properties(zend_object *z
|
Line 77 ZEND_API void rebuild_object_properties(zend_object *z
|
zend_hash_get_current_data_ex(&ce->properties_info, (void**)&prop_info, &pos) == SUCCESS; |
zend_hash_get_current_data_ex(&ce->properties_info, (void**)&prop_info, &pos) == SUCCESS; |
zend_hash_move_forward_ex(&ce->properties_info, &pos)) { |
zend_hash_move_forward_ex(&ce->properties_info, &pos)) { |
if (/*prop_info->ce == ce &&*/ |
if (/*prop_info->ce == ce &&*/ |
(prop_info->flags & ZEND_ACC_STATIC) == 0 && | (prop_info->flags & ZEND_ACC_STATIC) == 0 && |
prop_info->offset >= 0 && |
prop_info->offset >= 0 && |
zobj->properties_table[prop_info->offset]) { |
zobj->properties_table[prop_info->offset]) { |
zend_hash_quick_add(zobj->properties, prop_info->name, prop_info->name_length+1, prop_info->h, (void**)&zobj->properties_table[prop_info->offset], sizeof(zval*), (void**)&zobj->properties_table[prop_info->offset]); |
zend_hash_quick_add(zobj->properties, prop_info->name, prop_info->name_length+1, prop_info->h, (void**)&zobj->properties_table[prop_info->offset], sizeof(zval*), (void**)&zobj->properties_table[prop_info->offset]); |
} | } |
} |
} |
while (ce->parent && ce->parent->default_properties_count) { |
while (ce->parent && ce->parent->default_properties_count) { |
ce = ce->parent; |
ce = ce->parent; |
Line 78 ZEND_API void rebuild_object_properties(zend_object *z
|
Line 89 ZEND_API void rebuild_object_properties(zend_object *z
|
zend_hash_get_current_data_ex(&ce->properties_info, (void**)&prop_info, &pos) == SUCCESS; |
zend_hash_get_current_data_ex(&ce->properties_info, (void**)&prop_info, &pos) == SUCCESS; |
zend_hash_move_forward_ex(&ce->properties_info, &pos)) { |
zend_hash_move_forward_ex(&ce->properties_info, &pos)) { |
if (prop_info->ce == ce && |
if (prop_info->ce == ce && |
(prop_info->flags & ZEND_ACC_STATIC) == 0 && | (prop_info->flags & ZEND_ACC_STATIC) == 0 && |
(prop_info->flags & ZEND_ACC_PRIVATE) != 0 && | (prop_info->flags & ZEND_ACC_PRIVATE) != 0 && |
prop_info->offset >= 0 && |
prop_info->offset >= 0 && |
zobj->properties_table[prop_info->offset]) { |
zobj->properties_table[prop_info->offset]) { |
zend_hash_quick_add(zobj->properties, prop_info->name, prop_info->name_length+1, prop_info->h, (void**)&zobj->properties_table[prop_info->offset], sizeof(zval*), (void**)&zobj->properties_table[prop_info->offset]); |
zend_hash_quick_add(zobj->properties, prop_info->name, prop_info->name_length+1, prop_info->h, (void**)&zobj->properties_table[prop_info->offset], sizeof(zval*), (void**)&zobj->properties_table[prop_info->offset]); |
} | } |
} |
} |
} |
} |
} |
} |
Line 382 static int zend_get_property_guard(zend_object *zobj,
|
Line 393 static int zend_get_property_guard(zend_object *zobj,
|
info.name = Z_STRVAL_P(member); |
info.name = Z_STRVAL_P(member); |
info.name_length = Z_STRLEN_P(member); |
info.name_length = Z_STRLEN_P(member); |
info.h = zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1); |
info.h = zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1); |
|
} else if(property_info->name[0] == '\0'){ |
|
const char *class_name = NULL, *prop_name = NULL; |
|
zend_unmangle_property_name(property_info->name, property_info->name_length, &class_name, &prop_name); |
|
if(class_name) { |
|
/* use unmangled name for protected properties */ |
|
info.name = prop_name; |
|
info.name_length = strlen(prop_name); |
|
info.h = zend_get_hash_value(info.name, info.name_length+1); |
|
property_info = &info; |
|
} |
} |
} |
if (!zobj->guards) { |
if (!zobj->guards) { |
ALLOC_HASHTABLE(zobj->guards); |
ALLOC_HASHTABLE(zobj->guards); |
Line 424 zval *zend_std_read_property(zval *object, zval *membe
|
Line 445 zval *zend_std_read_property(zval *object, zval *membe
|
#endif |
#endif |
|
|
/* make zend_get_property_info silent if we have getter - we may want to use it */ |
/* make zend_get_property_info silent if we have getter - we may want to use it */ |
property_info = zend_get_property_info_quick(zobj->ce, member, (zobj->ce->__get != NULL), key TSRMLS_CC); | property_info = zend_get_property_info_quick(zobj->ce, member, silent || (zobj->ce->__get != NULL), key TSRMLS_CC); |
|
|
if (UNEXPECTED(!property_info) || |
if (UNEXPECTED(!property_info) || |
((EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) && |
((EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) && |
Line 539 ZEND_API void zend_std_write_property(zval *object, zv
|
Line 560 ZEND_API void zend_std_write_property(zval *object, zv
|
(*variable_ptr)->value = value->value; |
(*variable_ptr)->value = value->value; |
if (Z_REFCOUNT_P(value) > 0) { |
if (Z_REFCOUNT_P(value) > 0) { |
zval_copy_ctor(*variable_ptr); |
zval_copy_ctor(*variable_ptr); |
|
} else { |
|
efree(value); |
} |
} |
zval_dtor(&garbage); |
zval_dtor(&garbage); |
} else { |
} else { |
Line 783 static void zend_std_unset_property(zval *object, zval
|
Line 806 static void zend_std_unset_property(zval *object, zval
|
property_info = zend_get_property_info_quick(zobj->ce, member, (zobj->ce->__unset != NULL), key TSRMLS_CC); |
property_info = zend_get_property_info_quick(zobj->ce, member, (zobj->ce->__unset != NULL), key TSRMLS_CC); |
|
|
if (EXPECTED(property_info != NULL) && |
if (EXPECTED(property_info != NULL) && |
EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) && | EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) && |
!zobj->properties && |
!zobj->properties && |
property_info->offset >= 0 && |
property_info->offset >= 0 && |
EXPECTED(zobj->properties_table[property_info->offset] != NULL)) { |
EXPECTED(zobj->properties_table[property_info->offset] != NULL)) { |
Line 815 static void zend_std_unset_property(zval *object, zval
|
Line 838 static void zend_std_unset_property(zval *object, zval
|
} |
} |
} |
} |
} |
} |
} else if (EXPECTED(property_info != NULL) && | } else if (EXPECTED(property_info != NULL) && |
EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) && | EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) && |
property_info->offset >= 0) { |
property_info->offset >= 0) { |
zobj->properties_table[property_info->offset] = NULL; |
zobj->properties_table[property_info->offset] = NULL; |
} |
} |
Line 960 ZEND_API int zend_check_protected(zend_class_entry *ce
|
Line 983 ZEND_API int zend_check_protected(zend_class_entry *ce
|
} |
} |
/* }}} */ |
/* }}} */ |
|
|
static inline zend_class_entry * zend_get_function_root_class(zend_function *fbc) /* {{{ */ |
|
{ |
|
return fbc->common.prototype ? fbc->common.prototype->common.scope : fbc->common.scope; |
|
} |
|
/* }}} */ |
|
|
|
static inline union _zend_function *zend_get_user_call_function(zend_class_entry *ce, const char *method_name, int method_len) /* {{{ */ |
static inline union _zend_function *zend_get_user_call_function(zend_class_entry *ce, const char *method_name, int method_len) /* {{{ */ |
{ |
{ |
zend_internal_function *call_user_call = emalloc(sizeof(zend_internal_function)); |
zend_internal_function *call_user_call = emalloc(sizeof(zend_internal_function)); |
Line 1143 ZEND_API zend_function *zend_std_get_static_method(zen
|
Line 1160 ZEND_API zend_function *zend_std_get_static_method(zen
|
zend_str_tolower_copy(lc_function_name, function_name_strval, function_name_strlen); |
zend_str_tolower_copy(lc_function_name, function_name_strval, function_name_strlen); |
hash_value = zend_hash_func(lc_function_name, function_name_strlen+1); |
hash_value = zend_hash_func(lc_function_name, function_name_strlen+1); |
} |
} |
| |
if (function_name_strlen == ce->name_length && ce->constructor) { |
if (function_name_strlen == ce->name_length && ce->constructor) { |
lc_class_name = zend_str_tolower_dup(ce->name, ce->name_length); |
lc_class_name = zend_str_tolower_dup(ce->name, ce->name_length); |
/* Only change the method to the constructor if the constructor isn't called __construct |
/* Only change the method to the constructor if the constructor isn't called __construct |
Line 1178 ZEND_API zend_function *zend_std_get_static_method(zen
|
Line 1195 ZEND_API zend_function *zend_std_get_static_method(zen
|
if (UNEXPECTED(!(fbc->common.fn_flags & ZEND_ACC_STATIC))) { |
if (UNEXPECTED(!(fbc->common.fn_flags & ZEND_ACC_STATIC))) { |
zend_error_noreturn(E_ERROR, "Cannot call non static method %s::%s() without object", ZEND_FN_SCOPE_NAME(fbc), fbc->common.function_name); |
zend_error_noreturn(E_ERROR, "Cannot call non static method %s::%s() without object", ZEND_FN_SCOPE_NAME(fbc), fbc->common.function_name); |
} |
} |
#endif | #endif |
if (fbc->op_array.fn_flags & ZEND_ACC_PUBLIC) { |
if (fbc->op_array.fn_flags & ZEND_ACC_PUBLIC) { |
/* No further checks necessary, most common case */ |
/* No further checks necessary, most common case */ |
} else if (fbc->op_array.fn_flags & ZEND_ACC_PRIVATE) { |
} else if (fbc->op_array.fn_flags & ZEND_ACC_PRIVATE) { |
Line 1220 ZEND_API zval **zend_std_get_static_property(zend_clas
|
Line 1237 ZEND_API zval **zend_std_get_static_property(zend_clas
|
{ |
{ |
zend_property_info *property_info; |
zend_property_info *property_info; |
ulong hash_value; |
ulong hash_value; |
| |
if (UNEXPECTED(!key) || |
if (UNEXPECTED(!key) || |
(property_info = CACHED_POLYMORPHIC_PTR(key->cache_slot, ce)) == NULL) { |
(property_info = CACHED_POLYMORPHIC_PTR(key->cache_slot, ce)) == NULL) { |
if (EXPECTED(key != NULL)) { |
if (EXPECTED(key != NULL)) { |
Line 1261 ZEND_API zval **zend_std_get_static_property(zend_clas
|
Line 1278 ZEND_API zval **zend_std_get_static_property(zend_clas
|
} |
} |
} |
} |
|
|
|
if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL) || |
|
UNEXPECTED(CE_STATIC_MEMBERS(ce)[property_info->offset] == NULL)) { |
|
if (!silent) { |
|
zend_error_noreturn(E_ERROR, "Access to undeclared static property: %s::$%s", ce->name, property_name); |
|
} |
|
return NULL; |
|
} |
|
|
return &CE_STATIC_MEMBERS(ce)[property_info->offset]; |
return &CE_STATIC_MEMBERS(ce)[property_info->offset]; |
} |
} |
/* }}} */ |
/* }}} */ |
Line 1323 static int zend_std_compare_objects(zval *o1, zval *o2
|
Line 1348 static int zend_std_compare_objects(zval *o1, zval *o2
|
} |
} |
if (!zobj1->properties && !zobj2->properties) { |
if (!zobj1->properties && !zobj2->properties) { |
int i; |
int i; |
|
|
|
Z_OBJ_PROTECT_RECURSION(o1); |
|
Z_OBJ_PROTECT_RECURSION(o2); |
for (i = 0; i < zobj1->ce->default_properties_count; i++) { |
for (i = 0; i < zobj1->ce->default_properties_count; i++) { |
if (zobj1->properties_table[i]) { |
if (zobj1->properties_table[i]) { |
if (zobj2->properties_table[i]) { |
if (zobj2->properties_table[i]) { |
zval result; |
zval result; |
|
|
if (compare_function(&result, zobj1->properties_table[i], zobj2->properties_table[i] TSRMLS_CC)==FAILURE) { |
if (compare_function(&result, zobj1->properties_table[i], zobj2->properties_table[i] TSRMLS_CC)==FAILURE) { |
|
Z_OBJ_UNPROTECT_RECURSION(o1); |
|
Z_OBJ_UNPROTECT_RECURSION(o2); |
return 1; |
return 1; |
} |
} |
if (Z_LVAL(result) != 0) { |
if (Z_LVAL(result) != 0) { |
|
Z_OBJ_UNPROTECT_RECURSION(o1); |
|
Z_OBJ_UNPROTECT_RECURSION(o2); |
return Z_LVAL(result); |
return Z_LVAL(result); |
} |
} |
} else { |
} else { |
|
Z_OBJ_UNPROTECT_RECURSION(o1); |
|
Z_OBJ_UNPROTECT_RECURSION(o2); |
return 1; |
return 1; |
} |
} |
} else { |
} else { |
if (zobj2->properties_table[i]) { |
if (zobj2->properties_table[i]) { |
|
Z_OBJ_UNPROTECT_RECURSION(o1); |
|
Z_OBJ_UNPROTECT_RECURSION(o2); |
return 1; |
return 1; |
} else { |
} else { |
|
Z_OBJ_UNPROTECT_RECURSION(o1); |
|
Z_OBJ_UNPROTECT_RECURSION(o2); |
return 0; |
return 0; |
} |
} |
} |
} |
} |
} |
|
Z_OBJ_UNPROTECT_RECURSION(o1); |
|
Z_OBJ_UNPROTECT_RECURSION(o2); |
return 0; |
return 0; |
} else { |
} else { |
if (!zobj1->properties) { |
if (!zobj1->properties) { |
Line 1496 ZEND_API int zend_std_cast_object_tostring(zval *reado
|
Line 1536 ZEND_API int zend_std_cast_object_tostring(zval *reado
|
if (retval) { |
if (retval) { |
zval_ptr_dtor(&retval); |
zval_ptr_dtor(&retval); |
} |
} |
|
EG(exception) = NULL; |
zend_error_noreturn(E_ERROR, "Method %s::__toString() must not throw an exception", ce->name); |
zend_error_noreturn(E_ERROR, "Method %s::__toString() must not throw an exception", ce->name); |
return FAILURE; |
return FAILURE; |
} |
} |