enable Classname() constructor to be called via parent::__constructor()

This commit is contained in:
Stanislav Malyshev 2003-07-03 12:03:11 +00:00
parent bc16d962a6
commit 8f0234160a
2 changed files with 29 additions and 14 deletions

View File

@ -1306,7 +1306,14 @@ void zend_do_begin_class_member_function_call(TSRMLS_D)
/* a tmp var is leaked here */
opline->opcode = ZEND_INIT_STATIC_METHOD_CALL;
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 *));
}

View File

@ -2426,6 +2426,7 @@ int zend_init_ctor_call_handler(ZEND_OPCODE_HANDLER_ARGS)
}
EX(fbc) = EX(fbc_constructor);
if (EX(fbc)->type == ZEND_USER_FUNCTION) { /* HACK!! */
EX(calling_scope) = EX(fbc)->common.scope;
} else {
@ -2498,12 +2499,14 @@ int zend_init_static_method_call_handler(ZEND_OPCODE_HANDLER_ARGS)
{
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));
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) {
@ -2516,9 +2519,14 @@ int zend_init_static_method_call_handler(ZEND_OPCODE_HANDLER_ARGS)
function_name_strlen = function_name->value.str.len;
}
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);
} else {
if(!ce->constructor) {
zend_error(E_ERROR, "Can not call constructor");
}
EX(fbc) = ce->constructor;
}
EX(calling_scope) = EX(fbc)->common.scope;
if (!is_const) {