ZEND_INI_BEGIN()
ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting)
- STD_ZEND_INI_BOOLEAN("zend.ze1_compatibility_mode", "0", ZEND_INI_ALL, OnUpdateBool, ze1_compatibility_mode, zend_executor_globals, executor_globals)
#ifdef ZEND_MULTIBYTE
STD_ZEND_INI_BOOLEAN("detect_unicode", "1", ZEND_INI_ALL, OnUpdateBool, detect_unicode, zend_compiler_globals, compiler_globals)
#endif
case IS_OBJECT:
{
TSRMLS_FETCH();
-#if 0
+
/* Standard PHP objects */
if (Z_OBJ_HT_P(expr) == &std_object_handlers || !Z_OBJ_HT_P(expr)->cast_object) {
- if (zend_std_cast_object_tostring(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
+ if (zend_std_cast_object_tostring(expr, expr_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
break;
}
zend_error(E_NOTICE, "Object of class %s could not be converted to string", Z_OBJCE_P(expr)->name);
- }
-#endif
- if (Z_OBJ_HANDLER_P(expr, cast_object)) {
- if(Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
- break;
- }
} else {
if(Z_OBJ_HANDLER_P(expr, get)) {
zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC);
# define zend_error_noreturn zend_error
#endif
-
/*
* zval
*/
char type;
char *name;
zend_uint name_length;
- struct _zend_class_entry *parent;
+ struct _zend_class_entry *parent;
int refcount;
zend_bool constants_updated;
zend_uint ce_flags;
union _zend_function *__unset;
union _zend_function *__isset;
union _zend_function *__call;
+ union _zend_function *__tostring;
union _zend_function *serialize_func;
union _zend_function *unserialize_func;
/* handlers */
zend_object_value (*create_object)(zend_class_entry *class_type TSRMLS_DC);
- zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object TSRMLS_DC);
+ zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type TSRMLS_DC); /* a class implements this interface */
/* serializer callbacks */
zend_uint line_end;
char *doc_comment;
zend_uint doc_comment_len;
-
+
struct _zend_module_entry *module;
};
char *(*getenv_function)(char *name, size_t name_len TSRMLS_DC);
} zend_utility_functions;
-
+
typedef struct _zend_utility_values {
char *import_use_extension;
uint import_use_extension_length;
#define OE_IS_OBJECT (1<<1)
#define OE_IS_METHOD (1<<2)
-
int zend_startup(zend_utility_functions *utility_functions, char **extensions, int start_builtin_functions);
void zend_shutdown(TSRMLS_D);
void zend_register_standard_ini_entries(TSRMLS_D);
#define INIT_PZVAL(z) \
(z)->refcount = 1; \
- (z)->is_ref = 0;
+ (z)->is_ref = 0;
#define INIT_ZVAL(z) z = zval_used_for_init;
while (param_count-->0) {
zval **value = (zval**)(p-arg_count);
- if (EG(ze1_compatibility_mode) && Z_TYPE_PP(value) == IS_OBJECT) {
- zval *value_ptr;
- char *class_name;
- zend_uint class_name_len;
- int dup;
-
- dup = zend_get_object_classname(*value, &class_name, &class_name_len TSRMLS_CC);
-
- ALLOC_ZVAL(value_ptr);
- *value_ptr = **value;
- INIT_PZVAL(value_ptr);
- zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
- if(!dup) {
- efree(class_name);
- }
- value_ptr->value.obj = Z_OBJ_HANDLER_PP(value, clone_obj)(*value TSRMLS_CC);
- zval_ptr_dtor(value);
- *value = value_ptr;
- }
*(argument_array++) = value;
arg_count--;
}
while (param_count-->0) {
zval **param = (zval **) p-(arg_count--);
zval_add_ref(param);
- add_next_index_zval(argument_array, *param);
+ add_next_index_zval(argument_array, *param);
}
return SUCCESS;
if (Z_OBJ_HT_P(object)->get_class_name == NULL ||
Z_OBJ_HT_P(object)->get_class_name(object, class_name, class_name_len, 0 TSRMLS_CC) != SUCCESS) {
zend_class_entry *ce = Z_OBJCE_P(object);
-
+
*class_name = ce->name;
*class_name_len = ce->name_length;
return 1;
*p = Z_STRVAL_PP(arg);
*pl = Z_STRLEN_PP(arg);
break;
+
case IS_OBJECT: {
if (Z_OBJ_HANDLER_PP(arg, cast_object)) {
SEPARATE_ZVAL_IF_NOT_REF(arg);
- if (Z_OBJ_HANDLER_PP(arg, cast_object)(*arg, *arg, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
+ if (Z_OBJ_HANDLER_PP(arg, cast_object)(*arg, *arg, IS_STRING TSRMLS_CC) == SUCCESS) {
*pl = Z_STRLEN_PP(arg);
*p = Z_STRVAL_PP(arg);
break;
}
}
}
-
+
case IS_ARRAY:
case IS_RESOURCE:
default:
} else {
return "resource";
}
- } else
+ } else {
*p = *arg;
+ }
}
break;
} else {
return "array";
}
- } else
+ } else {
*p = *arg;
+ }
}
break;
} else {
return "object";
}
- } else
+ } else {
*p = *arg;
+ }
}
break;
}
return FAILURE;
}
-
+
return SUCCESS;
}
{
va_list va;
int retval;
-
+
va_start(va, type_spec);
retval = zend_parse_va_args(num_args, type_spec, &va, flags TSRMLS_CC);
va_end(va);
{
va_list va;
int retval;
-
+
va_start(va, type_spec);
retval = zend_parse_va_args(num_args, type_spec, &va, 0 TSRMLS_CC);
va_end(va);
}
-/* This function should be called after the constructor has been called
+/* This function should be called after the constructor has been called
* because it may call __set from the uninitialized object otherwise. */
ZEND_API void zend_merge_properties(zval *obj, HashTable *properties, int destroy_ht TSRMLS_DC)
{
zend_hash_add(CE_STATIC_MEMBERS(class_type), str_index, str_length, (void**)q, sizeof(zval*), NULL);
} else {
zval *q;
-
+
ALLOC_ZVAL(q);
*q = **p;
INIT_PZVAL(q);
/* This function requires 'properties' to contain all props declared in the
- * class and all props being public. If only a subset is given or the class
+ * class and all props being public. If only a subset is given or the class
* has protected members then you need to merge the properties seperately by
* calling zend_merge_properties(). */
ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties ZEND_FILE_LINE_DC TSRMLS_DC)
}
zend_update_class_constants(class_type TSRMLS_CC);
-
- arg->type = IS_OBJECT;
+
+ Z_TYPE_P(arg) = IS_OBJECT;
if (class_type->create_object == NULL) {
- arg->value.obj = zend_objects_new(&object, class_type TSRMLS_CC);
+ Z_OBJVAL_P(arg) = zend_objects_new(&object, class_type TSRMLS_CC);
if (properties) {
object->properties = properties;
} else {
zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
}
} else {
- arg->value.obj = class_type->create_object(class_type TSRMLS_CC);
+ Z_OBJVAL_P(arg) = class_type->create_object(class_type TSRMLS_CC);
}
return SUCCESS;
}
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, n);
-
+
return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_assoc_null_ex(zval *arg, char *key, uint key_len)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_NULL(tmp);
-
+
return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_assoc_bool_ex(zval *arg, char *key, uint key_len, int b)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_BOOL(tmp, b);
ZEND_API int add_assoc_resource_ex(zval *arg, char *key, uint key_len, int r)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_RESOURCE(tmp, r);
-
+
return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_assoc_double_ex(zval *arg, char *key, uint key_len, double d)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_DOUBLE(tmp, d);
ZEND_API int add_assoc_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_STRING(tmp, str, duplicate);
ZEND_API int add_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, str, length, duplicate);
ZEND_API int add_index_bool(zval *arg, ulong index, int b)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_BOOL(tmp, b);
-
+
return zend_hash_index_update(Z_ARRVAL_P(arg), index, (void *) &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_index_resource(zval *arg, ulong index, int r)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_RESOURCE(tmp, r);
-
+
return zend_hash_index_update(Z_ARRVAL_P(arg), index, (void *) &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_index_double(zval *arg, ulong index, double d)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_DOUBLE(tmp, d);
-
+
return zend_hash_index_update(Z_ARRVAL_P(arg), index, (void *) &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_index_string(zval *arg, ulong index, char *str, int duplicate)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_STRING(tmp, str, duplicate);
ZEND_API int add_index_stringl(zval *arg, ulong index, char *str, uint length, int duplicate)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, str, length, duplicate);
ZEND_API int add_next_index_long(zval *arg, long n)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, n);
-
+
return zend_hash_next_index_insert(Z_ARRVAL_P(arg), &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_next_index_null(zval *arg)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_NULL(tmp);
-
+
return zend_hash_next_index_insert(Z_ARRVAL_P(arg), &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_next_index_bool(zval *arg, int b)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_BOOL(tmp, b);
-
+
return zend_hash_next_index_insert(Z_ARRVAL_P(arg), &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_next_index_resource(zval *arg, int r)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_RESOURCE(tmp, r);
-
+
return zend_hash_next_index_insert(Z_ARRVAL_P(arg), &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_next_index_double(zval *arg, double d)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_DOUBLE(tmp, d);
-
+
return zend_hash_next_index_insert(Z_ARRVAL_P(arg), &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_get_assoc_string_ex(zval *arg, char *key, uint key_len, char *str, void **dest, int duplicate)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_STRING(tmp, str, duplicate);
-
+
return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), dest);
}
ZEND_API int add_get_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, void **dest, int duplicate)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, str, length, duplicate);
ZEND_API int add_get_index_long(zval *arg, ulong index, long l, void **dest)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, l);
-
+
return zend_hash_index_update(Z_ARRVAL_P(arg), index, (void *) &tmp, sizeof(zval *), dest);
}
ZEND_API int add_get_index_double(zval *arg, ulong index, double d, void **dest)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_DOUBLE(tmp, d);
-
+
return zend_hash_index_update(Z_ARRVAL_P(arg), index, (void *) &tmp, sizeof(zval *), dest);
}
ZEND_API int add_get_index_string(zval *arg, ulong index, char *str, void **dest, int duplicate)
{
zval *tmp;
-
+
MAKE_STD_ZVAL(tmp);
ZVAL_STRING(tmp, str, duplicate);
zend_error(E_CORE_WARNING, "Cannot load module '%s' because required module '%s' is not loaded", module->name, dep->name);
module->module_started = 0;
return FAILURE;
- }
+ }
efree(lcname);
}
++dep;
Bucket **b1 = base;
Bucket **b2;
Bucket **end = b1 + count;
- Bucket *tmp;
+ Bucket *tmp;
zend_module_entry *m, *r;
while (b1 < end) {
if (strcasecmp(dep->name, r->name) == 0) {
tmp = *b1;
*b1 = *b2;
- *b2 = tmp;
+ *b2 = tmp;
goto try_again;
}
b2++;
}
}
dep++;
- }
+ }
}
b1++;
}
int name_len;
char *lcname;
zend_module_entry *module_ptr;
-
+
if (!module) {
return NULL;
}
/* TODO: Check version relationship */
zend_error(E_CORE_WARNING, "Cannot load module '%s' because conflicting module '%s' is already loaded", module->name, dep->name);
return NULL;
- }
+ }
efree(lcname);
}
++dep;
}
efree(lcname);
module = module_ptr;
+ EG(current_module) = module;
if (module->functions && zend_register_functions(NULL, module->functions, NULL, module->type TSRMLS_CC)==FAILURE) {
+ EG(current_module) = NULL;
zend_error(E_CORE_WARNING,"%s: Unable to register functions, unable to load", module->name);
return NULL;
}
+ EG(current_module) = NULL;
return module;
}
int count=0, unload=0;
HashTable *target_function_table = function_table;
int error_type;
- zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL;
+ zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__tostring = NULL;;
char *lowercase_name;
int fname_len;
char *lc_class_name = NULL;
clone = reg_function;
} else if ((fname_len == sizeof(ZEND_CALL_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME))) {
__call = reg_function;
+ } else if ((fname_len == sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME))) {
+ __tostring = reg_function;
} else if ((fname_len == sizeof(ZEND_GET_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_GET_FUNC_NAME, sizeof(ZEND_GET_FUNC_NAME))) {
__get = reg_function;
} else if ((fname_len == sizeof(ZEND_SET_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME))) {
scope->destructor = dtor;
scope->clone = clone;
scope->__call = __call;
+ scope->__tostring = __tostring;
scope->__get = __get;
scope->__set = __set;
scope->__unset = __unset;
}
__call->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
+ if (__tostring) {
+ if (__tostring->common.fn_flags & ZEND_ACC_STATIC) {
+ zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __tostring->common.function_name);
+ }
+ __tostring->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
+ }
if (__get) {
if (__get->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __get->common.function_name);
return SUCCESS;
}
-/* count=-1 means erase all functions, otherwise,
+/* count=-1 means erase all functions, otherwise,
* erase the first count functions
*/
ZEND_API void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table TSRMLS_DC)
ZEND_API int zend_startup_module(zend_module_entry *module)
{
TSRMLS_FETCH();
-
+
if ((module = zend_register_internal_module(module TSRMLS_CC)) != NULL &&
zend_startup_module_ex(module TSRMLS_CC) == SUCCESS) {
return SUCCESS;
ZEND_API int zend_get_module_started(char *module_name)
{
zend_module_entry *module;
-
+
return (zend_hash_find(&module_registry, module_name, strlen(module_name)+1, (void**)&module) == SUCCESS && module->module_started) ? SUCCESS : FAILURE;
}
#if HAVE_LIBDL || defined(HAVE_MACH_O_DYLD_H)
#if !(defined(NETWARE) && defined(APACHE_1_BUILD))
- if (module->handle) {
- DL_UNLOAD(module->handle);
- }
+ if (module->handle) {
+ DL_UNLOAD(module->handle);
+ }
#endif
#endif
}
} else {
class_entry->interfaces = erealloc(class_entry->interfaces, sizeof(zend_class_entry*) * (class_entry->num_interfaces+num_interfaces));
}
-
+
while (num_interfaces--) {
interface_entry = va_arg(interface_list, zend_class_entry *);
class_entry->interfaces[class_entry->num_interfaces++] = interface_entry;
ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length,
zend_bool is_ref, int num_symbol_tables, ...)
{
- HashTable *symbol_table;
- va_list symbol_table_list;
+ HashTable *symbol_table;
+ va_list symbol_table_list;
- if (num_symbol_tables <= 0) return FAILURE;
+ if (num_symbol_tables <= 0) return FAILURE;
- symbol->is_ref = is_ref;
+ symbol->is_ref = is_ref;
- va_start(symbol_table_list, num_symbol_tables);
- while (num_symbol_tables-- > 0) {
- symbol_table = va_arg(symbol_table_list, HashTable *);
- zend_hash_update(symbol_table, name, name_length + 1, &symbol, sizeof(zval *), NULL);
- zval_add_ref(&symbol);
- }
- va_end(symbol_table_list);
- return SUCCESS;
+ va_start(symbol_table_list, num_symbol_tables);
+ while (num_symbol_tables-- > 0) {
+ symbol_table = va_arg(symbol_table_list, HashTable *);
+ zend_hash_update(symbol_table, name, name_length + 1, &symbol, sizeof(zval *), NULL);
+ zval_add_ref(&symbol);
+ }
+ va_end(symbol_table_list);
+ return SUCCESS;
}
{
zend_class_entry *disabled_class;
disabled_class = (zend_class_entry *) emalloc(sizeof(zend_class_entry));
-
+
zend_str_tolower(class_name, class_name_length);
if (zend_hash_del(CG(class_table), class_name, class_name_length+1)==FAILURE) {
return FAILURE;
zend_function *fptr;
zend_class_entry **pce;
HashTable *ftable;
-
+
*ce_ptr = NULL;
*fptr_ptr = NULL;
zend_class_entry *ce = NULL;
zval **method;
zval **obj;
-
+
if (zend_hash_num_elements(Z_ARRVAL_P(callable)) == 2 &&
zend_hash_index_find(Z_ARRVAL_P(callable), 0, (void **) &obj) == SUCCESS &&
zend_hash_index_find(Z_ARRVAL_P(callable), 1, (void **) &method) == SUCCESS &&
efree(lcname);
} else {
ce = Z_OBJCE_PP(obj); /* TBFixed: what if it's overloaded? */
-
+
*zobj_ptr_ptr = obj;
if (callable_name) {
zend_module_entry *module;
if (zend_hash_find(&module_registry, module_name, strlen(module_name) + 1,
- (void**)&module) == FAILURE) {
+ (void**)&module) == FAILURE) {
return NULL;
}
- return module->version;
+ return module->version;
}
ZEND_API int zend_declare_property_null(zend_class_entry *ce, char *name, int name_length, int access_type TSRMLS_DC)
{
zval *property;
-
+
if (ce->type & ZEND_INTERNAL_CLASS) {
property = malloc(sizeof(zval));
} else {
ZEND_API int zend_declare_property_bool(zend_class_entry *ce, char *name, int name_length, long value, int access_type TSRMLS_DC)
{
zval *property;
-
+
if (ce->type & ZEND_INTERNAL_CLASS) {
property = malloc(sizeof(zval));
} else {
ZEND_API int zend_declare_property_long(zend_class_entry *ce, char *name, int name_length, long value, int access_type TSRMLS_DC)
{
zval *property;
-
+
if (ce->type & ZEND_INTERNAL_CLASS) {
property = malloc(sizeof(zval));
} else {
ZEND_API int zend_declare_property_double(zend_class_entry *ce, char *name, int name_length, double value, int access_type TSRMLS_DC)
{
zval *property;
-
+
if (ce->type & ZEND_INTERNAL_CLASS) {
property = malloc(sizeof(zval));
} else {
{
zval *property;
int len = strlen(value);
-
+
if (ce->type & ZEND_INTERNAL_CLASS) {
property = malloc(sizeof(zval));
ZVAL_STRINGL(property, zend_strndup(value, len), len, 0);
ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, char *name, int name_length, char *value, int value_len, int access_type TSRMLS_DC)
{
zval *property;
-
+
if (ce->type & ZEND_INTERNAL_CLASS) {
property = malloc(sizeof(zval));
ZVAL_STRINGL(property, zend_strndup(value, value_len), value_len, 0);
{
zval *property;
zend_class_entry *old_scope = EG(scope);
-
+
EG(scope) = scope;
if (!Z_OBJ_HT_P(object)->write_property) {
zend_uint class_name_len;
zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
-
+
zend_error(E_CORE_ERROR, "Property %s of class %s cannot be updated", name, class_name);
}
MAKE_STD_ZVAL(property);
ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC)
{
zval *tmp;
-
+
ALLOC_ZVAL(tmp);
tmp->is_ref = 0;
tmp->refcount = 0;
ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC)
{
zval *tmp;
-
+
ALLOC_ZVAL(tmp);
tmp->is_ref = 0;
tmp->refcount = 0;
ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, char *name, int name_length, double value TSRMLS_DC)
{
zval *tmp;
-
+
ALLOC_ZVAL(tmp);
tmp->is_ref = 0;
tmp->refcount = 0;
ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, char *name, int name_length, char *value TSRMLS_DC)
{
zval *tmp;
-
+
ALLOC_ZVAL(tmp);
tmp->is_ref = 0;
tmp->refcount = 0;
ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, char *name, int name_length, char *value, int value_len TSRMLS_DC)
{
zval *tmp;
-
+
ALLOC_ZVAL(tmp);
tmp->is_ref = 0;
tmp->refcount = 0;
{
zval **property;
zend_class_entry *old_scope = EG(scope);
-
+
EG(scope) = scope;
property = zend_std_get_static_property(scope, name, name_length, 0 TSRMLS_CC);
EG(scope) = old_scope;
if (*property != value) {
if (PZVAL_IS_REF(*property)) {
zval_dtor(*property);
- (*property)->type = value->type;
+ Z_TYPE_PP(property) = Z_TYPE_P(value);
(*property)->value = value->value;
if (value->refcount > 0) {
zval_copy_ctor(*property);
ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, char *name, int name_length, long value TSRMLS_DC)
{
zval *tmp;
-
+
ALLOC_ZVAL(tmp);
tmp->is_ref = 0;
tmp->refcount = 0;
ZEND_API int zend_update_static_property_long(zend_class_entry *scope, char *name, int name_length, long value TSRMLS_DC)
{
zval *tmp;
-
+
ALLOC_ZVAL(tmp);
tmp->is_ref = 0;
tmp->refcount = 0;
ZEND_API int zend_update_static_property_double(zend_class_entry *scope, char *name, int name_length, double value TSRMLS_DC)
{
zval *tmp;
-
+
ALLOC_ZVAL(tmp);
tmp->is_ref = 0;
tmp->refcount = 0;
ZEND_API int zend_update_static_property_string(zend_class_entry *scope, char *name, int name_length, char *value TSRMLS_DC)
{
zval *tmp;
-
+
ALLOC_ZVAL(tmp);
tmp->is_ref = 0;
tmp->refcount = 0;
ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, char *name, int name_length, char *value, int value_len TSRMLS_DC)
{
zval *tmp;
-
+
ALLOC_ZVAL(tmp);
tmp->is_ref = 0;
tmp->refcount = 0;
{
zval *property, *value;
zend_class_entry *old_scope = EG(scope);
-
+
EG(scope) = scope;
if (!Z_OBJ_HT_P(object)->read_property) {
zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
zend_error(E_CORE_ERROR, "Property %s of class %s cannot be read", name, class_name);
}
+
MAKE_STD_ZVAL(property);
ZVAL_STRINGL(property, name, name_length, 1);
value = Z_OBJ_HT_P(object)->read_property(object, property, silent TSRMLS_CC);
zval_ptr_dtor(&property);
+
EG(scope) = old_scope;
return value;
}
{
zval **property;
zend_class_entry *old_scope = EG(scope);
-
+
EG(scope) = scope;
property = zend_std_get_static_property(scope, name, name_length, silent TSRMLS_CC);
EG(scope) = old_scope;
} zend_function_entry;
#define ZEND_FN(name) zif_##name
+#define ZEND_MN(name) zim_##name
#define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
#define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(ZEND_FN(name))
-#define ZEND_METHOD(classname, name) ZEND_NAMED_FUNCTION(ZEND_FN(classname##_##name))
+#define ZEND_METHOD(classname, name) ZEND_NAMED_FUNCTION(ZEND_MN(classname##_##name))
#define ZEND_FENTRY(zend_name, name, arg_info, flags) { #zend_name, name, arg_info, (zend_uint) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
#define ZEND_DEP_FE(name, arg_info) ZEND_FENTRY(name, ZEND_FN(name), arg_info, ZEND_ACC_DEPRECATED)
#define ZEND_FALIAS(name, alias, arg_info) ZEND_FENTRY(name, ZEND_FN(alias), arg_info, 0)
#define ZEND_DEP_FALIAS(name, alias, arg_info) ZEND_FENTRY(name, ZEND_FN(alias), arg_info, ZEND_ACC_DEPRECATED)
-#define ZEND_ME(classname, name, arg_info, flags) ZEND_FENTRY(name, ZEND_FN(classname##_##name), arg_info, flags)
+#define ZEND_NAMED_ME(zend_name, name, arg_info, flags) ZEND_FENTRY(zend_name, name, arg_info, flags)
+#define ZEND_ME(classname, name, arg_info, flags) ZEND_FENTRY(name, ZEND_MN(classname##_##name), arg_info, flags)
#define ZEND_ABSTRACT_ME(classname, name, arg_info) ZEND_FENTRY(name, NULL, arg_info, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
#define ZEND_MALIAS(classname, name, alias, arg_info, flags) \
- ZEND_FENTRY(name, ZEND_FN(classname##_##alias), arg_info, flags)
-#define ZEND_ME_MAPPING(name, func_name, arg_types) ZEND_NAMED_FE(name, ZEND_FN(func_name), arg_types)
+ ZEND_FENTRY(name, ZEND_MN(classname##_##alias), arg_info, flags)
+#define ZEND_ME_MAPPING(name, func_name, arg_types, flags) ZEND_NAMED_ME(name, ZEND_FN(func_name), arg_types, flags)
#define ZEND_ARG_INFO(pass_by_ref, name) { #name, sizeof(#name)-1, NULL, 0, 0, 0, pass_by_ref, 0, 0 },
#define ZEND_ARG_PASS_INFO(pass_by_ref) { NULL, 0, NULL, 0, 0, 0, pass_by_ref, 0, 0 },
#endif
-
-
#define INIT_CLASS_ENTRY(class_container, class_name, functions) INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL)
#define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
class_container.constructor = NULL; \
class_container.destructor = NULL; \
class_container.clone = NULL; \
- class_container.create_object = NULL; \
+ class_container.serialize = NULL; \
+ class_container.unserialize = NULL; \
+ class_container.create_object = NULL; \
class_container.interface_gets_implemented = NULL; \
- class_container.__call = handle_fcall; \
- class_container.__get = handle_propget; \
- class_container.__set = handle_propset; \
- class_container.__unset = handle_propunset; \
- class_container.__isset = handle_propisset; \
- class_container.serialize = NULL; \
- class_container.unserialize = NULL; \
- class_container.parent = NULL; \
- class_container.num_interfaces = 0; \
- class_container.interfaces = NULL; \
- class_container.get_iterator = NULL; \
- class_container.iterator_funcs.funcs = NULL; \
- class_container.module = NULL; \
+ class_container.__call = handle_fcall; \
+ class_container.__tostring = NULL; \
+ class_container.__get = handle_propget; \
+ class_container.__set = handle_propset; \
+ class_container.__unset = handle_propunset; \
+ class_container.__isset = handle_propisset; \
+ class_container.serialize_func = NULL; \
+ class_container.unserialize_func = NULL; \
+ class_container.serialize = NULL; \
+ class_container.unserialize = NULL; \
+ class_container.parent = NULL; \
+ class_container.num_interfaces = 0; \
+ class_container.interfaces = NULL; \
+ class_container.get_iterator = NULL; \
+ class_container.iterator_funcs.funcs = NULL; \
+ class_container.module = NULL; \
}
#define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \
#define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key) + 1 TSRMLS_CC)
#define add_property_bool(__arg, __key, __b) add_property_bool_ex(__arg, __key, strlen(__key)+1, __b TSRMLS_CC)
#define add_property_resource(__arg, __key, __r) add_property_resource_ex(__arg, __key, strlen(__key)+1, __r TSRMLS_CC)
-#define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key)+1, __d TSRMLS_CC)
+#define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key)+1, __d TSRMLS_CC)
#define add_property_string(__arg, __key, __str, __duplicate) add_property_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate TSRMLS_CC)
#define add_property_stringl(__arg, __key, __str, __length, __duplicate) add_property_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate TSRMLS_CC)
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key)+1, __value TSRMLS_CC)
#define CHECK_ZVAL_STRING_REL(z)
#endif
-#define ZVAL_RESOURCE(z, l) { \
- (z)->type = IS_RESOURCE; \
- (z)->value.lval = l; \
+#define ZVAL_RESOURCE(z, l) { \
+ Z_TYPE_P(z) = IS_RESOURCE; \
+ Z_LVAL_P(z) = l; \
}
-#define ZVAL_BOOL(z, b) { \
- (z)->type = IS_BOOL; \
- (z)->value.lval = ((b) != 0); \
+#define ZVAL_BOOL(z, b) { \
+ Z_TYPE_P(z) = IS_BOOL; \
+ Z_LVAL_P(z) = ((b) != 0); \
}
-#define ZVAL_NULL(z) { \
- (z)->type = IS_NULL; \
+#define ZVAL_NULL(z) { \
+ Z_TYPE_P(z) = IS_NULL; \
}
-#define ZVAL_LONG(z, l) { \
- (z)->type = IS_LONG; \
- (z)->value.lval = l; \
+#define ZVAL_LONG(z, l) { \
+ Z_TYPE_P(z) = IS_LONG; \
+ Z_LVAL_P(z) = l; \
}
-#define ZVAL_DOUBLE(z, d) { \
- (z)->type = IS_DOUBLE; \
- (z)->value.dval = d; \
+#define ZVAL_DOUBLE(z, d) { \
+ Z_TYPE_P(z) = IS_DOUBLE; \
+ Z_DVAL_P(z) = d; \
}
#define ZVAL_STRING(z, s, duplicate) { \
zend_declare_property(class_ptr, _name, namelen, value, mask TSRMLS_CC); \
}
-#define HASH_OF(p) ((p)->type==IS_ARRAY ? (p)->value.ht : (((p)->type==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p) TSRMLS_CC) : NULL)))
-#define ZVAL_IS_NULL(z) ((z)->type==IS_NULL)
+#define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p) TSRMLS_CC) : NULL)))
+#define ZVAL_IS_NULL(z) (Z_TYPE_P(z)==IS_NULL)
/* For compatibility */
#define ZEND_MINIT ZEND_MODULE_STARTUP_N
#define ZEND_MINFO_FUNCTION ZEND_MODULE_INFO_D
END_EXTERN_C()
-
+
#endif /* ZEND_API_H */
ZEND_BEGIN_ARG_INFO(all_args_by_ref, 1)
ZEND_END_ARG_INFO();
-
ZEND_NAMED_FUNCTION(zend_if_strlen)
{
zval **str;
-
+
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
ulong num_key;
zval **inserted_pointer;
HashTable *target_hash;
-
+
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &array) == FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
zval **var, **val, **non_cs;
int case_sensitive;
zend_constant c;
-
+
switch (ZEND_NUM_ARGS()) {
case 2:
if (zend_get_parameters_ex(2, &var, &val)==FAILURE) {
RETURN_FALSE;
}
convert_to_long_ex(non_cs);
- if ((*non_cs)->value.lval) {
+ if (Z_LVAL_PP(non_cs)) {
case_sensitive = 0;
} else {
case_sensitive = CONST_CS;
break;
}
- switch ((*val)->type) {
+ switch (Z_TYPE_PP(val)) {
case IS_LONG:
case IS_DOUBLE:
case IS_STRING:
{
zval **var;
zval c;
-
+
if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &var)==FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
char *name = "";
zend_uint name_len = 0;
int dup;
-
+
if (!ZEND_NUM_ARGS()) {
if (EG(scope)) {
RETURN_STRINGL(EG(scope)->name, EG(scope)->name_length, 1);
zend_error(E_WARNING, "Unknown class passed as parameter");
RETURN_FALSE;
}
- instance_ce = *the_ce;
+ instance_ce = *the_ce;
} else if (Z_TYPE_PP(obj) != IS_OBJECT) {
RETURN_FALSE;
} else {
instance_ce = NULL;
}
-
+
/* TBI!! new object handlers */
if (Z_TYPE_PP(obj) == IS_OBJECT && !HAS_CLASS_ENTRY(**obj)) {
RETURN_FALSE;
if (Z_TYPE_P(prop_copy) == IS_CONSTANT_ARRAY || Z_TYPE_P(prop_copy) == IS_CONSTANT) {
zval_update_constant(&prop_copy, 0 TSRMLS_CC);
}
-
+
add_assoc_zval(return_value, prop_name, prop_copy);
}
}
ZEND_WRONG_PARAM_COUNT();
}
- if ((*obj)->type != IS_OBJECT) {
+ if (Z_TYPE_PP(obj) != IS_OBJECT) {
RETURN_FALSE;
}
if (Z_OBJ_HT_PP(obj)->get_properties == NULL) {
zval **klass, **method_name;
char *lcname;
zend_class_entry * ce, **pce;
-
+
if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &klass, &method_name)==FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
}
RETURN_BOOL(EG(scope) == ce);
RETURN_FALSE;
-
+
case IS_OBJECT:
if (Z_OBJ_HANDLER_PP(object, has_property) && Z_OBJ_HANDLER_PP(object, has_property)(*object, *property, 2 TSRMLS_CC)) {
RETURN_TRUE;
leakbytes = (*leak)->value.lval;
}
}
-
+
emalloc(leakbytes);
}
/* }}} */
zend_bool had_orig_error_handler=0;
char *error_handler_name = NULL;
long error_type = E_ALL | E_STRICT;
-
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &error_handler, &error_type) == FAILURE) {
return;
}
{
zend_uint mask = ZEND_ACC_INTERFACE;
zend_uint comply = 1;
-
+
if (ZEND_NUM_ARGS() != 0) {
ZEND_WRONG_PARAM_COUNT();
}
} else if (func->type == ZEND_USER_FUNCTION) {
add_next_index_stringl(user_ar, hash_key->arKey, hash_key->nKeyLength-1, 1);
}
-
+
return 0;
}
{
zval *internal;
zval *user;
-
+
if (ZEND_NUM_ARGS() != 0) {
ZEND_WRONG_PARAM_COUNT();
}
-
+
MAKE_STD_ZVAL(internal);
MAKE_STD_ZVAL(user);
-
+
array_init(internal);
array_init(user);
array_init(return_value);
-
+
zend_hash_apply_with_arguments(EG(function_table), (apply_func_args_t) copy_function_name, 2, internal, user);
-
- if (zend_hash_add(return_value->value.ht, "internal", sizeof("internal"), (void **)&internal, sizeof(zval *), NULL) == FAILURE) {
+
+ if (zend_hash_add(Z_ARRVAL_P(return_value), "internal", sizeof("internal"), (void **)&internal, sizeof(zval *), NULL) == FAILURE) {
zend_error(E_WARNING, "Cannot add internal functions to return value from get_defined_functions()");
RETURN_FALSE;
}
-
- if (zend_hash_add(return_value->value.ht, "user", sizeof("user"), (void **)&user, sizeof(zval *), NULL) == FAILURE) {
+
+ if (zend_hash_add(Z_ARRVAL_P(return_value), "user", sizeof("user"), (void **)&user, sizeof(zval *), NULL) == FAILURE) {
zend_error(E_WARNING, "Cannot add user functions to return value from get_defined_functions()");
RETURN_FALSE;
}
/* {{{ proto array get_defined_vars(void)
Returns an associative array of names and values of all currently defined variable names (variables in the current scope) */
ZEND_FUNCTION(get_defined_vars)
-{
+{
zval *tmp;
-
+
array_init(return_value);
-
- zend_hash_copy(return_value->value.ht, EG(active_symbol_table),
+
+ zend_hash_copy(Z_ARRVAL_P(return_value), EG(active_symbol_table),
(copy_ctor_func_t)zval_add_ref, &tmp, sizeof(zval *));
}
/* }}} */
modules = ecalloc(zend_hash_num_elements(&module_registry) + 2, sizeof(zval *));
module_names = emalloc((zend_hash_num_elements(&module_registry) + 2) * sizeof(char *));
-
+
module_names[0] = "internal";
zend_hash_internal_pointer_reset_ex(&module_registry, &pos);
while (zend_hash_get_current_data_ex(&module_registry, (void *) &module, &pos) != FAILURE) {
zval *arg_array, **arg;
int arg_count = (ulong) *p;
- *curpos -= (arg_count+2);
+ *curpos -= (arg_count+2);
MAKE_STD_ZVAL(arg_array);
array_init(arg_array);
arg_array = NULL;
skip = ptr;
- /* skip internal handler */
+ /* skip internal handler */
if (!skip->op_array &&
skip->prev_execute_data &&
skip->prev_execute_data->opline &&
} else {
zend_uint class_name_len;
int dup;
-
+
dup = zend_get_object_classname(ptr->object, &class_name, &class_name_len TSRMLS_CC);
if(!dup) {
free_class_name = class_name;
arg_array = debug_backtrace_get_args(&cur_arg_pos TSRMLS_CC);
frames_on_stack--;
}
- }
+ }
} else {
/* i know this is kinda ugly, but i'm trying to avoid extra cycles in the main execution loop */
zend_bool build_filename_arg = 1;
function_name = "unknown";
build_filename_arg = 0;
} else
- switch (ptr->opline->op2.u.constant.value.lval) {
+ switch (Z_LVAL(ptr->opline->op2.u.constant)) {
case ZEND_EVAL:
function_name = "eval";
build_filename_arg = 0;
} else {
zend_uint class_name_len;
int dup;
-
+
dup = zend_get_object_classname(ptr->object, &class_name, &class_name_len TSRMLS_CC);
add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, dup);
add_assoc_zval_ex(stack_frame, "args", sizeof("args"), debug_backtrace_get_args(&cur_arg_pos TSRMLS_CC));
frames_on_stack--;
}
- }
+ }
} else {
/* i know this is kinda ugly, but i'm trying to avoid extra cycles in the main execution loop */
zend_bool build_filename_arg = 1;
MAKE_STD_ZVAL(arg_array);
array_init(arg_array);
-
+
/* include_filename always points to the last filename of the last last called-fuction.
if we have called include in the frame above - this is the file we have included.
*/
if (ZEND_NUM_ARGS()) {
ZEND_WRONG_PARAM_COUNT();
}
-
+
zend_fetch_debug_backtrace(return_value, 1, 1 TSRMLS_CC);
}
/* }}} */
RETURN_FALSE;
}
efree(lcname);
-
+
if (!(func = module->functions)) {
RETURN_FALSE;
}
static void init_compiler_declarables(TSRMLS_D)
{
- CG(declarables).ticks.type = IS_LONG;
- CG(declarables).ticks.value.lval = 0;
+ Z_TYPE(CG(declarables).ticks) = IS_LONG;
+ Z_LVAL(CG(declarables).ticks) = 0;
}
i = op_array->last_var;
op_array->last_var++;
if (op_array->last_var > op_array->size_var) {
- op_array->size_var += 16; /* FIXME */
+ op_array->size_var += 16; /* FIXME */
op_array->vars = erealloc(op_array->vars, op_array->size_var*sizeof(zend_compiled_variable));
}
op_array->vars[i].name = name; /* estrndup(name, name_len); */
if (last_op_number > 0) {
zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1];
-
+
switch (last_op->opcode) {
case ZEND_FETCH_OBJ_RW:
last_op->opcode = op;
while (last_op_number - n > 0) {
zend_op *last_op;
-
- last_op = &CG(active_op_array)->opcodes[last_op_number-(n+1)];
+
+ last_op = &CG(active_op_array)->opcodes[last_op_number-n-1];
if (last_op->result.op_type == IS_VAR &&
last_op->result.u.var == variable->u.var) {
opline->opcode = ZEND_ASSIGN_REF;
if (zend_is_function_or_method_call(rvar)) {
- opline->extended_value = ZEND_RETURNS_FUNCTION;
+ opline->extended_value = ZEND_RETURNS_FUNCTION;
} else {
opline->extended_value = 0;
}
opline->op1.u.opline_num = while_token->u.opline_num;
SET_UNUSED(opline->op1);
SET_UNUSED(opline->op2);
-
+
/* update while's conditional jmp */
CG(active_op_array)->opcodes[close_bracket_token->u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array));
}
zend_stack_top(&CG(bp_stack), (void **) &jmp_list_ptr);
zend_llist_add_element(jmp_list_ptr, &if_end_op_number);
-
+
CG(active_op_array)->opcodes[closing_bracket_token->u.opline_num].op2.u.opline_num = if_end_op_number+1;
SET_UNUSED(opline->op1);
SET_UNUSED(opline->op2);
le = fetch_list_ptr->head;
/* TODO: $foo->x->y->z = 1 should fetch "x" and "y" for R or RW, not just W */
-
+
if (le) {
opline_ptr = (zend_op *)le->data;
if (opline_is_fetch_this(opline_ptr TSRMLS_CC)) {
}
} else if (op1->op_type == IS_CONST) {
zval_dtor(&op1->u.constant);
- }
+ }
}
int zend_do_verify_access_types(znode *current_access_type, znode *new_modifier)
{
- if ((current_access_type->u.constant.value.lval & ZEND_ACC_PPP_MASK)
- && (new_modifier->u.constant.value.lval & ZEND_ACC_PPP_MASK)
- && ((current_access_type->u.constant.value.lval & ZEND_ACC_PPP_MASK) != (new_modifier->u.constant.value.lval & ZEND_ACC_PPP_MASK))) {
+ if ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_PPP_MASK)
+ && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_PPP_MASK)
+ && ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_PPP_MASK) != (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_PPP_MASK))) {
zend_error(E_COMPILE_ERROR, "Multiple access type modifiers are not allowed");
}
- if (((current_access_type->u.constant.value.lval | new_modifier->u.constant.value.lval) & (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) == (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) {
+ if (((Z_LVAL(current_access_type->u.constant) | Z_LVAL(new_modifier->u.constant)) & (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) == (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) {
zend_error(E_COMPILE_ERROR, "Cannot use the final modifier on an abstract class member");
}
- return (current_access_type->u.constant.value.lval | new_modifier->u.constant.value.lval);
+ return (Z_LVAL(current_access_type->u.constant) | Z_LVAL(new_modifier->u.constant));
}
if (is_method) {
if (CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) {
- if ((fn_flags_znode->u.constant.value.lval & ~(ZEND_ACC_STATIC|ZEND_ACC_PUBLIC))) {
+ if ((Z_LVAL(fn_flags_znode->u.constant) & ~(ZEND_ACC_STATIC|ZEND_ACC_PUBLIC))) {
zend_error(E_COMPILE_ERROR, "Access type for interface method %s::%s() must be omitted", CG(active_class_entry)->name, function_name->u.constant.value.str.val);
}
- fn_flags_znode->u.constant.value.lval |= ZEND_ACC_ABSTRACT; /* propagates to the rest of the parser */
+ Z_LVAL(fn_flags_znode->u.constant) |= ZEND_ACC_ABSTRACT; /* propagates to the rest of the parser */
}
- fn_flags = fn_flags_znode->u.constant.value.lval; /* must be done *after* the above check */
+ fn_flags = Z_LVAL(fn_flags_znode->u.constant); /* must be done *after* the above check */
} else {
fn_flags = 0;
}
+ if ((fn_flags & ZEND_ACC_STATIC) && (fn_flags & ZEND_ACC_ABSTRACT) && !(CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE)) {
+ zend_error(E_COMPILE_ERROR, "Static function %s%s%s() cannot be abstract", is_method ? CG(active_class_entry)->name : "", is_method ? "::" : "", Z_STRVAL(function_name->u.constant));
+ }
function_token->u.op_array = CG(active_op_array);
lcname = zend_str_tolower_dup(name, name_len);
CG(active_class_entry)->__unset = (zend_function *) CG(active_op_array);
} else if ((name_len == sizeof(ZEND_ISSET_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_ISSET_FUNC_NAME, sizeof(ZEND_ISSET_FUNC_NAME)))) {
CG(active_class_entry)->__isset = (zend_function *) CG(active_op_array);
+ } else if ((name_len == sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME)))) {
+ CG(active_class_entry)->__tostring = (zend_function *) CG(active_op_array);
} else if (!(fn_flags & ZEND_ACC_STATIC)) {
CG(active_op_array)->fn_flags |= ZEND_ACC_ALLOW_STATIC;
}
SET_UNUSED(opline->op1);
SET_UNUSED(opline->op2);
}
-
+
{
/* Push a seperator to the switch and foreach stacks */
zend_switch_entry switch_entry;
-
+
switch_entry.cond.op_type = IS_UNUSED;
switch_entry.default_case = 0;
switch_entry.control_var = 0;
switch (function->type) {
case ZEND_USER_FUNCTION: {
zend_op_array *op_array = (zend_op_array *) function;
-
+
zend_stack_push(&CG(function_call_stack), (void *) &op_array, sizeof(zend_function *));
}
break;
case ZEND_INTERNAL_FUNCTION: {
zend_internal_function *internal_function = (zend_internal_function *) function;
-
+
zend_stack_push(&CG(function_call_stack), (void *) &internal_function, sizeof(zend_function *));
}
break;
}
- zend_do_extended_fcall_begin(TSRMLS_C);
+ zend_do_extended_fcall_begin(TSRMLS_C);
return 0;
}
zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC);
zend_do_begin_variable_parse(TSRMLS_C);
-
+
last_op_number = get_next_op_number(CG(active_op_array))-1;
last_op = &CG(active_op_array)->opcodes[last_op_number];
if (last_op->opcode == ZEND_FETCH_OBJ_R) {
last_op->opcode = ZEND_INIT_METHOD_CALL;
- left_bracket->u.constant.value.lval = ZEND_INIT_FCALL_BY_NAME;
+ Z_LVAL(left_bracket->u.constant) = ZEND_INIT_FCALL_BY_NAME;
} else {
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_INIT_FCALL_BY_NAME;
}
zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *));
- zend_do_extended_fcall_begin(TSRMLS_C);
+ zend_do_extended_fcall_begin(TSRMLS_C);
}
-
+
void zend_do_clone(znode *result, znode *expr TSRMLS_DC)
{
SET_UNUSED(opline->op1);
zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *));
- zend_do_extended_fcall_begin(TSRMLS_C);
+ zend_do_extended_fcall_begin(TSRMLS_C);
}
void zend_do_end_function_call(znode *function_name, znode *result, znode *argument_list, int is_method, int is_dynamic_fcall TSRMLS_DC)
{
zend_op *opline;
-
+
if (is_method && function_name && function_name->op_type == IS_UNUSED) {
/* clone */
- if (argument_list->u.constant.value.lval != 0) {
+ if (Z_LVAL(argument_list->u.constant) != 0) {
zend_error(E_WARNING, "Clone method does not require arguments");
}
- opline = &CG(active_op_array)->opcodes[function_name->u.constant.value.lval];
+ opline = &CG(active_op_array)->opcodes[Z_LVAL(function_name->u.constant)];
} else {
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
if (!is_method && !is_dynamic_fcall && function_name->op_type==IS_CONST) {
SET_UNUSED(opline->op1);
}
}
-
+
opline->result.u.var = get_temporary_variable(CG(active_op_array));
opline->result.op_type = IS_VAR;
*result = opline->result;
SET_UNUSED(opline->op2);
zend_stack_del_top(&CG(function_call_stack));
- opline->extended_value = argument_list->u.constant.value.lval;
+ opline->extended_value = Z_LVAL(argument_list->u.constant);
}
zend_function **function_ptr_ptr, *function_ptr;
int send_by_reference;
int send_function = 0;
-
+
zend_stack_top(&CG(function_call_stack), (void **) &function_ptr_ptr);
function_ptr = *function_ptr_ptr;
op = (param->op_type & (IS_VAR|IS_CV))?ZEND_SEND_REF:ZEND_SEND_VAL;
send_by_reference = 0;
} else {
- send_by_reference = ARG_SHOULD_BE_SENT_BY_REF(function_ptr, (zend_uint) offset) ? ZEND_ARG_SEND_BY_REF : 0;
+ send_by_reference = ARG_SHOULD_BE_SENT_BY_REF(function_ptr, (zend_uint) offset) ? ZEND_ARG_SEND_BY_REF : 0;
}
} else {
send_by_reference = 0;
static int generate_free_switch_expr(zend_switch_entry *switch_entry TSRMLS_DC)
{
zend_op *opline;
-
+
if (switch_entry->cond.op_type != IS_VAR && switch_entry->cond.op_type != IS_TMP_VAR) {
return (switch_entry->cond.op_type == IS_UNUSED);
}
-
+
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_SWITCH_FREE;
/* If we reach the seperator then stop applying the stack */
if (foreach_copy->result.op_type == IS_UNUSED && foreach_copy->op1.op_type == IS_UNUSED) {
return 1;
- }
+ }
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
SET_UNUSED(opline->op2);
opline->extended_value = 0;
}
-
+
return 0;
}
void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC)
{
zend_op *opline;
-
+
if (do_end_vparse) {
if (CG(active_op_array)->return_reference && !zend_is_function_or_method_call(expr)) {
zend_do_end_variable_parse(BP_VAR_W, 0 TSRMLS_CC);
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_RETURN;
-
+
if (expr) {
opline->op1 = *expr;
} else {
if (do_end_vparse) {
if (zend_is_function_or_method_call(expr)) {
- opline->extended_value = ZEND_RETURNS_FUNCTION;
+ opline->extended_value = ZEND_RETURNS_FUNCTION;
} else {
opline->extended_value = 0;
}
{
long catch_op_number = get_next_op_number(CG(active_op_array));
zend_op *opline;
-
+
if (catch_op_number > 0) {
opline = &CG(active_op_array)->opcodes[catch_op_number-1];
if (opline->opcode == ZEND_FETCH_CLASS) {
void zend_do_throw(znode *expr TSRMLS_DC)
{
zend_op *opline;
-
+
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_THROW;
opline->op1 = *expr;
if (!ce->__call) {
ce->__call = ce->parent->__call;
}
+ if (!ce->__tostring) {
+ ce->__tostring = ce->parent->__tostring;
+ }
if (!ce->clone) {
ce->clone = ce->parent->clone;
}
}
return;
}
-
+
if (zend_hash_find(&ce->parent->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), (void **)&function)==SUCCESS) {
/* inherit parent's constructor */
zend_hash_update(&ce->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), function, sizeof(zend_function), NULL);
child->common.prototype = parent->common.prototype;
}
-
+
if (child->common.prototype) {
if (!zend_do_perform_implementation_check(child, child->common.prototype)) {
zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with that of %s::%s()", ZEND_FN_SCOPE_NAME(child), child->common.function_name, ZEND_FN_SCOPE_NAME(child->common.prototype), child->common.prototype->common.function_name);
if (*old_constant != *parent_constant) {
zend_error(E_COMPILE_ERROR, "Cannot inherit previously-inherited constant %s from interface %s", hash_key->arKey, iface->name);
}
- return 0;
+ return 0;
}
return 1;
}
return SUCCESS;
}
}
-
+
ZEND_API zend_class_entry *do_bind_class(zend_op *opline, HashTable *class_table, zend_bool compile_time TSRMLS_DC)
{
}
opline->op1 = *expr1;
SET_UNUSED(opline->op2);
-
+
op_token->u.opline_num = next_op_number;
*expr1 = opline->result;
}
opline->op1 = *expr1;
SET_UNUSED(opline->op2);
-
+
op_token->u.opline_num = next_op_number;
*expr1 = opline->result;
if (expr) {
opline->op2 = *expr;
} else {
- opline->op2.u.constant.type = IS_LONG;
- opline->op2.u.constant.value.lval = 1;
+ Z_TYPE(opline->op2.u.constant) = IS_LONG;
+ Z_LVAL(opline->op2.u.constant) = 1;
INIT_PZVAL(&opline->op2.u.constant);
opline->op2.op_type = IS_CONST;
}
{
zend_op *opline;
zend_switch_entry *switch_entry_ptr;
-
+
zend_stack_top(&CG(switch_cond_stack), (void **) &switch_entry_ptr);
/* add code to jmp to default case */
zval_copy_ctor(&opline->op1.u.constant);
}
result = opline->result;
-
+
next_op_number = get_next_op_number(CG(active_op_array));
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_JMPZ;
opline->op2.op_type = IS_CONST;
opline->op2.u.constant.type = IS_STRING;
opline->op2.u.constant.refcount = 1;
-
+
if (doing_inheritance) {
opline->extended_value = parent_class_name->u.var;
opline->opcode = ZEND_DECLARE_INHERITED_CLASS;
}
break;
}
-
+
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_ADD_INTERFACE;
opline->op1 = CG(implementing_class);
{
char *prop_name;
int prop_name_length;
-
+
prop_name_length = 1 + src1_length + 1 + src2_length;
prop_name = pemalloc(prop_name_length + 1, internal);
prop_name[0] = '\0';
*property = value->u.constant;
} else {
INIT_PZVAL(property);
- property->type = IS_NULL;
+ Z_TYPE_P(property) = IS_NULL;
}
if (CG(doc_comment)) {
void zend_do_declare_class_constant(znode *var_name, znode *value TSRMLS_DC)
{
zval *property;
-
+
if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) {
zend_error(E_COMPILE_ERROR, "Arrays are not allowed in class constants");
}
-
+
ALLOC_ZVAL(property);
*property = value->u.constant;
zend_op opline;
zend_llist *fetch_list_ptr;
zend_op *opline_ptr=NULL;
-
+
zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr);
-
+
if (fetch_list_ptr->count == 1) {
zend_llist_element *le;
{
zend_op *opline;
unsigned char *ptr = NULL;
-
+
new_token->u.opline_num = get_next_op_number(CG(active_op_array));
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_NEW;
opline->result.u.var = get_temporary_variable(CG(active_op_array));
opline->op1 = *class_type;
SET_UNUSED(opline->op2);
-
+
zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(unsigned char *));
}
if (constant_container ||
!zend_constant_ct_subst(result, &constant_name->u.constant TSRMLS_CC)) {
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
-
+
opline->opcode = ZEND_FETCH_CONSTANT;
opline->result.op_type = IS_TMP_VAR;
opline->result.u.var = get_temporary_variable(CG(active_op_array));
opline->result.u.var = get_temporary_variable(CG(active_op_array));
opline->op1 = last_container;
opline->op2.op_type = IS_CONST;
- opline->op2.u.constant.type = IS_LONG;
- opline->op2.u.constant.value.lval = *((int *) dimension->data);
+ Z_TYPE(opline->op2.u.constant) = IS_LONG;
+ Z_LVAL(opline->op2.u.constant) = *((int *) dimension->data);
INIT_PZVAL(&opline->op2.u.constant);
opline->extended_value = ZEND_FETCH_ADD_LOCK;
last_container = opline->result;
opline->result.u.var = get_temporary_variable(CG(active_op_array));
opline->op1 = *op1;
SET_UNUSED(opline->op2);
- opline->op2.u.constant.value.lval = type;
+ Z_LVAL(opline->op2.u.constant) = type;
*result = opline->result;
}
zend_do_extended_fcall_end(TSRMLS_C);
break;
}
- }
+ }
}
zend_do_end_variable_parse(BP_VAR_IS, 0 TSRMLS_CC);
zend_check_writable_variable(variable);
-
+
if (variable->op_type == IS_CV) {
last_op = get_next_op(CG(active_op_array) TSRMLS_CC);
last_op->opcode = ZEND_ISSET_ISEMPTY_VAR;
last_op->result.u.var = get_temporary_variable(CG(active_op_array));
} else {
last_op = &CG(active_op_array)->opcodes[get_next_op_number(CG(active_op_array))-1];
-
+
switch (last_op->opcode) {
case ZEND_FETCH_IS:
last_op->opcode = ZEND_ISSET_ISEMPTY_VAR;
void zend_do_foreach_fetch(znode *foreach_token, znode *open_brackets_token, znode *as_token TSRMLS_DC)
{
zend_op *opline;
-
+
/* save the location of FE_FETCH */
as_token->u.opline_num = get_next_op_number(CG(active_op_array));
SET_UNUSED(opline->op2);
result->op_type = IS_CONST;
- result->u.constant.type = IS_BOOL;
- result->u.constant.value.lval = 1;
+ Z_TYPE(result->u.constant) = IS_BOOL;
+ Z_LVAL(result->u.constant) = 1;
}
void zend_do_begin_silence(znode *strudel_token TSRMLS_DC)
{
int jmpz_op_number = get_next_op_number(CG(active_op_array));
zend_op *opline;
-
+
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_JMPZ;
opline->result = *qm_token;
opline->op1 = *false_value;
SET_UNUSED(opline->op2);
-
+
CG(active_op_array)->opcodes[colon_token->u.opline_num].op1.u.opline_num = get_next_op_number(CG(active_op_array));
*result = opline->result;
void zend_do_extended_info(TSRMLS_D)
{
zend_op *opline;
-
+
if (!CG(extended_info)) {
return;
}
-
+
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_EXT_STMT;
void zend_do_extended_fcall_begin(TSRMLS_D)
{
zend_op *opline;
-
+
if (!CG(extended_info)) {
return;
}
-
+
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_EXT_FCALL_BEGIN;
void zend_do_extended_fcall_end(TSRMLS_D)
{
zend_op *opline;
-
+
if (!CG(extended_info)) {
return;
}
-
+
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_EXT_FCALL_END;
void zend_do_ticks(TSRMLS_D)
{
- if (CG(declarables).ticks.value.lval) {
+ if (Z_LVAL(CG(declarables).ticks)) {
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_TICKS;
CG(increment_lineno) = 0;
}
- zendlval->u.constant.type = IS_LONG;
+ Z_TYPE(zendlval->u.constant) = IS_LONG;
retval = lex_scan(&zendlval->u.constant TSRMLS_CC);
switch (retval) {
case T_COMMENT:
case EOF:
return EOF;
}
-
+
INIT_PZVAL(&zendlval->u.constant);
zendlval->op_type = IS_CONST;
return retval;
ce->__unset = NULL;
ce->__isset = NULL;
ce->__call = NULL;
+ ce->__tostring = NULL;
ce->create_object = NULL;
ce->get_iterator = NULL;
ce->iterator_funcs.funcs = NULL;
typedef struct _zend_internal_function {
/* Common elements */
zend_uchar type;
- char *function_name;
+ char * function_name;
zend_class_entry *scope;
- zend_uint fn_flags;
+ zend_uint fn_flags;
union _zend_function *prototype;
zend_uint num_args;
zend_uint required_num_args;
/* END of common elements */
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
+ struct _zend_module_entry *module;
} zend_internal_function;
#define ZEND_FN_SCOPE_NAME(function) ((function) && (function)->common.scope ? (function)->common.scope->name : "")
zend_bool pass_rest_by_reference;
unsigned char return_reference;
} common;
-
+
zend_op_array op_array;
zend_internal_function internal_function;
} zend_function;
/* helper functions in zend_language_scanner.l */
ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSRMLS_DC);
-ZEND_API zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC);
+ZEND_API zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC);
ZEND_API zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC);
ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_count, ...);
ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC);
#define ZEND_DESTRUCTOR_FUNC_NAME "__destruct"
#define ZEND_GET_FUNC_NAME "__get"
#define ZEND_SET_FUNC_NAME "__set"
-#define ZEND_UNSET_FUNC_NAME "__unset"
-#define ZEND_ISSET_FUNC_NAME "__isset"
+#define ZEND_UNSET_FUNC_NAME "__unset"
+#define ZEND_ISSET_FUNC_NAME "__isset"
#define ZEND_CALL_FUNC_NAME "__call"
+#define ZEND_TOSTRING_FUNC_NAME "__tostring"
#define ZEND_AUTOLOAD_FUNC_NAME "__autoload"
#endif /* ZEND_COMPILE_H */
#define E_USER_WARNING (1<<9L)
#define E_USER_NOTICE (1<<10L)
#define E_STRICT (1<<11L)
+#define E_RECOVERABLE_ERROR (1<<12L)
-#define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE)
+#define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_STRICT | E_RECOVERABLE_ERROR)
#define E_CORE (E_CORE_ERROR | E_CORE_WARNING)
#endif /* ZEND_ERRORS_H */
zend_object *object;
zval *trace;
- obj.value.obj = zend_objects_new(&object, class_type TSRMLS_CC);
- obj.value.obj.handlers = &default_exception_handlers;
+ Z_OBJVAL(obj) = zend_objects_new(&object, class_type TSRMLS_CC);
+ Z_OBJ_HT(obj) = &default_exception_handlers;
ALLOC_HASHTABLE(object->properties);
zend_hash_init(object->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_update_property_long(default_exception_ce, &obj, "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);
zend_update_property(default_exception_ce, &obj, "trace", sizeof("trace")-1, trace TSRMLS_CC);
- return obj.value.obj;
+ return Z_OBJVAL(obj);
}
static zend_object_value zend_default_exception_new(zend_class_entry *class_type TSRMLS_DC)
}
zend_update_property_long(default_exception_ce, object, "severity", sizeof("severity")-1, severity TSRMLS_CC);
-
+
if (argc >= 4) {
zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, filename TSRMLS_CC);
if (argc < 5) {
#define TRACE_APPEND_STRL(val, vallen) \
{ \
- int l = vallen; \
+ int l = vallen; \
*str = (char*)erealloc(*str, *len + l + 1); \
memcpy((*str) + *len, val, l); \
*len += l; \
if(!dup) {
efree(class_name);
}
-
+
TRACE_APPEND_STR("), ");
break;
}
zval *trace;
char *res = estrdup(""), **str = &res, *s_tmp;
int res_len = 0, *len = &res_len, num = 0;
-
+
trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC);
zend_hash_apply_with_arguments(Z_ARRVAL_P(trace), (apply_func_args_t)_build_trace_string, 3, str, len, &num);
}
/* }}} */
-static int zend_spprintf(char **message, int max_len, char *format, ...)
+int zend_spprintf(char **message, int max_len, char *format, ...)
{
va_list arg;
int len;
- va_start(arg, format);
+ va_start(arg, format);
len = zend_vspprintf(message, max_len, format, arg);
va_end(arg);
return len;
/* All functions that may be used in uncaught exception handlers must be final
* and must not throw exceptions. Otherwise we would need a facility to handle
- * such exceptions in that handler.
+ * such exceptions in that handler.
* Also all getXY() methods are final because thy serve as read only access to
- * their corresponding properties, no more, no less. If after all you need to
+ * their corresponding properties, no more, no less. If after all you need to
* override somthing then it is method __toString().
* And never try to change the state of exceptions and never implement anything
* that gives the user anything to accomplish this.
INIT_CLASS_ENTRY(ce, "Exception", default_exception_functions);
default_exception_ce = zend_register_internal_class(&ce TSRMLS_CC);
- default_exception_ce->create_object = zend_default_exception_new;
+ default_exception_ce->create_object = zend_default_exception_new;
memcpy(&default_exception_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
default_exception_handlers.clone_obj = NULL;
INIT_CLASS_ENTRY(ce, "ErrorException", error_exception_functions);
error_exception_ce = zend_register_internal_class_ex(&ce, default_exception_ce, NULL TSRMLS_CC);
- error_exception_ce->create_object = zend_error_exception_new;
+ error_exception_ce->create_object = zend_error_exception_new;
zend_declare_property_long(error_exception_ce, "severity", sizeof("severity")-1, E_ERROR, ZEND_ACC_PROTECTED TSRMLS_CC);
}
-ZEND_API zend_class_entry *zend_exception_get_default(void)
+ZEND_API zend_class_entry *zend_exception_get_default(TSRMLS_D)
{
return default_exception_ce;
}
-ZEND_API zend_class_entry *zend_get_error_exception(void)
+ZEND_API zend_class_entry *zend_get_error_exception(TSRMLS_D)
{
return error_exception_ce;
}
exception_ce = default_exception_ce;
}
object_init_ex(ex, exception_ce);
-
+
if (message) {
zend_update_property_string(default_exception_ce, ex, "message", sizeof("message")-1, message TSRMLS_CC);
char *message;
zval *zexception;
- va_start(arg, format);
+ va_start(arg, format);
zend_vspprintf(&message, 0, format, arg);
va_end(arg);
zexception = zend_throw_exception(exception_ce, message, code TSRMLS_CC);
static void zend_error_va(int type, const char *file, uint lineno, const char *format, ...)
{
va_list args;
-
+
va_start(args, format);
zend_error_cb(type, file, lineno, format, args);
va_end(args);
zval *str, *file, *line;
EG(exception) = NULL;
-
+
zend_call_method_with_0_params(&exception, ce_exception, NULL, "__tostring", &str);
if (!EG(exception)) {
if (Z_TYPE_P(str) != IS_STRING) {
}
}
zval_ptr_dtor(&str);
-
+
if (EG(exception)) {
/* do the best we can to inform about the inner exception */
if (instanceof_function(ce_exception, default_exception_ce TSRMLS_CC)) {
file = NULL;
line = NULL;
}
- zend_error_va(E_WARNING, file ? Z_STRVAL_P(file) : NULL, line ? Z_LVAL_P(line) : 0, "Uncaught %s in exception handling during call to %s::__tostring()", Z_OBJCE_P(EG(exception))->name, ce_exception->name);
+ zend_error_va(E_WARNING, file ? Z_STRVAL_P(file) : NULL, line ? Z_LVAL_P(line) : 0, "Uncaught %v in exception handling during call to %v::__tostring()", Z_OBJCE_P(EG(exception))->name, ce_exception->name);
}
str = zend_read_property(default_exception_ce, exception, "string", sizeof("string")-1, 1 TSRMLS_CC);
{
zend_class_entry *exception_ce;
- if (exception == NULL || exception->type != IS_OBJECT) {
+ if (exception == NULL || Z_TYPE_P(exception) != IS_OBJECT) {
zend_error(E_ERROR, "Need to supply an object when throwing an exception");
}
void zend_register_default_exception(TSRMLS_D);
-ZEND_API zend_class_entry *zend_exception_get_default(void);
-ZEND_API zend_class_entry *zend_get_error_exception(void);
+ZEND_API zend_class_entry *zend_exception_get_default(TSRMLS_D);
+ZEND_API zend_class_entry *zend_get_error_exception(TSRMLS_D);
ZEND_API void zend_register_default_classes(TSRMLS_D);
-/* exception_ce NULL or zend_exception_get_default() or a derived class
+/* exception_ce NULL or zend_exception_get_default() or a derived class
* message NULL or the message of the exception */
ZEND_API zval * zend_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC);
ZEND_API zval * zend_throw_exception_ex(zend_class_entry *exception_ce, long code TSRMLS_DC, char *format, ...);
/* show an exception using zend_error(E_ERROR,...) */
ZEND_API void zend_exception_error(zval *exception TSRMLS_DC);
+/* do not export, in php it's available thru spprintf directly */
+int zend_spprintf(char **message, int max_len, char *format, ...);
+
END_EXTERN_C()
#endif
#include "zend_fast_cache.h"
#include "zend_ini.h"
#include "zend_exceptions.h"
+#include "zend_interfaces.h"
#include "zend_vm.h"
#define _CONST_CODE 0
#define INIT_PZVAL_COPY(z,v) \
(z)->value = (v)->value; \
- (z)->type = (v)->type; \
+ Z_TYPE_P(z) = Z_TYPE_P(v); \
(z)->refcount = 1; \
- (z)->is_ref = 0;
+ (z)->is_ref = 0;
#define MAKE_REAL_ZVAL_PTR(val) \
do { \
zval *_tmp; \
ALLOC_ZVAL(_tmp); \
_tmp->value = (val)->value; \
- _tmp->type = (val)->type; \
+ Z_TYPE_P(_tmp) = Z_TYPE_P(val); \
_tmp->refcount = 1; \
_tmp->is_ref = 0; \
val = _tmp; \
static inline zval *_get_zval_ptr_cv(znode *node, temp_variable *Ts, int type TSRMLS_DC)
{
zval ***ptr = &CV_OF(node->u.var);
-
+
if (!*ptr) {
zend_compiled_variable *cv = &CV_DEF_OF(node->u.var);
if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) {
static inline zval **_get_zval_ptr_ptr_cv(znode *node, temp_variable *Ts, int type TSRMLS_DC)
{
zval ***ptr = &CV_OF(node->u.var);
-
+
if (!*ptr) {
zend_compiled_variable *cv = &CV_DEF_OF(node->u.var);
if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) {
}
}
-static inline void zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zval *arg TSRMLS_DC)
+static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zval *arg TSRMLS_DC)
{
zend_arg_info *cur_arg_info;
zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data;
if (!zf->common.arg_info
|| arg_num>zf->common.num_args) {
- return;
+ return 1;
}
cur_arg_info = &zf->common.arg_info[arg_num-1];
if (cur_arg_info->class_name) {
if (!arg) {
if (ptr && ptr->op_array) {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an object of class %s, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, ptr->op_array->filename, ptr->opline->lineno);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an object of class %s, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, ptr->op_array->filename, ptr->opline->lineno);
} else {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an object of class %s", arg_num, fclass, fsep, fname, cur_arg_info->class_name);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an object of class %s", arg_num, fclass, fsep, fname, cur_arg_info->class_name);
}
+ return 0;
}
switch (Z_TYPE_P(arg)) {
case IS_NULL:
if (!cur_arg_info->allow_null) {
if (ptr && ptr->op_array) {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must not be null, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must not be null, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
} else {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must not be null", arg_num, fclass, fsep, fname);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must not be null", arg_num, fclass, fsep, fname);
}
+ return 0;
}
break;
case IS_OBJECT: {
zend_class_entry *ce = zend_fetch_class(cur_arg_info->class_name, cur_arg_info->class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
if (!instanceof_function(Z_OBJCE_P(arg), ce TSRMLS_CC)) {
char *error_msg;
-
- if (ce->ce_flags & ZEND_ACC_INTERFACE) {
+ if (ce->ce_flags & ZEND_ACC_INTERFACE) {
error_msg = "implement interface";
} else {
error_msg = "be an instance of";
}
if (ptr && ptr->op_array) {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must %s %s, called in %s on line %d and defined", arg_num, fclass, fsep, fname, error_msg, ce->name, ptr->op_array->filename, ptr->opline->lineno);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must %s %s, called in %s on line %d and defined", arg_num, fclass, fsep, fname, error_msg, ce->name, ptr->op_array->filename, ptr->opline->lineno);
} else {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must %s %s", arg_num, fclass, fsep, fname, error_msg, ce->name);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must %s %s", arg_num, fclass, fsep, fname, error_msg, ce->name);
}
+ return 0;
}
}
break;
default:
if (ptr && ptr->op_array) {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an object of class %s, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, ptr->op_array->filename, ptr->opline->lineno);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an object of class %s, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, ptr->op_array->filename, ptr->opline->lineno);
} else {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an object of class %s", arg_num, fclass, fsep, fname, cur_arg_info->class_name);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an object of class %s", arg_num, fclass, fsep, fname, cur_arg_info->class_name);
}
- break;
+ return 0;
}
} else if (cur_arg_info->array_type_hint) {
if (!arg) {
- if(ptr && ptr->op_array) {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an array, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
+ if (ptr && ptr->op_array) {
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an array, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
} else {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an array", arg_num, fclass, fsep, fname);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an array", arg_num, fclass, fsep, fname);
}
+ return 0;
}
switch (Z_TYPE_P(arg)) {
case IS_NULL:
if (!cur_arg_info->allow_null) {
if (ptr && ptr->op_array) {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must not be null, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must not be null, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
} else {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must not be null", arg_num, fclass, fsep, fname);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must not be null", arg_num, fclass, fsep, fname);
}
+ return 0;
}
break;
case IS_ARRAY:
break;
- default:
+ default:
if (ptr && ptr->op_array) {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an array, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an array, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
} else {
- zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an array", arg_num, fclass, fsep, fname);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an array", arg_num, fclass, fsep, fname);
}
- break;
+ return 0;
}
}
+ return 1;
}
make_real_object(object_ptr TSRMLS_CC); /* this should modify object only if it's empty */
object = *object_ptr;
-
- if (object->type != IS_OBJECT || (opcode == ZEND_ASSIGN_OBJ && !Z_OBJ_HT_P(object)->write_property)) {
+
+ if (Z_TYPE_P(object) != IS_OBJECT || (opcode == ZEND_ASSIGN_OBJ && !Z_OBJ_HT_P(object)->write_property)) {
zend_error(E_WARNING, "Attempt to assign property of non-object");
FREE_OP(free_op2);
if (!RETURN_VALUE_UNUSED(result)) {
FREE_OP(free_value);
return;
}
-
+
/* here we are sure we are dealing with an object */
/* separate our value if necessary */
- if (EG(ze1_compatibility_mode) && Z_TYPE_P(value) == IS_OBJECT) {
- zval *orig_value = value;
- char *class_name;
- zend_uint class_name_len;
- int dup;
-
- ALLOC_ZVAL(value);
- *value = *orig_value;
- value->is_ref = 0;
- value->refcount = 0;
- dup = zend_get_object_classname(orig_value, &class_name, &class_name_len TSRMLS_CC);
- if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", class_name);
- }
- zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
- value->value.obj = Z_OBJ_HANDLER_P(orig_value, clone_obj)(orig_value TSRMLS_CC);
- if(!dup) {
- efree(class_name);
- }
- } else if (value_op->op_type == IS_TMP_VAR) {
+ if (value_op->op_type == IS_TMP_VAR) {
zval *orig_value = value;
ALLOC_ZVAL(value);
value->refcount = 0;
zval_copy_ctor(value);
}
-
+
value->refcount++;
if (opcode == ZEND_ASSIGN_OBJ) {
}
Z_OBJ_HT_P(object)->write_dimension(object, property_name, value TSRMLS_CC);
}
-
+
if (result && !RETURN_VALUE_UNUSED(result)) {
T(result->u.var).var.ptr = value;
T(result->u.var).var.ptr_ptr = &T(result->u.var).var.ptr; /* this is so that we could use it in FETCH_DIM_R, etc. - see bug #27876 */
zend_free_op free_op1;
zval **variable_ptr_ptr = get_zval_ptr_ptr(op1, Ts, &free_op1, BP_VAR_W);
zval *variable_ptr;
-
+
if (!variable_ptr_ptr) {
temp_variable *T = &T(op1->u.var);
*/
} while (0);
/* zval_ptr_dtor(&T->str_offset.str); Nuke this line if it doesn't cause a leak */
-
+
/* T(result->u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); */
if (!RETURN_VALUE_UNUSED(result)) {
T(result->u.var).var.ptr_ptr = &value;
goto done_setting_var;
}
- if (EG(ze1_compatibility_mode) && Z_TYPE_P(value) == IS_OBJECT) {
- char *class_name;
- zend_uint class_name_len;
- int dup;
-
- dup = zend_get_object_classname(value, &class_name, &class_name_len TSRMLS_CC);
-
- if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", class_name);
- } else if (PZVAL_IS_REF(variable_ptr)) {
- if (variable_ptr != value) {
- zend_uint refcount = variable_ptr->refcount;
- zval garbage;
-
- if (type != IS_TMP_VAR) {
- value->refcount++;
- }
- garbage = *variable_ptr;
- *variable_ptr = *value;
- variable_ptr->refcount = refcount;
- variable_ptr->is_ref = 1;
- zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
- variable_ptr->value.obj = Z_OBJ_HANDLER_P(value, clone_obj)(value TSRMLS_CC);
- if (type != IS_TMP_VAR) {
- value->refcount--;
- }
- zendi_zval_dtor(garbage);
- }
- } else {
- if (variable_ptr != value) {
- value->refcount++;
- variable_ptr->refcount--;
- if (variable_ptr->refcount == 0) {
- zendi_zval_dtor(*variable_ptr);
- } else {
- ALLOC_ZVAL(variable_ptr);
- *variable_ptr_ptr = variable_ptr;
- }
- *variable_ptr = *value;
- INIT_PZVAL(variable_ptr);
- zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
- variable_ptr->value.obj = Z_OBJ_HANDLER_P(value, clone_obj)(value TSRMLS_CC);
- zval_ptr_dtor(&value);
- }
- }
- if (!dup) {
- efree(class_name);
- }
- } else if (PZVAL_IS_REF(variable_ptr)) {
+ if (PZVAL_IS_REF(variable_ptr)) {
if (variable_ptr!=value) {
zend_uint refcount = variable_ptr->refcount;
zval garbage;
-
+
if (type!=IS_TMP_VAR) {
value->refcount++;
}
variable_ptr->refcount++;
} else if (PZVAL_IS_REF(value)) {
zval tmp;
-
+
tmp = *value;
zval_copy_ctor(&tmp);
tmp.refcount=1;
}
(*variable_ptr_ptr)->is_ref=0;
}
-
+
done_setting_var:
if (result && !RETURN_VALUE_UNUSED(result)) {
T(result->u.var).var.ptr_ptr = variable_ptr_ptr;
PZVAL_LOCK(*variable_ptr_ptr);
AI_USE_PTR(T(result->u.var).var);
- }
+ }
FREE_OP_VAR_PTR(free_op1);
}
{
zval *variable_ptr = *variable_ptr_ptr;
- if (EG(ze1_compatibility_mode) && Z_TYPE_P(value) == IS_OBJECT) {
- char *class_name;
- zend_uint class_name_len;
- int dup;
-
- dup = zend_get_object_classname(value, &class_name, &class_name_len TSRMLS_CC);
-
- if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", class_name);
- } else {
- variable_ptr->refcount--;
- ALLOC_ZVAL(variable_ptr);
- *variable_ptr_ptr = variable_ptr;
- *variable_ptr = *value;
- INIT_PZVAL(variable_ptr);
- zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
- variable_ptr->value.obj = Z_OBJ_HANDLER_P(value, clone_obj)(value TSRMLS_CC);
- }
- if (!dup) {
- efree(class_name);
- }
- } else {
- variable_ptr->refcount--;
- *variable_ptr_ptr = value;
- value->refcount++;
- }
+ variable_ptr->refcount--;
+ *variable_ptr_ptr = value;
+ value->refcount++;
}
/* Utility Functions for Extensions */
zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", dim->value.lval, dim->value.lval);
/* Fall Through */
case IS_DOUBLE:
- case IS_BOOL:
+ case IS_BOOL:
case IS_LONG: {
long index;
- if (dim->type == IS_DOUBLE) {
- index = (long)dim->value.dval;
+ if (Z_TYPE_P(dim) == IS_DOUBLE) {
+ index = (long)Z_DVAL_P(dim);
} else {
- index = dim->value.lval;
+ index = Z_LVAL_P(dim);
}
if (zend_hash_index_find(ht, index, (void **) &retval) == FAILURE) {
switch (type) {
}
}
break;
- default:
+ default:
zend_error(E_WARNING, "Illegal offset type");
switch (type) {
case BP_VAR_R:
if (!container_ptr) {
zend_error_noreturn(E_ERROR, "Cannot use string offset as an array");
}
-
+
container = *container_ptr;
if (container == EG(error_zval_ptr)) {
}
}
- switch (container->type) {
+ switch (Z_TYPE_P(container)) {
zval **retval;
case IS_ARRAY:
zval *new_zval = &EG(uninitialized_zval);
new_zval->refcount++;
- if (zend_hash_next_index_insert(container->value.ht, &new_zval, sizeof(zval *), (void **) &retval) == FAILURE) {
+ if (zend_hash_next_index_insert(Z_ARRVAL_P(container), &new_zval, sizeof(zval *), (void **) &retval) == FAILURE) {
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
retval = &EG(error_zval_ptr);
- new_zval->refcount--;
+ new_zval->refcount--;
}
} else {
- retval = zend_fetch_dimension_address_inner(container->value.ht, dim, type TSRMLS_CC);
+ retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, type TSRMLS_CC);
}
if (result) {
result->var.ptr_ptr = retval;
zend_error_noreturn(E_ERROR, "[] operator not supported for strings");
}
- if (dim->type != IS_LONG) {
+ if (Z_TYPE_P(dim) != IS_LONG) {
tmp = *dim;
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
container = *container_ptr;
result->str_offset.str = container;
PZVAL_LOCK(container);
- result->str_offset.offset = dim->value.lval;
+ result->str_offset.offset = Z_LVAL_P(dim);
result->var.ptr_ptr = NULL;
if (type == BP_VAR_R || type == BP_VAR_IS) {
AI_USE_PTR(result->var);
zend_error_noreturn(E_ERROR, "Cannot use object as array");
} else {
zval *overloaded_result;
-
+
if (dim_is_tmp_var) {
zval *orig = dim;
MAKE_REAL_ZVAL_PTR(dim);
ZVAL_NULL(orig);
- }
+ }
overloaded_result = Z_OBJ_HT_P(container)->read_dimension(container, dim, type TSRMLS_CC);
if (overloaded_result) {
switch (type) {
case BP_VAR_RW:
case BP_VAR_W:
- if (overloaded_result->type != IS_OBJECT
+ if (Z_TYPE_P(overloaded_result) != IS_OBJECT
&& !overloaded_result->is_ref) {
zend_error_noreturn(E_ERROR, "Objects used as arrays in post/pre increment/decrement must return values by reference");
}
return;
}
break;
- default: {
+ default: {
switch (type) {
case BP_VAR_UNSET:
zend_error(E_WARNING, "Cannot unset offset in a non-array variable");
static void zend_fetch_property_address(temp_variable *result, zval **container_ptr, zval *prop_ptr, int type TSRMLS_DC)
{
zval *container;
-
+
container = *container_ptr;
if (container == EG(error_zval_ptr)) {
if (result) {
break;
}
}
-
- if (container->type != IS_OBJECT) {
+
+ if (Z_TYPE_P(container) != IS_OBJECT) {
if (result) {
if (type == BP_VAR_R || type == BP_VAR_IS) {
result->var.ptr_ptr = &EG(uninitialized_zval_ptr);
}
return;
}
-
+
if (Z_OBJ_HT_P(container)->get_property_ptr_ptr) {
zval **ptr_ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr TSRMLS_CC);
- if(NULL == ptr_ptr) {
+ if (NULL == ptr_ptr) {
zval *ptr;
if (Z_OBJ_HT_P(container)->read_property &&
- (ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, BP_VAR_W TSRMLS_CC)) != NULL) {
+ (ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, BP_VAR_W TSRMLS_CC)) != NULL) {
if (result) {
result->var.ptr = ptr;
result->var.ptr_ptr = &result->var.ptr;
result->var.ptr_ptr = &EG(error_zval_ptr);
}
}
-
+
if (result) {
PZVAL_LOCK(*result->var.ptr_ptr);
- }
+ }
}
static inline zend_brk_cont_element* zend_brk_cont(zval *nest_levels_zval, int array_offset, zend_op_array *op_array, temp_variable *Ts TSRMLS_DC)
} else if (Z_TYPE_PP(pz) == IS_ARRAY) {
zend_hash_apply(Z_ARRVAL_PP(pz), (apply_func_t) zend_check_symbol TSRMLS_CC);
} else if (Z_TYPE_PP(pz) == IS_OBJECT) {
-
+
/* OBJ-TBI - doesn't support new object model! */
zend_hash_apply(Z_OBJPROP_PP(pz), (apply_func_t) zend_check_symbol TSRMLS_CC);
}
}
#define ZEND_VM_NEXT_OPCODE() \
- CHECK_SYMBOL_TABLES() \
- EX(opline)++; \
- ZEND_VM_CONTINUE()
+ CHECK_SYMBOL_TABLES() \
+ EX(opline)++; \
+ ZEND_VM_CONTINUE()
#define ZEND_VM_SET_OPCODE(new_op) \
- CHECK_SYMBOL_TABLES() \
- EX(opline) = new_op
+ CHECK_SYMBOL_TABLES() \
+ EX(opline) = new_op
#define ZEND_VM_JMP(new_op) \
CHECK_SYMBOL_TABLES() \
ZEND_VM_CONTINUE()
#define ZEND_VM_INC_OPCODE() \
- if (!EG(exception)) { \
- CHECK_SYMBOL_TABLES() \
- EX(opline)++; \
- }
+ if (!EG(exception)) { \
+ CHECK_SYMBOL_TABLES() \
+ EX(opline)++; \
+ }
#define ZEND_VM_RETURN_FROM_EXECUTE_LOOP() \
- free_alloca(EX(CVs)); \
- if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \
- free_alloca(EX(Ts)); \
- } else { \
- efree(EX(Ts)); \
- } \
- EG(in_execution) = EX(original_in_execution); \
- EG(current_execute_data) = EX(prev_execute_data); \
- ZEND_VM_RETURN()
+ free_alloca(EX(CVs)); \
+ if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \
+ free_alloca(EX(Ts)); \
+ } else { \
+ efree(EX(Ts)); \
+ } \
+ EG(in_execution) = EX(original_in_execution); \
+ EG(current_execute_data) = EX(prev_execute_data); \
+ ZEND_VM_RETURN()
#include "zend_vm_execute.h"
#include "zend_compile.h"
#include "zend_hash.h"
-#include "zend_variables.h"
#include "zend_operators.h"
+#include "zend_variables.h"
typedef union _temp_variable {
zval tmp_var;
{
int result;
- switch (op->type) {
+ switch (Z_TYPE_P(op)) {
case IS_NULL:
result = 0;
break;
case IS_LONG:
case IS_BOOL:
case IS_RESOURCE:
- result = (op->value.lval?1:0);
+ result = (Z_LVAL_P(op)?1:0);
break;
case IS_DOUBLE:
- result = (op->value.dval ? 1 : 0);
+ result = (Z_DVAL_P(op) ? 1 : 0);
break;
case IS_STRING:
- if (op->value.str.len == 0
- || (op->value.str.len==1 && op->value.str.val[0]=='0')) {
+ if (Z_STRLEN_P(op) == 0
+ || (Z_STRLEN_P(op)==1 && Z_STRVAL_P(op)[0]=='0')) {
result = 0;
} else {
result = 1;
}
break;
case IS_ARRAY:
- result = (zend_hash_num_elements(op->value.ht)?1:0);
+ result = (zend_hash_num_elements(Z_ARRVAL_P(op))?1:0);
break;
case IS_OBJECT:
if(IS_ZEND_STD_OBJECT(*op)) {
if (Z_OBJ_HT_P(op)->cast_object) {
zval tmp;
- if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, IS_BOOL, 0 TSRMLS_CC) == SUCCESS) {
+ if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, IS_BOOL TSRMLS_CC) == SUCCESS) {
result = Z_LVAL(tmp);
break;
}
break;
}
}
-
- if(EG(ze1_compatibility_mode)) {
- result = (zend_hash_num_elements(Z_OBJPROP_P(op))?1:0);
- } else {
- result = 1;
- }
- } else {
- result = 1;
}
+ result = 1;
break;
default:
result = 0;
/* The following tries to resolve the classname of a zval of type object.
* Since it is slow it should be only used in error messages.
*/
-#define Z_OBJ_CLASS_NAME_P(zval) ((zval) && (zval)->type == IS_OBJECT && Z_OBJ_HT_P(zval)->get_class_entry != NULL && Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC) ? Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC)->name : "")
+#define Z_OBJ_CLASS_NAME_P(zval) ((zval) && Z_TYPE_P(zval) == IS_OBJECT && Z_OBJ_HT_P(zval)->get_class_entry != NULL && Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC) ? Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC)->name : "")
ZEND_API zval** zend_get_compiled_variable_value(zend_execute_data *execute_data_ptr, zend_uint var);
ALLOC_ZVAL(globals);
globals->refcount=1;
globals->is_ref=1;
- globals->type = IS_ARRAY;
- globals->value.ht = &EG(symbol_table);
+ Z_TYPE_P(globals) = IS_ARRAY;
+ Z_ARRVAL_P(globals) = &EG(symbol_table);
zend_hash_update(&EG(symbol_table), "GLOBALS", sizeof("GLOBALS"), &globals, sizeof(zval *), NULL);
}
EG(active_symbol_table) = &EG(symbol_table);
zval_dtor(*zval_ptr);
safe_free_zval_ptr_rel(*zval_ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC);
} else if ((*zval_ptr)->refcount == 1) {
- if ((*zval_ptr)->type == IS_OBJECT) {
- TSRMLS_FETCH();
-
- if (EG(ze1_compatibility_mode)) {
- return;
- }
- }
(*zval_ptr)->is_ref = 0;
}
}
zend_bool inline_change = (zend_bool) (unsigned long) arg;
zval const_value;
- if (p->type == IS_CONSTANT) {
+ if (Z_TYPE_P(p) == IS_CONSTANT) {
int refcount;
zend_uchar is_ref;
p->refcount = refcount;
p->is_ref = is_ref;
- } else if (p->type == IS_CONSTANT_ARRAY) {
+ } else if (Z_TYPE_P(p) == IS_CONSTANT_ARRAY) {
zval **element, *new_val;
char *str_index;
uint str_index_len;
SEPARATE_ZVAL_IF_NOT_REF(pp);
p = *pp;
- p->type = IS_ARRAY;
+ Z_TYPE_P(p) = IS_ARRAY;
/* First go over the array and see if there are any constant indices */
- zend_hash_internal_pointer_reset(p->value.ht);
- while (zend_hash_get_current_data(p->value.ht, (void **) &element)==SUCCESS) {
+ zend_hash_internal_pointer_reset(Z_ARRVAL_P(p));
+ while (zend_hash_get_current_data(Z_ARRVAL_P(p), (void **) &element)==SUCCESS) {
if (!(Z_TYPE_PP(element) & IS_CONSTANT_INDEX)) {
- zend_hash_move_forward(p->value.ht);
+ zend_hash_move_forward(Z_ARRVAL_P(p));
continue;
}
Z_TYPE_PP(element) &= ~IS_CONSTANT_INDEX;
- if (zend_hash_get_current_key_ex(p->value.ht, &str_index, &str_index_len, &num_index, 0, NULL)!=HASH_KEY_IS_STRING) {
- zend_hash_move_forward(p->value.ht);
+ if (zend_hash_get_current_key_ex(Z_ARRVAL_P(p), &str_index, &str_index_len, &num_index, 0, NULL)!=HASH_KEY_IS_STRING) {
+ zend_hash_move_forward(Z_ARRVAL_P(p));
continue;
}
if (!zend_get_constant(str_index, str_index_len-1, &const_value TSRMLS_CC)) {
zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", str_index, str_index);
- zend_hash_move_forward(p->value.ht);
+ zend_hash_move_forward(Z_ARRVAL_P(p));
continue;
}
zval_ptr_dtor(element);
*element = new_val;
- switch (const_value.type) {
+ switch (Z_TYPE(const_value)) {
case IS_STRING:
- zend_symtable_update_current_key(p->value.ht, const_value.value.str.val, const_value.value.str.len+1);
+ zend_symtable_update_current_key(Z_ARRVAL_P(p), const_value.value.str.val, const_value.value.str.len+1);
break;
case IS_BOOL:
case IS_LONG:
- zend_hash_update_current_key(p->value.ht, HASH_KEY_IS_LONG, NULL, 0, const_value.value.lval);
+ zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, NULL, 0, Z_LVAL(const_value));
break;
case IS_DOUBLE:
- zend_hash_update_current_key(p->value.ht, HASH_KEY_IS_LONG, NULL, 0, (long)const_value.value.dval);
+ zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, NULL, 0, (long)Z_DVAL(const_value));
break;
case IS_NULL:
- zend_hash_update_current_key(p->value.ht, HASH_KEY_IS_STRING, "", 1, 0);
+ zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_STRING, "", 1, 0);
break;
}
- zend_hash_move_forward(p->value.ht);
+ zend_hash_move_forward(Z_ARRVAL_P(p));
zval_dtor(&const_value);
}
- zend_hash_apply_with_argument(p->value.ht, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
- zend_hash_internal_pointer_reset(p->value.ht);
+ zend_hash_apply_with_argument(Z_ARRVAL_P(p), (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
+ zend_hash_internal_pointer_reset(Z_ARRVAL_P(p));
}
return 0;
}
*fci->retval_ptr_ptr = NULL;
if (!fci_cache || !fci_cache->initialized) {
- if (fci->function_name->type==IS_ARRAY) { /* assume array($obj, $name) couple */
+ if (Z_TYPE_P(fci->function_name)==IS_ARRAY) { /* assume array($obj, $name) couple */
zval **tmp_object_ptr, **tmp_real_function_name;
- if (zend_hash_index_find(fci->function_name->value.ht, 0, (void **) &tmp_object_ptr)==FAILURE) {
+ if (zend_hash_index_find(Z_ARRVAL_P(fci->function_name), 0, (void **) &tmp_object_ptr)==FAILURE) {
return FAILURE;
}
- if (zend_hash_index_find(fci->function_name->value.ht, 1, (void **) &tmp_real_function_name)==FAILURE) {
+ if (zend_hash_index_find(Z_ARRVAL_P(fci->function_name), 1, (void **) &tmp_real_function_name)==FAILURE) {
return FAILURE;
}
fci->function_name = *tmp_real_function_name;
if (found == FAILURE) {
zend_error(E_ERROR, "Class '%s' not found", Z_STRVAL_PP(fci->object_pp));
}
- if (scope && EG(This) &&
+ if (scope && EG(This) &&
instanceof_function(Z_OBJCE_P(EG(This)), scope TSRMLS_CC) &&
instanceof_function(scope, *ce TSRMLS_CC)) {
fci->object_pp = &EG(This);
fci->object_pp = fci_cache->object_pp;
EX(object) = fci->object_pp ? *fci->object_pp : NULL;
}
-
+
if (EX(function_state).function->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) {
if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) {
zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name);
ZVAL_STRINGL(class_name_ptr, name, name_length, 1);
args[0] = &class_name_ptr;
-
+
fcall_info.size = sizeof(fcall_info);
fcall_info.function_table = EG(function_table);
fcall_info.function_name = &autoload_function;
zend_hash_apply_with_argument(&ce->function_table, (apply_func_arg_t) zend_verify_abstract_class_function, &ai TSRMLS_CC);
- if (ai.cnt) {
- zend_error(E_ERROR, "Class %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
- ce->name, ai.cnt,
+ if (ai.cnt) {
+ zend_error(E_ERROR, "Class %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
+ ce->name, ai.cnt,
ai.cnt > 1 ? "s" : "",
DISPLAY_ABSTRACT_FN(0),
DISPLAY_ABSTRACT_FN(1),
new_extension->name);
DL_UNLOAD(handle);
return FAILURE;
- }
+ }
} else if (ZTS_V!=extension_version_info->thread_safe) {
fprintf(stderr, "Cannot load %s - it %s thread safe, whereas Zend %s\n",
new_extension->name,
* Support for dynamic loading of MH_BUNDLEs on Darwin / Mac OS X
*
*/
-
+
#if HAVE_MACH_O_DYLD_H
-void *zend_mh_bundle_load(char* bundle_path)
+void *zend_mh_bundle_load(char* bundle_path)
{
NSObjectFileImage bundle_image;
NSModule bundle_handle;
if (NSCreateObjectFileImageFromFile(bundle_path, &bundle_image) != NSObjectFileImageSuccess) {
return NULL;
}
-
+
bundle_handle = NSLinkModule(bundle_image, bundle_path, NSLINKMODULE_OPTION_PRIVATE);
NSDestroyObjectFileImage(bundle_image);
-
+
/* call the init function of the bundle */
bundle_init_nssymbol = NSLookupSymbolInModule(bundle_handle, "__init");
if (bundle_init_nssymbol != NULL) {
bundle_init = NSAddressOfSymbol(bundle_init_nssymbol);
bundle_init();
}
-
+
return bundle_handle;
}
{
NSSymbol bundle_fini_nssymbol;
void (*bundle_fini)(void);
-
+
/* call the fini function of the bundle */
bundle_fini_nssymbol = NSLookupSymbolInModule(bundle_handle, "__fini");
if (bundle_fini_nssymbol != NULL) {
bundle_fini = NSAddressOfSymbol(bundle_fini_nssymbol);
bundle_fini();
}
-
+
return (int) NSUnLinkModule(bundle_handle, NULL);
}
| Copyright (c) 1998-2006 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| 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 |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
#include "zend_compile.h"
/* The first number is the engine version and the rest is the date.
- * This way engine 2 API no. is always greater than engine 1 API no..
+ * This way engine 2/3 API no. is always greater than engine 1 API no..
*/
-#define ZEND_EXTENSION_API_NO 220051025
+#define ZEND_EXTENSION_API_NO 220060510
typedef struct _zend_extension_version_info {
int zend_extension_api_no;
op_array_handler_func_t op_array_handler;
- statement_handler_func_t statement_handler;
+ statement_handler_func_t statement_handler;
fcall_begin_handler_func_t fcall_begin_handler;
fcall_end_handler_func_t fcall_end_handler;
zend_function *autoload_func;
zend_bool bailout_set;
zend_bool full_tables_cleanup;
- zend_bool ze1_compatibility_mode;
/* for extended information support */
zend_bool no_extensions;
| Copyright (c) 1998-2006 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| 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 |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
ZEND_API zend_class_entry *zend_ce_arrayaccess;
ZEND_API zend_class_entry *zend_ce_serializable;
-/* {{{ zend_call_method
+/* {{{ zend_call_method
Only returns the returned zval if retval_ptr != NULL */
ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC)
{
/* iterator interface, c-level functions used by engine */
/* {{{ zend_user_it_new_iterator */
-static zval *zend_user_it_new_iterator(zend_class_entry *ce, zval *object TSRMLS_DC)
+ZEND_API zval *zend_user_it_new_iterator(zend_class_entry *ce, zval *object TSRMLS_DC)
{
zval *retval;
/* }}} */
/* {{{ zend_user_it_dtor */
-static void zend_user_it_invalidate_current(zend_object_iterator *_iter TSRMLS_DC)
+ZEND_API void zend_user_it_invalidate_current(zend_object_iterator *_iter TSRMLS_DC)
{
zend_user_iterator *iter = (zend_user_iterator*)_iter;
/* }}} */
/* {{{ zend_user_it_valid */
-static int zend_user_it_valid(zend_object_iterator *_iter TSRMLS_DC)
+ZEND_API int zend_user_it_valid(zend_object_iterator *_iter TSRMLS_DC)
{
if (_iter) {
zend_user_iterator *iter = (zend_user_iterator*)_iter;
zval *object = (zval*)iter->it.data;
zval *more;
int result;
-
+
zend_call_method_with_0_params(&object, iter->ce, &iter->ce->iterator_funcs.zf_valid, "valid", &more);
if (more) {
result = i_zend_is_true(more);
/* }}} */
/* {{{ zend_user_it_get_current_data */
-static void zend_user_it_get_current_data(zend_object_iterator *_iter, zval ***data TSRMLS_DC)
+ZEND_API void zend_user_it_get_current_data(zend_object_iterator *_iter, zval ***data TSRMLS_DC)
{
zend_user_iterator *iter = (zend_user_iterator*)_iter;
zval *object = (zval*)iter->it.data;
/* }}} */
/* {{{ zend_user_it_get_current_key */
-static int zend_user_it_get_current_key(zend_object_iterator *_iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+ZEND_API int zend_user_it_get_current_key(zend_object_iterator *_iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
{
zend_user_iterator *iter = (zend_user_iterator*)_iter;
zval *object = (zval*)iter->it.data;
case IS_DOUBLE:
case IS_RESOURCE:
- case IS_BOOL:
+ case IS_BOOL:
case IS_LONG: {
if (retval->type == IS_DOUBLE) {
*int_key = (long)retval->value.dval;
/* }}} */
/* {{{ zend_user_it_move_forward */
-static void zend_user_it_move_forward(zend_object_iterator *_iter TSRMLS_DC)
+ZEND_API void zend_user_it_move_forward(zend_object_iterator *_iter TSRMLS_DC)
{
zend_user_iterator *iter = (zend_user_iterator*)_iter;
zval *object = (zval*)iter->it.data;
/* }}} */
/* {{{ zend_user_it_rewind */
-static void zend_user_it_rewind(zend_object_iterator *_iter TSRMLS_DC)
+ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter TSRMLS_DC)
{
zend_user_iterator *iter = (zend_user_iterator*)_iter;
zval *object = (zval*)iter->it.data;
};
/* {{{ zend_user_it_get_iterator */
-static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zval *object TSRMLS_DC)
+static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)
{
- zend_user_iterator *iterator = emalloc(sizeof(zend_user_iterator));
+ zend_user_iterator *iterator;
+
+ if (by_ref) {
+ zend_error(E_ERROR, "An iterator cannot be used with foreach by reference");
+ }
+
+ iterator = emalloc(sizeof(zend_user_iterator));
object->refcount++;
iterator->it.data = (void*)object;
/* }}} */
/* {{{ zend_user_it_get_new_iterator */
-static zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *ce, zval *object TSRMLS_DC)
+ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)
{
zval *iterator = zend_user_it_new_iterator(ce, object TSRMLS_CC);
zend_object_iterator *new_iterator;
zend_class_entry *ce_it = iterator && Z_TYPE_P(iterator) == IS_OBJECT ? Z_OBJCE_P(iterator) : NULL;
- if (!ce || !ce_it || !ce_it->get_iterator || (ce_it->get_iterator == zend_user_it_get_new_iterator && iterator == object)) {
- if (!EG(exception))
- {
+ if (!ce_it || !ce_it->get_iterator || (ce_it->get_iterator == zend_user_it_get_new_iterator && iterator == object)) {
+ if (!EG(exception)) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Objects returned by %s::getIterator() must be traversable or implement interface Iterator", ce ? ce->name : Z_OBJCE_P(object)->name);
}
- if (iterator)
- {
+ if (iterator) {
zval_ptr_dtor(&iterator);
}
return NULL;
}
- new_iterator = ce_it->get_iterator(ce_it, iterator TSRMLS_CC);
+
+ new_iterator = ce_it->get_iterator(ce_it, iterator, by_ref TSRMLS_CC);
zval_ptr_dtor(&iterator);
return new_iterator;
}
} else if (class_type->get_iterator != zend_user_it_get_new_iterator) {
/* c-level get_iterator cannot be changed (exception being only Traversable is implmented) */
if (class_type->num_interfaces) {
- for (i = 0; i < (int)class_type->num_interfaces; i++) {
+ for (i = 0; i < class_type->num_interfaces; i++) {
if (class_type->interfaces[i] == zend_ce_iterator) {
return FAILURE;
}
}
if (result == FAILURE) {
- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "%s::serialize() must return a string or NULL", ce->name);
+ zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "%v::serialize() must return a string or NULL", ce->name);
}
return result;
}
zval * zdata;
object_init_ex(*object, ce);
-
+
MAKE_STD_ZVAL(zdata);
ZVAL_STRINGL(zdata, (char*)buf, buf_len, 1);
zend_call_method_with_1_params(object, ce, &ce->unserialize_func, "unserialize", NULL, zdata);
-
+
zval_ptr_dtor(&zdata);
-
+
if (EG(exception)) {
return FAILURE;
} else {
ZEND_END_ARG_INFO();
static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_arrayaccess_offset_value, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_arrayaccess_offset_value, 0, 0, 2)
ZEND_ARG_INFO(0, offset)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO();
zend_function_entry zend_funcs_serializable[] = {
ZEND_ABSTRACT_ME(serializable, serialize, NULL)
- ZEND_FENTRY(unserialize, NULL, arginfo_serializable_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT|ZEND_ACC_CTOR)
+ ZEND_FENTRY(unserialize, NULL, arginfo_serializable_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT|ZEND_ACC_CTOR)
{NULL, NULL, NULL}
};
/* }}} */
REGISTER_ITERATOR_INTERFACE(iterator, Iterator);
REGISTER_ITERATOR_IMPLEMENT(iterator, traversable);
-
+
REGISTER_ITERATOR_INTERFACE(arrayaccess, ArrayAccess);
-
+
REGISTER_ITERATOR_INTERFACE(serializable, Serializable)
}
/* }}} */
ZEND_API zval *zend_iterator_wrap(zend_object_iterator *iter TSRMLS_DC)
{
zval *wrapped;
-
+
MAKE_STD_ZVAL(wrapped);
Z_TYPE_P(wrapped) = IS_OBJECT;
- wrapped->value.obj.handle = zend_objects_store_put(iter, iter_wrapper_dtor, NULL, NULL TSRMLS_CC);
- wrapped->value.obj.handlers = &iterator_object_handlers;
+ Z_OBJ_HANDLE_P(wrapped) = zend_objects_store_put(iter, iter_wrapper_dtor, NULL, NULL TSRMLS_CC);
+ Z_OBJ_HT_P(wrapped) = &iterator_object_handlers;
return wrapped;
}
return ZEND_ITER_PLAIN_OBJECT;
}
return ZEND_ITER_INVALID;
-
-
+
case IS_ARRAY:
if (HASH_OF(array_ptr)) {
return ZEND_ITER_PLAIN_ARRAY;
}
return ZEND_ITER_INVALID;
-
+
default:
return ZEND_ITER_INVALID;
}
| Copyright (c) 1998-2006 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| 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 |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
typedef struct _zend_object_iterator_funcs {
/* release all resources associated with this iterator instance */
void (*dtor)(zend_object_iterator *iter TSRMLS_DC);
-
+
/* check for end of iteration (FAILURE or SUCCESS if data is valid) */
int (*valid)(zend_object_iterator *iter TSRMLS_DC);
/* rewind to start of data (optional, may be NULL) */
void (*rewind)(zend_object_iterator *iter TSRMLS_DC);
-
+
/* invalidate current value/key (optional, may be NULL) */
void (*invalidate_current)(zend_object_iterator *iter TSRMLS_DC);
} zend_object_iterator_funcs;
ulong index; /* private to fe_reset/fe_fetch opcodes */
};
-typedef zval *(*zend_object_new_iterator_t)(zend_class_entry *ce, zval *object TSRMLS_DC);
-
typedef struct _zend_class_iterator_funcs {
zend_object_iterator_funcs *funcs;
- zend_object_new_iterator_t new_iterator;
union _zend_function *zf_new_iterator;
union _zend_function *zf_valid;
union _zend_function *zf_current;
| Copyright (c) 1998-2006 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| 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 |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
-/*
+/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
enable accessors to change properties array.
if we have __call and method which is not part of the class function table is
- called, we cal __call handler.
+ called, we cal __call handler.
*/
static HashTable *zend_std_get_properties(zval *object TSRMLS_DC)
{
zval *retval = NULL;
zend_class_entry *ce = Z_OBJCE_P(object);
-
+
/* __get handler is called with one argument:
property name
it should return whether the call was successfull or not
*/
-
+
SEPARATE_ARG_IF_REF(member);
zend_call_method_with_1_params(&object, ce, &ce->__get, ZEND_GET_FUNC_NAME, &retval, member);
static void zend_std_call_unsetter(zval *object, zval *member TSRMLS_DC)
{
zend_class_entry *ce = Z_OBJCE_P(object);
-
+
/* __unset handler is called with one argument:
property name
*/
-
+
SEPARATE_ARG_IF_REF(member);
zend_call_method_with_1_params(&object, ce, &ce->__unset, ZEND_UNSET_FUNC_NAME, NULL, member);
{
zval *retval = NULL;
zend_class_entry *ce = Z_OBJCE_P(object);
-
+
/* __isset handler is called with one argument:
property name
it should return whether the property is set or not
*/
-
+
SEPARATE_ARG_IF_REF(member);
zend_call_method_with_1_params(&object, ce, &ce->__isset, ZEND_ISSET_FUNC_NAME, &retval, member);
if (rv) {
retval = &rv;
} else {
- retval = &EG(uninitialized_zval_ptr);
+ retval = &EG(uninitialized_zval_ptr);
}
} else {
if (!silent) {
{
zend_class_entry *ce = Z_OBJCE_P(object);
zval *retval;
-
+
if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) {
if(offset == NULL) {
/* [] construct */
zend_class_entry *ce = Z_OBJCE_P(object);
zval *retval;
int result;
-
+
if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) {
SEPARATE_ARG_IF_REF(offset);
zend_call_method_with_1_params(&object, ce, NULL, "offsetexists", &retval, offset);
zval tmp_member;
zval **retval;
zend_property_info *property_info;
-
+
zobj = Z_OBJ_P(object);
if (member->type != IS_STRING) {
#if DEBUG_OBJECT_HANDLERS
fprintf(stderr, "Ptr object #%d property: %s\n", Z_OBJ_HANDLE_P(object), Z_STRVAL_P(member));
-#endif
+#endif
property_info = zend_get_property_info(zobj->ce, member, (zobj->ce->__get != NULL) TSRMLS_CC);
zend_object *zobj;
zval *tmp_member = NULL;
zend_property_info *property_info;
-
+
zobj = Z_OBJ_P(object);
if (member->type != IS_STRING) {
}
property_info = zend_get_property_info(zobj->ce, member, (zobj->ce->__unset != NULL) TSRMLS_CC);
-
+
if (!property_info || zend_hash_del(zobj->properties, property_info->name, property_info->name_length+1) == FAILURE) {
zend_guard *guard;
static void zend_std_unset_dimension(zval *object, zval *offset TSRMLS_DC)
{
zend_class_entry *ce = Z_OBJCE_P(object);
-
+
if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) {
SEPARATE_ARG_IF_REF(offset);
zend_call_method_with_1_params(&object, ce, NULL, "offsetunset", NULL, offset);
zval *method_name_ptr, *method_args_ptr;
zval *method_result_ptr = NULL;
zend_class_entry *ce = Z_OBJCE_P(this_ptr);
-
+
ALLOC_ZVAL(method_args_ptr);
INIT_PZVAL(method_args_ptr);
array_init(method_args_ptr);
RETVAL_ZVAL(method_result_ptr, 0, 1);
}
}
-
+
/* now destruct all auxiliaries */
zval_ptr_dtor(&method_args_ptr);
zval_ptr_dtor(&method_name_ptr);
if (zobj->ce->__call) {
zend_internal_function *call_user_call = emalloc(sizeof(zend_internal_function));
call_user_call->type = ZEND_INTERNAL_FUNCTION;
+ call_user_call->module = zobj->ce->module;
call_user_call->handler = zend_std_call_user_call;
call_user_call->arg_info = NULL;
call_user_call->num_args = 0;
/* Ensure that if we're calling a private function, we're allowed to do so.
*/
- updated_fbc = zend_check_private_int(fbc, object->value.obj.handlers->get_class_entry(object TSRMLS_CC), lc_method_name, method_len TSRMLS_CC);
+ updated_fbc = zend_check_private_int(fbc, Z_OBJ_HANDLER_P(object, get_class_entry)(object TSRMLS_CC), lc_method_name, method_len TSRMLS_CC);
if (!updated_fbc) {
zend_error(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name, EG(scope) ? EG(scope)->name : "");
}
/* Ensure that if we're calling a private function, we're allowed to do so.
*/
- updated_fbc = zend_check_private_int(fbc, EG(scope), function_name_strval, function_name_strlen TSRMLS_CC);
+ updated_fbc = zend_check_private_int(fbc, EG(scope), function_name_strval, function_name_strlen TSRMLS_CC);
if (!updated_fbc) {
zend_error(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), function_name_strval, EG(scope) ? EG(scope)->name : "");
}
zend_error(E_ERROR, "Access to undeclared static property: %s::$%s", ce->name, property_name);
}
}
-
+
return retval;
}
} else if (constructor->op_array.fn_flags & ZEND_ACC_PRIVATE) {
/* Ensure that if we're calling a private function, we're allowed to do so.
*/
- if (object->value.obj.handlers->get_class_entry(object TSRMLS_CC) != EG(scope)) {
+ if (Z_OBJ_HANDLER_P(object, get_class_entry)(object TSRMLS_CC) != EG(scope)) {
zend_error(E_ERROR, "Call to private %s::%s() from context '%s'", constructor->common.scope->name, constructor->common.function_name, EG(scope) ? EG(scope)->name : "");
}
} else if ((constructor->common.fn_flags & ZEND_ACC_PROTECTED)) {
static int zend_std_compare_objects(zval *o1, zval *o2 TSRMLS_DC)
{
zend_object *zobj1, *zobj2;
-
+
zobj1 = Z_OBJ_P(o1);
zobj2 = Z_OBJ_P(o2);
zval **value;
zval *tmp_member = NULL;
zend_property_info *property_info;
-
+
zobj = Z_OBJ_P(object);
- if (member->type != IS_STRING) {
- ALLOC_ZVAL(tmp_member);
+ if (member->type != IS_STRING) {
+ ALLOC_ZVAL(tmp_member);
*tmp_member = *member;
INIT_PZVAL(tmp_member);
zval_copy_ctor(tmp_member);
#if DEBUG_OBJECT_HANDLERS
fprintf(stderr, "Read object #%d property: %s\n", Z_OBJ_HANDLE_P(object), Z_STRVAL_P(member));
-#endif
+#endif
property_info = zend_get_property_info(zobj->ce, member, 1 TSRMLS_CC);
return SUCCESS;
}
-ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC)
+ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type TSRMLS_DC)
{
- zval fname, *retval;
-
+ zval *retval;
+ zend_class_entry *ce;
+
switch (type) {
case IS_STRING:
- if (!zend_hash_exists(&Z_OBJCE_P(readobj)->function_table, "__tostring", sizeof("__tostring"))) {
- return FAILURE;
- }
- ZVAL_STRING(&fname, "__tostring", 0);
- if (call_user_function_ex(NULL, &readobj, &fname, &retval, 0, NULL, 0, NULL TSRMLS_CC) == SUCCESS) {
- if (retval) {
- if (Z_TYPE_P(retval) != IS_STRING) {
- zend_error(E_ERROR, "Method %s::__toString() must return a string value", Z_OBJCE_P(readobj)->name);
+ ce = Z_OBJCE_P(readobj);
+ if (ce->__tostring &&
+ zend_call_method_with_0_params(&readobj, ce, &ce->__tostring, "__tostring", &retval)) {
+ if (EG(exception)) {
+ zval_ptr_dtor(&retval);
+ zend_error(E_ERROR, "Method %s::__toString() must not throw an exception", ce->name);
+ return FAILURE;
+ }
+ if (Z_TYPE_P(retval) == IS_STRING) {
+ INIT_PZVAL(writeobj);
+ ZVAL_ZVAL(writeobj, retval, 1, 1);
+ if (Z_TYPE_P(writeobj) != type) {
+ convert_to_explicit_type(writeobj, type);
}
+ return SUCCESS;
} else {
- MAKE_STD_ZVAL(retval);
- ZVAL_STRINGL(retval, "", 0, 1);
+ zval_ptr_dtor(&retval);
+ INIT_PZVAL(writeobj);
+ ZVAL_EMPTY_STRING(writeobj);
+ zend_error(E_RECOVERABLE_ERROR, "Method %s::__toString() must return a string value", ce->name);
+ return SUCCESS;
}
- *writeobj = *retval;
- zval_copy_ctor(writeobj);
- INIT_PZVAL(writeobj);
- zval_ptr_dtor(&retval);
- return SUCCESS;
}
- break;
+ return FAILURE;
+ case IS_BOOL:
+ INIT_PZVAL(writeobj);
+ ZVAL_BOOL(writeobj, 1);
+ return SUCCESS;
+ case IS_LONG:
+ ce = Z_OBJCE_P(readobj);
+ zend_error(E_NOTICE, "Object of class %s could not be converted to int", ce->name);
+ INIT_PZVAL(writeobj);
+ ZVAL_LONG(writeobj, 1);
+ return SUCCESS;
+ case IS_DOUBLE:
+ ce = Z_OBJCE_P(readobj);
+ zend_error(E_NOTICE, "Object of class %s could not be converted to double", ce->name);
+ INIT_PZVAL(writeobj);
+ ZVAL_DOUBLE(writeobj, 1);
+ return SUCCESS;
default:
break;
}
zend_objects_store_add_ref, /* add_ref */
zend_objects_store_del_ref, /* del_ref */
zend_objects_clone_obj, /* clone_obj */
-
+
zend_std_read_property, /* read_property */
zend_std_write_property, /* write_property */
zend_std_read_dimension, /* read_dimension */
zend_std_object_get_class, /* get_class_entry */
zend_std_object_get_class_name, /* get_class_name */
zend_std_compare_objects, /* compare_objects */
- NULL, /* cast_object */
+ zend_std_cast_object_tostring, /* cast_object */
NULL, /* count_elements */
};
-/*
+/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
typedef zend_class_entry *(*zend_object_get_class_entry_t)(zval *object TSRMLS_DC);
typedef int (*zend_object_get_class_name_t)(zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC);
typedef int (*zend_object_compare_t)(zval *object1, zval *object2 TSRMLS_DC);
-typedef int (*zend_object_cast_t)(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC);
+
+/* Cast an object to some other type
+ */
+typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type TSRMLS_DC);
/* updates *count to hold the number of elements present and returns SUCCESS.
* Returns FAILURE if the object does not have any sense of overloaded dimensions */
ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, char *property_name, int property_name_len TSRMLS_DC);
ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zval *member, int silent TSRMLS_DC);
-ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC);
+ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type TSRMLS_DC);
-#define IS_ZEND_STD_OBJECT(z) ((z).type == IS_OBJECT && (Z_OBJ_HT((z))->get_class_entry != NULL))
+#define IS_ZEND_STD_OBJECT(z) (Z_TYPE(z) == IS_OBJECT && (Z_OBJ_HT((z))->get_class_entry != NULL))
#define HAS_CLASS_ENTRY(z) (Z_OBJ_HT(z)->get_class_entry != NULL)
ZEND_API int zend_check_private(union _zend_function *fbc, zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC);
ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object_value new_obj_val, zend_object *old_object, zend_object_handle handle TSRMLS_DC)
{
- if (EG(ze1_compatibility_mode)) {
- zend_hash_copy(new_object->properties, old_object->properties, (copy_ctor_func_t) zval_add_ref_or_clone, (void *) NULL /* Not used anymore */, sizeof(zval *));
- } else {
- zend_hash_copy(new_object->properties, old_object->properties, (copy_ctor_func_t) zval_add_ref, (void *) NULL /* Not used anymore */, sizeof(zval *));
- }
+ zend_hash_copy(new_object->properties, old_object->properties, (copy_ctor_func_t) zval_add_ref, (void *) NULL /* Not used anymore */, sizeof(zval *));
+
if (old_object->ce->clone) {
zval *new_obj;
-/*
+/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
{
zend_object_handle handle;
struct _store_object *obj;
-
+
if (EG(objects_store).free_list_head != -1) {
handle = EG(objects_store).free_list_head;
EG(objects_store).free_list_head = EG(objects_store).object_buckets[handle].bucket.free_list.next;
#endif
}
+/*
+ * Add a reference to an objects store entry given the object handle.
+ */
+ZEND_API void zend_objects_store_add_ref_by_handle(zend_object_handle handle TSRMLS_DC)
+{
+ EG(objects_store).object_buckets[handle].bucket.obj.refcount++;
+}
+
#define ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST() \
EG(objects_store).object_buckets[handle].bucket.free_list.next = EG(objects_store).free_list_head; \
EG(objects_store).free_list_head = handle; \
ZEND_API void zend_objects_store_del_ref(zval *zobject TSRMLS_DC)
{
zend_object_handle handle;
+
+ handle = Z_OBJ_HANDLE_P(zobject);
+
+ zobject->refcount++;
+ zend_objects_store_del_ref_by_handle(handle TSRMLS_CC);
+ zobject->refcount--;
+}
+
+/*
+ * Delete a reference to an objects store entry given the object handle.
+ */
+ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSRMLS_DC)
+{
struct _store_object *obj;
if (!EG(objects_store).object_buckets) {
return;
}
- handle = Z_OBJ_HANDLE_P(zobject);
obj = &EG(objects_store).object_buckets[handle].bucket.obj;
/* Make sure we hold a reference count during the destructor call
otherwise, when the destructor ends the storage might be freed
when the refcount reaches 0 a second time
- */
+ */
if (EG(objects_store).object_buckets[handle].valid) {
if (obj->refcount == 1) {
if (!EG(objects_store).object_buckets[handle].destructor_called) {
EG(objects_store).object_buckets[handle].destructor_called = 1;
if (obj->dtor) {
- zobject->refcount++;
obj->dtor(obj->object, handle TSRMLS_CC);
- zobject->refcount--;
}
}
if (obj->refcount == 1) {
zend_object_handle handle = Z_OBJ_HANDLE_P(zobject);
obj = &EG(objects_store).object_buckets[handle].bucket.obj;
-
+
if (obj->clone == NULL) {
zend_error(E_CORE_ERROR, "Trying to clone uncloneable object of class %s", Z_OBJCE_P(zobject)->name);
- }
+ }
obj->clone(obj->object, &new_object TSRMLS_CC);
retval.handle = zend_objects_store_put(new_object, obj->dtor, obj->free_storage, obj->clone TSRMLS_CC);
retval.handlers = Z_OBJ_HT_P(zobject);
-
+
return retval;
}
return EG(objects_store).object_buckets[handle].bucket.obj.object;
}
+/*
+ * Retrieve an entry from the objects store given the object handle.
+ */
+ZEND_API void *zend_object_store_get_object_by_handle(zend_object_handle handle TSRMLS_DC)
+{
+ return EG(objects_store).object_buckets[handle].bucket.obj.object;
+}
+
/* zend_object_store_set_object:
* It is ONLY valid to call this function from within the constructor of an
* overloaded object. Its purpose is to set the object pointer for the object
zval_add_ref(&pobj->object);
MAKE_STD_ZVAL(retval);
- retval->type = IS_OBJECT;
+ Z_TYPE_P(retval) = IS_OBJECT;
Z_OBJ_HANDLE_P(retval) = zend_objects_store_put(pobj, NULL, (zend_objects_free_object_storage_t) zend_objects_proxy_free_storage, (zend_objects_store_clone_t) zend_objects_proxy_clone TSRMLS_CC);
Z_OBJ_HT_P(retval) = &zend_object_proxy_handlers;
-
+
return retval;
}
static zend_object_handlers zend_object_proxy_handlers = {
ZEND_OBJECTS_STORE_HANDLERS,
-
+
NULL, /* read_property */
NULL, /* write_property */
NULL, /* read dimension */
-/*
+/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
ZEND_API void zend_objects_store_add_ref(zval *object TSRMLS_DC);
ZEND_API void zend_objects_store_del_ref(zval *object TSRMLS_DC);
+ZEND_API void zend_objects_store_add_ref_by_handle(zend_object_handle handle TSRMLS_DC);
+ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSRMLS_DC);
ZEND_API zend_object_value zend_objects_store_clone_obj(zval *object TSRMLS_DC);
ZEND_API void *zend_object_store_get_object(zval *object TSRMLS_DC);
+ZEND_API void *zend_object_store_get_object_by_handle(zend_object_handle handle TSRMLS_DC);
/* See comment in zend_objects_API.c before you use this */
ZEND_API void zend_object_store_set_object(zval *zobject, void *object TSRMLS_DC);
ZEND_API void zend_object_store_ctor_failed(zval *zobject TSRMLS_DC);
}
-#define convert_object_to_type(op, ctype, conv_func) \
+#define convert_object_to_type(op, ctype, conv_func) \
if (Z_OBJ_HT_P(op)->cast_object) { \
- if (Z_OBJ_HT_P(op)->cast_object(op, op, ctype, 1 TSRMLS_CC) == SUCCESS) { \
- op->type = ctype; \
+ zval dst; \
+ if (Z_OBJ_HT_P(op)->cast_object(op, &dst, ctype TSRMLS_CC) == FAILURE) { \
+ zend_error(E_RECOVERABLE_ERROR, \
+ "Object of class %s could not be converted to " # ctype, Z_OBJCE_P(op)->name); \
+ } else { \
+ zval_dtor(op); \
+ Z_TYPE_P(op) = ctype; \
+ op->value = dst.value; \
} \
} else { \
if(Z_OBJ_HT_P(op)->get) { \
return;
}
- if (EG(ze1_compatibility_mode)) {
- HashTable *ht = Z_OBJPROP_P(op);
- if (ht) {
- retval = (zend_hash_num_elements(ht)?1:0);
- }
- } else {
- zend_error(E_NOTICE, "Object of class %s could not be converted to int", Z_OBJCE_P(op)->name);
- }
+ zend_error(E_NOTICE, "Object of class %s could not be converted to int", Z_OBJCE_P(op)->name);
zval_dtor(op);
ZVAL_LONG(op, retval);
return;
return;
}
- if (EG(ze1_compatibility_mode)) {
- HashTable *ht = Z_OBJPROP_P(op);
- if (ht) {
- retval = (zend_hash_num_elements(ht)?1.0:0.0);
- }
- } else {
- zend_error(E_NOTICE, "Object of class %s could not be converted to double", Z_OBJCE_P(op)->name);
- }
-
+ zend_error(E_NOTICE, "Object of class %s could not be converted to double", Z_OBJCE_P(op)->name);
zval_dtor(op);
ZVAL_DOUBLE(op, retval);
break;
ZEND_API void convert_to_null(zval *op)
{
- if (op->type == IS_OBJECT) {
+ if (Z_TYPE_P(op) == IS_OBJECT) {
if (Z_OBJ_HT_P(op)->cast_object) {
+ zval *org;
TSRMLS_FETCH();
- if (Z_OBJ_HT_P(op)->cast_object(op, op, IS_NULL, 1 TSRMLS_CC) == SUCCESS) {
+
+ ALLOC_ZVAL(org);
+ *org = *op;
+ if (Z_OBJ_HT_P(op)->cast_object(org, op, IS_NULL TSRMLS_CC) == SUCCESS) {
+ zval_dtor(org);
return;
}
+ *op = *org;
}
}
zval_dtor(op);
- op->type = IS_NULL;
+ Z_TYPE_P(op) = IS_NULL;
}
return;
}
- if (EG(ze1_compatibility_mode)) {
- HashTable *ht = Z_OBJPROP_P(op);
- if (ht) {
- retval = (zend_hash_num_elements(ht)?1:0);
- }
- }
-
zval_dtor(op);
ZVAL_BOOL(op, retval);
break;
op1 = op1_free = Z_OBJ_HT_P(op1)->get(op1 TSRMLS_CC);
} else if (!op2_obj && Z_OBJ_HT_P(op1)->cast_object) {
ALLOC_INIT_ZVAL(op1_free);
- if (Z_OBJ_HT_P(op1)->cast_object(op1, op1_free, Z_TYPE_P(op2), 0 TSRMLS_CC) == FAILURE) {
+ if (Z_OBJ_HT_P(op1)->cast_object(op1, op1_free, Z_TYPE_P(op2) TSRMLS_CC) == FAILURE) {
op2_free = NULL;
ZVAL_BOOL(result, 0);
COMPARE_RETURN_AND_FREE(FAILURE);
op2 = op2_free = Z_OBJ_HT_P(op2)->get(op2 TSRMLS_CC);
} else if (!op1_obj && Z_OBJ_HT_P(op2)->cast_object) {
ALLOC_INIT_ZVAL(op2_free);
- if (Z_OBJ_HT_P(op2)->cast_object(op2, op2_free, Z_TYPE_P(op1), 0 TSRMLS_CC) == FAILURE) {
+ if (Z_OBJ_HT_P(op2)->cast_object(op2, op2_free, Z_TYPE_P(op1) TSRMLS_CC) == FAILURE) {
ZVAL_BOOL(result, 0);
COMPARE_RETURN_AND_FREE(FAILURE);
}
break;
case IS_OBJECT:
if (Z_OBJ_HT_P(op1) == Z_OBJ_HT_P(op2)) {
- if (EG(ze1_compatibility_mode)) {
- zend_compare_objects(result, op1, op2 TSRMLS_CC);
- /* comparison returns 0 in case of equality and
- * 1 in case of ineqaulity, we need to reverse it
- */
- result->value.lval = !result->value.lval;
- } else {
- result->value.lval = (Z_OBJ_HANDLE_P(op1) == Z_OBJ_HANDLE_P(op2));
- }
+ result->value.lval = (Z_OBJ_HANDLE_P(op1) == Z_OBJ_HANDLE_P(op2));
} else {
result->value.lval = 0;
}
#include <errno.h>
#include <math.h>
+#include <assert.h>
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
if (!length) {
return 0;
}
-
+
/* handle hex numbers */
if (length>=2 && str[0]=='0' && (str[1]=='x' || str[1]=='X')) {
conv_base=16;
return p;
}
}
-
+
if (p == NULL) {
return NULL;
}
-
+
p++;
}
-
+
return NULL;
}
convert_to_##lower_type(*ppzv); \
}
+#define convert_to_explicit_type(pzv, type) \
+ do { \
+ switch (type) { \
+ case IS_NULL: \
+ convert_to_null(pzv); \
+ break; \
+ case IS_LONG: \
+ convert_to_long(pzv); \
+ break; \
+ case IS_DOUBLE: \
+ convert_to_double(pzv); \
+ break; \
+ case IS_BOOL: \
+ convert_to_boolean(pzv); \
+ break; \
+ case IS_ARRAY: \
+ convert_to_array(pzv); \
+ break; \
+ case IS_OBJECT: \
+ convert_to_object(pzv); \
+ break; \
+ case IS_STRING: \
+ convert_to_string(pzv); \
+ break; \
+ default: \
+ assert(0); \
+ break; \
+ } \
+ } while (0); \
+
+#define convert_to_explicit_type_ex(ppzv, str_type) \
+ if (Z_TYPE_PP(ppzv) != str_type) { \
+ SEPARATE_ZVAL_IF_NOT_REF(ppzv); \
+ convert_to_explicit_type(*ppzv, str_type); \
+ }
#define convert_to_boolean_ex(ppzv) convert_to_ex_master(ppzv, boolean, BOOL)
#define convert_to_long_ex(ppzv) convert_to_ex_master(ppzv, long, LONG)
#define convert_to_null_ex(ppzv) convert_to_ex_master(ppzv, null, NULL)
#define convert_scalar_to_number_ex(ppzv) \
- if ((*ppzv)->type!=IS_LONG && (*ppzv)->type!=IS_DOUBLE) { \
+ if (Z_TYPE_PP(ppzv)!=IS_LONG && Z_TYPE_PP(ppzv)!=IS_DOUBLE) { \
if (!(*ppzv)->is_ref) { \
SEPARATE_ZVAL(ppzv); \
} \
#define Z_STRLEN(zval) (zval).value.str.len
#define Z_ARRVAL(zval) (zval).value.ht
#define Z_OBJVAL(zval) (zval).value.obj
-#define Z_OBJ_HANDLE(zval) (zval).value.obj.handle
-#define Z_OBJ_HT(zval) (zval).value.obj.handlers
+#define Z_OBJ_HANDLE(zval) Z_OBJVAL(zval).handle
+#define Z_OBJ_HT(zval) Z_OBJVAL(zval).handlers
#define Z_OBJCE(zval) zend_get_class_entry(&(zval) TSRMLS_CC)
#define Z_OBJPROP(zval) Z_OBJ_HT((zval))->get_properties(&(zval) TSRMLS_CC)
#define Z_OBJ_HANDLER(zval, hf) Z_OBJ_HT((zval))->hf
#define Z_OBJVAL_P(zval_p) Z_OBJVAL(*zval_p)
#define Z_OBJ_HANDLE_P(zval_p) Z_OBJ_HANDLE(*zval_p)
#define Z_OBJ_HT_P(zval_p) Z_OBJ_HT(*zval_p)
-#define Z_OBJ_HANDLER_P(zval_p, h) Z_OBJ_HANDLER(*zval_p, h)
+#define Z_OBJ_HANDLER_P(zval_p, h) Z_OBJ_HANDLER(*zval_p, h)
#define Z_LVAL_PP(zval_pp) Z_LVAL(**zval_pp)
#define Z_BVAL_PP(zval_pp) Z_BVAL(**zval_pp)
#define Z_OBJVAL_PP(zval_pp) Z_OBJVAL(**zval_pp)
#define Z_OBJ_HANDLE_PP(zval_p) Z_OBJ_HANDLE(**zval_p)
#define Z_OBJ_HT_PP(zval_p) Z_OBJ_HT(**zval_p)
-#define Z_OBJ_HANDLER_PP(zval_p, h) Z_OBJ_HANDLER(**zval_p, h)
+#define Z_OBJ_HANDLER_PP(zval_p, h) Z_OBJ_HANDLER(**zval_p, h)
#define Z_TYPE(zval) (zval).type
#define Z_TYPE_P(zval_p) Z_TYPE(*zval_p)
zval *z = GET_OP1_ZVAL_PTR(BP_VAR_R);
if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL &&
- zend_std_cast_object_tostring(z, &z_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
+ zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
zend_print_variable(&z_copy);
zval_dtor(&z_copy);
} else {
retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
- if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) {
- zval *ret;
- char *class_name;
- zend_uint class_name_len;
- int dup;
-
- ALLOC_ZVAL(ret);
- INIT_PZVAL_COPY(ret, retval_ptr);
- dup = zend_get_object_classname(retval_ptr, &class_name, &class_name_len TSRMLS_CC);
- if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", class_name);
- }
- zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
- ret->value.obj = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC);
- *EG(return_value_ptr_ptr) = ret;
- if (!dup) {
- efree(class_name);
- }
- } else if (!IS_OP1_TMP_FREE()) { /* Not a temp var */
+ if (!IS_OP1_TMP_FREE()) { /* Not a temp var */
if (EG(active_op_array)->return_reference == ZEND_RETURN_REF ||
(PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) {
zval *ret;
}
if (ce && ce->get_iterator) {
- iter = ce->get_iterator(ce, array_ptr TSRMLS_CC);
+ iter = ce->get_iterator(ce, array_ptr, 0 TSRMLS_CC);
if (iter && !EG(exception)) {
array_ptr = zend_iterator_wrap(iter TSRMLS_CC);
zval *z = &opline->op1.u.constant;
if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL &&
- zend_std_cast_object_tostring(z, &z_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
+ zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
zend_print_variable(&z_copy);
zval_dtor(&z_copy);
} else {
retval_ptr = &opline->op1.u.constant;
- if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) {
- zval *ret;
- char *class_name;
- zend_uint class_name_len;
- int dup;
-
- ALLOC_ZVAL(ret);
- INIT_PZVAL_COPY(ret, retval_ptr);
- dup = zend_get_object_classname(retval_ptr, &class_name, &class_name_len TSRMLS_CC);
- if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", class_name);
- }
- zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
- ret->value.obj = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC);
- *EG(return_value_ptr_ptr) = ret;
- if (!dup) {
- efree(class_name);
- }
- } else if (!0) { /* Not a temp var */
+ if (!0) { /* Not a temp var */
if (EG(active_op_array)->return_reference == ZEND_RETURN_REF ||
(PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) {
zval *ret;
}
if (ce && ce->get_iterator) {
- iter = ce->get_iterator(ce, array_ptr TSRMLS_CC);
+ iter = ce->get_iterator(ce, array_ptr, 0 TSRMLS_CC);
if (iter && !EG(exception)) {
array_ptr = zend_iterator_wrap(iter TSRMLS_CC);
zval *z = _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL &&
- zend_std_cast_object_tostring(z, &z_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
+ zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
zend_print_variable(&z_copy);
zval_dtor(&z_copy);
} else {
retval_ptr = _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
- if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) {
- zval *ret;
- char *class_name;
- zend_uint class_name_len;
- int dup;
-
- ALLOC_ZVAL(ret);
- INIT_PZVAL_COPY(ret, retval_ptr);
- dup = zend_get_object_classname(retval_ptr, &class_name, &class_name_len TSRMLS_CC);
- if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", class_name);
- }
- zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
- ret->value.obj = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC);
- *EG(return_value_ptr_ptr) = ret;
- if (!dup) {
- efree(class_name);
- }
- } else if (!1) { /* Not a temp var */
+ if (!1) { /* Not a temp var */
if (EG(active_op_array)->return_reference == ZEND_RETURN_REF ||
(PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) {
zval *ret;
}
if (ce && ce->get_iterator) {
- iter = ce->get_iterator(ce, array_ptr TSRMLS_CC);
+ iter = ce->get_iterator(ce, array_ptr, 0 TSRMLS_CC);
if (iter && !EG(exception)) {
array_ptr = zend_iterator_wrap(iter TSRMLS_CC);
zval *z = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL &&
- zend_std_cast_object_tostring(z, &z_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
+ zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
zend_print_variable(&z_copy);
zval_dtor(&z_copy);
} else {
retval_ptr = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
- if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) {
- zval *ret;
- char *class_name;
- zend_uint class_name_len;
- int dup;
-
- ALLOC_ZVAL(ret);
- INIT_PZVAL_COPY(ret, retval_ptr);
- dup = zend_get_object_classname(retval_ptr, &class_name, &class_name_len TSRMLS_CC);
- if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", class_name);
- }
- zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
- ret->value.obj = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC);
- *EG(return_value_ptr_ptr) = ret;
- if (!dup) {
- efree(class_name);
- }
- } else if (!0) { /* Not a temp var */
+ if (!0) { /* Not a temp var */
if (EG(active_op_array)->return_reference == ZEND_RETURN_REF ||
(PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) {
zval *ret;
}
if (ce && ce->get_iterator) {
- iter = ce->get_iterator(ce, array_ptr TSRMLS_CC);
+ iter = ce->get_iterator(ce, array_ptr, 0 TSRMLS_CC);
if (iter && !EG(exception)) {
array_ptr = zend_iterator_wrap(iter TSRMLS_CC);
zval *z = _get_zval_ptr_cv(&opline->op1, EX(Ts), BP_VAR_R TSRMLS_CC);
if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL &&
- zend_std_cast_object_tostring(z, &z_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
+ zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
zend_print_variable(&z_copy);
zval_dtor(&z_copy);
} else {
retval_ptr = _get_zval_ptr_cv(&opline->op1, EX(Ts), BP_VAR_R TSRMLS_CC);
- if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) {
- zval *ret;
- char *class_name;
- zend_uint class_name_len;
- int dup;
-
- ALLOC_ZVAL(ret);
- INIT_PZVAL_COPY(ret, retval_ptr);
- dup = zend_get_object_classname(retval_ptr, &class_name, &class_name_len TSRMLS_CC);
- if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", class_name);
- }
- zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
- ret->value.obj = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC);
- *EG(return_value_ptr_ptr) = ret;
- if (!dup) {
- efree(class_name);
- }
- } else if (!0) { /* Not a temp var */
+ if (!0) { /* Not a temp var */
if (EG(active_op_array)->return_reference == ZEND_RETURN_REF ||
(PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) {
zval *ret;
}
if (ce && ce->get_iterator) {
- iter = ce->get_iterator(ce, array_ptr TSRMLS_CC);
+ iter = ce->get_iterator(ce, array_ptr, 0 TSRMLS_CC);
if (iter && !EG(exception)) {
array_ptr = zend_iterator_wrap(iter TSRMLS_CC);