From 74d15b535afda508f498428262e423d46de7553d Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Tue, 6 Nov 2018 18:39:22 -0700 Subject: [PATCH] Remove do_bind_inherited_class; use do_bind_class Pass NULL as the second parameter. I don't know if in the past these differed more, but there isn't any point to having both of them anymore. --- Zend/zend_compile.c | 28 ++-------------------------- Zend/zend_compile.h | 3 +-- Zend/zend_vm_def.h | 6 +++--- Zend/zend_vm_execute.h | 6 +++--- 4 files changed, 9 insertions(+), 34 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 5055dcb0d97..fb5869712cb 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1073,31 +1073,7 @@ ZEND_API int do_bind_function(zval *lcname) /* {{{ */ } /* }}} */ -ZEND_API int do_bind_class(zval *lcname) /* {{{ */ -{ - zend_class_entry *ce; - zval *rtd_key, *zv; - - rtd_key = lcname + 1; - zv = zend_hash_find_ex(EG(class_table), Z_STR_P(rtd_key), 1); - if (UNEXPECTED(!zv)) { - zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare %s, because the name is already in use", Z_STRVAL_P(lcname)); - return FAILURE; - } - - ce = (zend_class_entry*)Z_PTR_P(zv); - zv = zend_hash_set_bucket_key(EG(class_table), (Bucket*)zv, Z_STR_P(lcname)); - if (UNEXPECTED(!zv)) { - zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), ZSTR_VAL(ce->name)); - return FAILURE; - } - - zend_do_link_class(ce, NULL); - return SUCCESS; -} -/* }}} */ - -ZEND_API int do_bind_inherited_class(zval *lcname, zend_class_entry *parent_ce) /* {{{ */ +ZEND_API int do_bind_class(zval *lcname, zend_class_entry *parent_ce) /* {{{ */ { zend_class_entry *ce; zval *rtd_key, *zv; @@ -1192,7 +1168,7 @@ ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array, uint3 const zend_op *opline = &op_array->opcodes[opline_num]; zval *parent_name = RT_CONSTANT(opline, opline->op2); if ((ce = zend_lookup_class_ex(Z_STR_P(parent_name), Z_STR_P(parent_name + 1), 0)) != NULL) { - do_bind_inherited_class(RT_CONSTANT(&op_array->opcodes[opline_num], op_array->opcodes[opline_num].op1), ce); + do_bind_class(RT_CONSTANT(&op_array->opcodes[opline_num], op_array->opcodes[opline_num].op1), ce); } opline_num = op_array->opcodes[opline_num].result.opline_num; } diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 8b39a7a77f9..2912316ccc4 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -750,8 +750,7 @@ zend_bool zend_handle_encoding_declaration(zend_ast *ast); void zend_do_free(znode *op1); ZEND_API int do_bind_function(zval *lcname); -ZEND_API int do_bind_class(zval *lcname); -ZEND_API int do_bind_inherited_class(zval *lcname, zend_class_entry *parent_ce); +ZEND_API int do_bind_class(zval *lcname, zend_class_entry *parent_ce); ZEND_API uint32_t zend_build_delayed_early_binding_list(const zend_op_array *op_array); ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array, uint32_t first_early_binding_opline); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 0025b9b3f10..7ea672caac9 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -6613,7 +6613,7 @@ ZEND_VM_HANDLER(139, ZEND_DECLARE_CLASS, CONST, ANY) USE_OPLINE SAVE_OPLINE(); - do_bind_class(RT_CONSTANT(opline, opline->op1)); + do_bind_class(RT_CONSTANT(opline, opline->op1), NULL); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -6630,7 +6630,7 @@ ZEND_VM_HANDLER(140, ZEND_DECLARE_INHERITED_CLASS, CONST, CONST) ZEND_ASSERT(EG(exception)); HANDLE_EXCEPTION(); } - do_bind_inherited_class(RT_CONSTANT(opline, opline->op1), parent); + do_bind_class(RT_CONSTANT(opline, opline->op1), parent); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -6651,7 +6651,7 @@ ZEND_VM_HANDLER(145, ZEND_DECLARE_INHERITED_CLASS_DELAYED, CONST, CONST) ZEND_ASSERT(EG(exception)); HANDLE_EXCEPTION(); } - do_bind_inherited_class(RT_CONSTANT(opline, opline->op1), parent); + do_bind_class(RT_CONSTANT(opline, opline->op1), parent); } ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index d9bf97bb749..3d42b954f90 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -3544,7 +3544,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DECLARE_CLASS_SPEC_CONST_HANDL USE_OPLINE SAVE_OPLINE(); - do_bind_class(RT_CONSTANT(opline, opline->op1)); + do_bind_class(RT_CONSTANT(opline, opline->op1), NULL); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -5754,7 +5754,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DECLARE_INHERITED_CLASS_SPEC_C ZEND_ASSERT(EG(exception)); HANDLE_EXCEPTION(); } - do_bind_inherited_class(RT_CONSTANT(opline, opline->op1), parent); + do_bind_class(RT_CONSTANT(opline, opline->op1), parent); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -5775,7 +5775,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DECLARE_INHERITED_CLASS_DELAYE ZEND_ASSERT(EG(exception)); HANDLE_EXCEPTION(); } - do_bind_inherited_class(RT_CONSTANT(opline, opline->op1), parent); + do_bind_class(RT_CONSTANT(opline, opline->op1), parent); } ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); }