cvs: ZendEngine2 / zend_compile.c zend_execute.c
| From: | Stanislav Malyshev | Date: | Thu, 03 Jul 2003 12:03:12 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c zend_execute.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1451@lists.php.net to get a copy of this message | ||
stas Thu Jul 3 08:03:12 2003 EDT
Modified files:
/ZendEngine2 zend_compile.c zend_execute.c
Log:
enable Classname() constructor to be called via parent::__constructor()
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.432 ZendEngine2/zend_compile.c:1.433
--- ZendEngine2/zend_compile.c:1.432 Wed Jul 2 12:52:07 2003
+++ ZendEngine2/zend_compile.c Thu Jul 3 08:03:11 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.432 2003/07/02 16:52:07 andi Exp $ */
+/* $Id: zend_compile.c,v 1.433 2003/07/03 12:03:11 stas Exp $ */
#include "zend_language_parser.h"
#include "zend.h"
@@ -1306,7 +1306,14 @@
/* a tmp var is leaked here */
opline->opcode = ZEND_INIT_STATIC_METHOD_CALL;
- zend_lowercase_znode_if_const(&opline->op2);
+ if(opline->op2.op_type == IS_CONST &&
+ (sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == Z_STRLEN(opline->op2.u.constant) &&
+ memcmp(Z_STRVAL(opline->op2.u.constant), ZEND_CONSTRUCTOR_FUNC_NAME,
sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == 0) {
+ zval_dtor(&opline->op2.u.constant);
+ SET_UNUSED(opline->op2);
+ } else {
+ zend_lowercase_znode_if_const(&opline->op2);
+ }
zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *));
}
@@ -2600,7 +2607,7 @@
opline->opcode = ZEND_INIT_CTOR_CALL;
opline->op1 = (opline-2)->result;
SET_UNUSED(opline->op2);
-
+
zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(unsigned char *));
}
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.485 ZendEngine2/zend_execute.c:1.486
--- ZendEngine2/zend_execute.c:1.485 Wed Jul 2 13:48:18 2003
+++ ZendEngine2/zend_execute.c Thu Jul 3 08:03:11 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.485 2003/07/02 17:48:18 zeev Exp $ */
+/* $Id: zend_execute.c,v 1.486 2003/07/03 12:03:11 stas Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -2426,6 +2426,7 @@
}
EX(fbc) = EX(fbc_constructor);
+
if (EX(fbc)->type == ZEND_USER_FUNCTION) { /* HACK!! */
EX(calling_scope) = EX(fbc)->common.scope;
} else {
@@ -2498,27 +2499,34 @@
{
zval *function_name;
zend_class_entry *ce;
- zend_bool is_const;
+ zend_bool is_const = 1;
char *function_name_strval;
int function_name_strlen;
zend_ptr_stack_n_push(&EG(arg_types_stack), 3, EX(fbc), EX(object), EX(calling_scope));
- is_const = (EX(opline)->op2.op_type == IS_CONST);
+ ce = EX_T(EX(opline)->op1.u.var).EA.class_entry;
+ if(EX(opline)->op2.op_type != IS_UNUSED) {
+ is_const = (EX(opline)->op2.op_type == IS_CONST);
- if (is_const) {
- function_name_strval = EX(opline)->op2.u.constant.value.str.val;
- function_name_strlen = EX(opline)->op2.u.constant.value.str.len;
- } else {
- function_name = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R);
+ if (is_const) {
+ function_name_strval = EX(opline)->op2.u.constant.value.str.val;
+ function_name_strlen = EX(opline)->op2.u.constant.value.str.len;
+ } else {
+ function_name = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R);
+
+ function_name_strval = zend_str_tolower_dup(function_name->value.str.val,
function_name->value.str.len);
+ function_name_strlen = function_name->value.str.len;
+ }
- function_name_strval = zend_str_tolower_dup(function_name->value.str.val,
function_name->value.str.len);
- function_name_strlen = function_name->value.str.len;
+ EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC);
+ } else {
+ if(!ce->constructor) {
+ zend_error(E_ERROR, "Can not call constructor");
+ }
+ EX(fbc) = ce->constructor;
}
- ce = EX_T(EX(opline)->op1.u.var).EA.class_entry;
-
- EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC);
EX(calling_scope) = EX(fbc)->common.scope;
if (!is_const) {