cvs: ZendEngine2 / zend.c zend_compile.c zend_execute.c zend_execute_API.c zend_globals.h zend_variables.c
| From: | Zeev Suraski | Date: | Wed, 25 Feb 2004 10:57:10 +0000 |
| Subject: | cvs: ZendEngine2 / zend.c zend_compile.c zend_execute.c zend_execute_API.c zend_globals.h zend_variables.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-2404@lists.php.net to get a copy of this message | ||
zeev Wed Feb 25 05:57:10 2004 EDT
Modified files:
/ZendEngine2 zend.c zend_compile.c zend_execute.c
zend_execute_API.c zend_globals.h zend_variables.c
Log:
- Rename compatiblity mode to zend.ze2_compatibility_mode (it doesn't only affect
auto-clone).
- Perform implementation checks even with simple inheritance (off when
compatibility mode is enabled).
- Restore default arguments in interfaces and handle it correctly.
- Move registration of internal classes later in the startup sequence
in order to have INI options available.
http://cvs.php.net/diff.php/ZendEngine2/zend.c?r1=1.269&r2=1.270&ty=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.269 ZendEngine2/zend.c:1.270 --- ZendEngine2/zend.c:1.269 Wed Feb 18 03:53:56 2004 +++ ZendEngine2/zend.c Wed Feb 25 05:57:09 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.269 2004/02/18 08:53:56 zeev Exp $ */ +/* $Id: zend.c,v 1.270 2004/02/25 10:57:09 zeev Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -73,20 +73,9 @@ } -static ZEND_INI_MH(OnUpdateImplicitClone) -{ - if (!new_value) { - EG(implicit_clone) = 0; - } else { - EG(implicit_clone) = atoi(new_value) ? 1 : 0; - } - return SUCCESS; -} - - ZEND_INI_BEGIN() - ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting) - ZEND_INI_ENTRY("zend2.implicit_clone", NULL, ZEND_INI_ALL, OnUpdateImplicitClone) + 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) ZEND_INI_END() @@ -643,7 +632,6 @@ if (start_builtin_functions) { zend_startup_builtin_functions(TSRMLS_C); } - zend_register_default_classes(TSRMLS_C); zend_ini_startup(TSRMLS_C); http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.544&r2=1.545&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.544 ZendEngine2/zend_compile.c:1.545 --- ZendEngine2/zend_compile.c:1.544 Wed Feb 25 04:25:36 2004 +++ ZendEngine2/zend_compile.c Wed Feb 25 05:57:09 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.544 2004/02/25 09:25:36 zeev Exp $ */ +/* $Id: zend_compile.c,v 1.545 2004/02/25 10:57:09 zeev Exp $ */ #include "zend_language_parser.h" #include "zend.h" @@ -1136,11 +1136,6 @@ opline->result = *var; opline->op1 = *offset; if (op == ZEND_RECV_INIT) { - if ((CG(active_class_entry) && CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) - || CG(active_op_array)->fn_flags & ZEND_ACC_ABSTRACT) { - CG(active_op_array)->num_args--; /* invalidate the current arg_info entry */ - zend_error(E_COMPILE_ERROR, "Abstract methods cannot have default values for arguments"); - } opline->op2 = *initialization; } else { CG(active_op_array)->required_num_args = CG(active_op_array)->num_args; @@ -1723,7 +1718,7 @@ } /* check number of arguments */ - if (proto->common.num_args < fe->common.required_num_args + if (proto->common.required_num_args != fe->common.required_num_args || proto->common.num_args > fe->common.num_args) { return 0; } @@ -1768,6 +1763,7 @@ zend_uint child_flags; zend_uint parent_flags = parent->common.fn_flags; zend_function *child; + TSRMLS_FETCH(); if (zend_hash_quick_find(child_function_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child)==FAILURE) { if (parent_flags & ZEND_ACC_ABSTRACT) { @@ -1818,15 +1814,22 @@ } } - if (parent_flags & ZEND_ACC_ABSTRACT) { + if (EG(ze1_compatibility_mode)) { + if (parent_flags & ZEND_ACC_ABSTRACT) { + child->common.prototype = parent; + child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT; + } else { + child->common.prototype = parent->common.prototype; + } + } else { child->common.prototype = parent; - child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT; - } else if (parent->common.prototype) { - child->common.prototype = parent->common.prototype; + if (parent_flags & ZEND_ACC_ABSTRACT) { + child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT; + } } if (!zend_do_perform_implementation_check(child)) { - zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be the same as %s::%s()", ZEND_FN_SCOPE_NAME(child), child->common.function_name, ZEND_FN_SCOPE_NAME(child->common.prototype), child->common.prototype->common.function_name); + 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); } return 0; http://cvs.php.net/diff.php/ZendEngine2/zend_execute.c?r1=1.612&r2=1.613&ty=u Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.612 ZendEngine2/zend_execute.c:1.613 --- ZendEngine2/zend_execute.c:1.612 Thu Feb 12 10:23:06 2004 +++ ZendEngine2/zend_execute.c Wed Feb 25 05:57:09 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.612 2004/02/12 15:23:06 andi Exp $ */ +/* $Id: zend_execute.c,v 1.613 2004/02/25 10:57:09 zeev Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -382,7 +382,7 @@ } /* here we are sure we are dealing with an object */ - if (EG(implicit_clone)) { + if (EG(ze1_compatibility_mode)) { SEPARATE_ZVAL_IF_NOT_REF(object_ptr); object = *object_ptr; } @@ -2401,7 +2401,7 @@ /* We are not handling overloaded classes right now */ EX(object) = get_zval_ptr(&opline->op1, EX(Ts), &EG(free_op1), BP_VAR_R); - if (!PZVAL_IS_REF(EX(object)) || !EG(implicit_clone)) { + if (!PZVAL_IS_REF(EX(object)) || !EG(ze1_compatibility_mode)) { EX(object)->refcount++; /* For $this pointer */ } else { zval *this_ptr; @@ -2459,7 +2459,7 @@ if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { EX(object) = NULL; } else { - if (!PZVAL_IS_REF(EX(object)) || !EG(implicit_clone)) { + if (!PZVAL_IS_REF(EX(object)) || !EG(ze1_compatibility_mode)) { EX(object)->refcount++; /* For $this pointer */ } else { zval *this_ptr; http://cvs.php.net/diff.php/ZendEngine2/zend_execute_API.c?r1=1.270&r2=1.271&ty=u Index: ZendEngine2/zend_execute_API.c diff -u ZendEngine2/zend_execute_API.c:1.270 ZendEngine2/zend_execute_API.c:1.271 --- ZendEngine2/zend_execute_API.c:1.270 Thu Feb 12 05:38:14 2004 +++ ZendEngine2/zend_execute_API.c Wed Feb 25 05:57:10 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute_API.c,v 1.270 2004/02/12 10:38:14 zeev Exp $ */ +/* $Id: zend_execute_API.c,v 1.271 2004/02/25 10:57:10 zeev Exp $ */ #include <stdio.h> #include <signal.h> @@ -132,7 +132,6 @@ EG(symtable_cache_ptr) = EG(symtable_cache)-1; EG(symtable_cache_limit)=EG(symtable_cache)+SYMTABLE_CACHE_SIZE-1; EG(no_extensions)=0; - EG(implicit_clone)=0; EG(function_table) = CG(function_table); EG(class_table) = CG(class_table); http://cvs.php.net/diff.php/ZendEngine2/zend_globals.h?r1=1.132&r2=1.133&ty=u Index: ZendEngine2/zend_globals.h diff -u ZendEngine2/zend_globals.h:1.132 ZendEngine2/zend_globals.h:1.133 --- ZendEngine2/zend_globals.h:1.132 Tue Feb 3 07:17:09 2004 +++ ZendEngine2/zend_globals.h Wed Feb 25 05:57:10 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_globals.h,v 1.132 2004/02/03 12:17:09 zeev Exp $ */ +/* $Id: zend_globals.h,v 1.133 2004/02/25 10:57:10 zeev Exp $ */ #ifndef ZEND_GLOBALS_H #define ZEND_GLOBALS_H @@ -193,7 +193,7 @@ zend_bool in_autoload; zend_bool bailout_set; zend_bool full_tables_cleanup; - zend_bool implicit_clone; + zend_bool ze1_compatibility_mode; /* for extended information support */ zend_bool no_extensions; http://cvs.php.net/diff.php/ZendEngine2/zend_variables.c?r1=1.54&r2=1.55&ty=u Index: ZendEngine2/zend_variables.c diff -u ZendEngine2/zend_variables.c:1.54 ZendEngine2/zend_variables.c:1.55 --- ZendEngine2/zend_variables.c:1.54 Thu Jan 8 12:31:48 2004 +++ ZendEngine2/zend_variables.c Wed Feb 25 05:57:10 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_variables.c,v 1.54 2004/01/08 17:31:48 sniper Exp $ */ +/* $Id: zend_variables.c,v 1.55 2004/02/25 10:57:10 zeev Exp $ */ #include <stdio.h> #include "zend.h" @@ -154,7 +154,7 @@ { TSRMLS_FETCH(); - if (EG(implicit_clone)) { + if (EG(ze1_compatibility_mode)) { zvalue->value.obj = zvalue->value.obj.handlers->clone_obj(zvalue TSRMLS_CC); } else { Z_OBJ_HT_P(zvalue)->add_ref(zvalue TSRMLS_CC);
http://cvs.php.net/diff.php/ZendEngine2/zend.c?r1=1.269&r2=1.270&ty=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.269 ZendEngine2/zend.c:1.270 --- ZendEngine2/zend.c:1.269 Wed Feb 18 03:53:56 2004 +++ ZendEngine2/zend.c Wed Feb 25 05:57:09 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.269 2004/02/18 08:53:56 zeev Exp $ */ +/* $Id: zend.c,v 1.270 2004/02/25 10:57:09 zeev Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -73,20 +73,9 @@ } -static ZEND_INI_MH(OnUpdateImplicitClone) -{ - if (!new_value) { - EG(implicit_clone) = 0; - } else { - EG(implicit_clone) = atoi(new_value) ? 1 : 0; - } - return SUCCESS; -} - - ZEND_INI_BEGIN() - ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting) - ZEND_INI_ENTRY("zend2.implicit_clone", NULL, ZEND_INI_ALL, OnUpdateImplicitClone) + 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) ZEND_INI_END() @@ -643,7 +632,6 @@ if (start_builtin_functions) { zend_startup_builtin_functions(TSRMLS_C); } - zend_register_default_classes(TSRMLS_C); zend_ini_startup(TSRMLS_C); http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.544&r2=1.545&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.544 ZendEngine2/zend_compile.c:1.545 --- ZendEngine2/zend_compile.c:1.544 Wed Feb 25 04:25:36 2004 +++ ZendEngine2/zend_compile.c Wed Feb 25 05:57:09 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.544 2004/02/25 09:25:36 zeev Exp $ */ +/* $Id: zend_compile.c,v 1.545 2004/02/25 10:57:09 zeev Exp $ */ #include "zend_language_parser.h" #include "zend.h" @@ -1136,11 +1136,6 @@ opline->result = *var; opline->op1 = *offset; if (op == ZEND_RECV_INIT) { - if ((CG(active_class_entry) && CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) - || CG(active_op_array)->fn_flags & ZEND_ACC_ABSTRACT) { - CG(active_op_array)->num_args--; /* invalidate the current arg_info entry */ - zend_error(E_COMPILE_ERROR, "Abstract methods cannot have default values for arguments"); - } opline->op2 = *initialization; } else { CG(active_op_array)->required_num_args = CG(active_op_array)->num_args; @@ -1723,7 +1718,7 @@ } /* check number of arguments */ - if (proto->common.num_args < fe->common.required_num_args + if (proto->common.required_num_args != fe->common.required_num_args || proto->common.num_args > fe->common.num_args) { return 0; } @@ -1768,6 +1763,7 @@ zend_uint child_flags; zend_uint parent_flags = parent->common.fn_flags; zend_function *child; + TSRMLS_FETCH(); if (zend_hash_quick_find(child_function_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child)==FAILURE) { if (parent_flags & ZEND_ACC_ABSTRACT) { @@ -1818,15 +1814,22 @@ } } - if (parent_flags & ZEND_ACC_ABSTRACT) { + if (EG(ze1_compatibility_mode)) { + if (parent_flags & ZEND_ACC_ABSTRACT) { + child->common.prototype = parent; + child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT; + } else { + child->common.prototype = parent->common.prototype; + } + } else { child->common.prototype = parent; - child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT; - } else if (parent->common.prototype) { - child->common.prototype = parent->common.prototype; + if (parent_flags & ZEND_ACC_ABSTRACT) { + child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT; + } } if (!zend_do_perform_implementation_check(child)) { - zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be the same as %s::%s()", ZEND_FN_SCOPE_NAME(child), child->common.function_name, ZEND_FN_SCOPE_NAME(child->common.prototype), child->common.prototype->common.function_name); + 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); } return 0; http://cvs.php.net/diff.php/ZendEngine2/zend_execute.c?r1=1.612&r2=1.613&ty=u Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.612 ZendEngine2/zend_execute.c:1.613 --- ZendEngine2/zend_execute.c:1.612 Thu Feb 12 10:23:06 2004 +++ ZendEngine2/zend_execute.c Wed Feb 25 05:57:09 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.612 2004/02/12 15:23:06 andi Exp $ */ +/* $Id: zend_execute.c,v 1.613 2004/02/25 10:57:09 zeev Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -382,7 +382,7 @@ } /* here we are sure we are dealing with an object */ - if (EG(implicit_clone)) { + if (EG(ze1_compatibility_mode)) { SEPARATE_ZVAL_IF_NOT_REF(object_ptr); object = *object_ptr; } @@ -2401,7 +2401,7 @@ /* We are not handling overloaded classes right now */ EX(object) = get_zval_ptr(&opline->op1, EX(Ts), &EG(free_op1), BP_VAR_R); - if (!PZVAL_IS_REF(EX(object)) || !EG(implicit_clone)) { + if (!PZVAL_IS_REF(EX(object)) || !EG(ze1_compatibility_mode)) { EX(object)->refcount++; /* For $this pointer */ } else { zval *this_ptr; @@ -2459,7 +2459,7 @@ if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { EX(object) = NULL; } else { - if (!PZVAL_IS_REF(EX(object)) || !EG(implicit_clone)) { + if (!PZVAL_IS_REF(EX(object)) || !EG(ze1_compatibility_mode)) { EX(object)->refcount++; /* For $this pointer */ } else { zval *this_ptr; http://cvs.php.net/diff.php/ZendEngine2/zend_execute_API.c?r1=1.270&r2=1.271&ty=u Index: ZendEngine2/zend_execute_API.c diff -u ZendEngine2/zend_execute_API.c:1.270 ZendEngine2/zend_execute_API.c:1.271 --- ZendEngine2/zend_execute_API.c:1.270 Thu Feb 12 05:38:14 2004 +++ ZendEngine2/zend_execute_API.c Wed Feb 25 05:57:10 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute_API.c,v 1.270 2004/02/12 10:38:14 zeev Exp $ */ +/* $Id: zend_execute_API.c,v 1.271 2004/02/25 10:57:10 zeev Exp $ */ #include <stdio.h> #include <signal.h> @@ -132,7 +132,6 @@ EG(symtable_cache_ptr) = EG(symtable_cache)-1; EG(symtable_cache_limit)=EG(symtable_cache)+SYMTABLE_CACHE_SIZE-1; EG(no_extensions)=0; - EG(implicit_clone)=0; EG(function_table) = CG(function_table); EG(class_table) = CG(class_table); http://cvs.php.net/diff.php/ZendEngine2/zend_globals.h?r1=1.132&r2=1.133&ty=u Index: ZendEngine2/zend_globals.h diff -u ZendEngine2/zend_globals.h:1.132 ZendEngine2/zend_globals.h:1.133 --- ZendEngine2/zend_globals.h:1.132 Tue Feb 3 07:17:09 2004 +++ ZendEngine2/zend_globals.h Wed Feb 25 05:57:10 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_globals.h,v 1.132 2004/02/03 12:17:09 zeev Exp $ */ +/* $Id: zend_globals.h,v 1.133 2004/02/25 10:57:10 zeev Exp $ */ #ifndef ZEND_GLOBALS_H #define ZEND_GLOBALS_H @@ -193,7 +193,7 @@ zend_bool in_autoload; zend_bool bailout_set; zend_bool full_tables_cleanup; - zend_bool implicit_clone; + zend_bool ze1_compatibility_mode; /* for extended information support */ zend_bool no_extensions; http://cvs.php.net/diff.php/ZendEngine2/zend_variables.c?r1=1.54&r2=1.55&ty=u Index: ZendEngine2/zend_variables.c diff -u ZendEngine2/zend_variables.c:1.54 ZendEngine2/zend_variables.c:1.55 --- ZendEngine2/zend_variables.c:1.54 Thu Jan 8 12:31:48 2004 +++ ZendEngine2/zend_variables.c Wed Feb 25 05:57:10 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_variables.c,v 1.54 2004/01/08 17:31:48 sniper Exp $ */ +/* $Id: zend_variables.c,v 1.55 2004/02/25 10:57:10 zeev Exp $ */ #include <stdio.h> #include "zend.h" @@ -154,7 +154,7 @@ { TSRMLS_FETCH(); - if (EG(implicit_clone)) { + if (EG(ze1_compatibility_mode)) { zvalue->value.obj = zvalue->value.obj.handlers->clone_obj(zvalue TSRMLS_CC); } else { Z_OBJ_HT_P(zvalue)->add_ref(zvalue TSRMLS_CC);