com php-src: Generate ZEND_COUNT for sizeof(): Ze nd/zend_compile.c Zend/zend_vm_def.h Zend/zend_ vm_execute.h

From: Date: Thu, 11 Apr 2019 08:48:52 +0000
Subject: com php-src: Generate ZEND_COUNT for sizeof(): Ze nd/zend_compile.c Zend/zend_vm_def.h Zend/zend_ vm_execute.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-105634@lists.php.net to get a copy of this message
Commit: 30df87f77d87d446afbfa4c9d2e0a1a643cc4bdc Author: Nikita Popov <nikita.ppv@gmail.com> Thu, 11 Apr 2019 10:48:52 +0200 Parents: b213f13a2621ec553beec06d3e2f163c1e7e2282 Branches: PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=30df87f77d87d446afbfa4c9d2e0a1a643cc4bdc Log: Generate ZEND_COUNT for sizeof() sizeof() is an alias of count(), so we should generate the same code for them. Changed paths: M Zend/zend_compile.c M Zend/zend_vm_def.h M Zend/zend_vm_execute.h Diff: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 2fa847d..ccdbd8a 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3551,16 +3551,19 @@ static int zend_compile_func_in_array(znode *result, zend_ast_list *args) /* {{{ } /* }}} */ -int zend_compile_func_count(znode *result, zend_ast_list *args) /* {{{ */ +int zend_compile_func_count(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ { znode arg_node; + zend_op *opline; if (args->children != 1) { return FAILURE; } zend_compile_expr(&arg_node, args->child[0]); - zend_emit_op_tmp(result, ZEND_COUNT, &arg_node, NULL); + opline = zend_emit_op_tmp(result, ZEND_COUNT, &arg_node, NULL); + opline->extended_value = zend_string_equals_literal(lcname, "sizeof"); + return SUCCESS; } /* }}} */ @@ -3739,8 +3742,9 @@ int zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_l return zend_compile_func_cuf(result, args, lcname); } else if (zend_string_equals_literal(lcname, "in_array")) { return zend_compile_func_in_array(result, args); - } else if (zend_string_equals_literal(lcname, "count")) { - return zend_compile_func_count(result, args); + } else if (zend_string_equals_literal(lcname, "count") + || zend_string_equals_literal(lcname, "sizeof")) { + return zend_compile_func_count(result, args, lcname); } else if (zend_string_equals_literal(lcname, "get_class")) { return zend_compile_func_get_class(result, args); } else if (zend_string_equals_literal(lcname, "get_called_class")) { diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 0f74e42..d716942 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -8379,7 +8379,7 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMP|VAR|CV, UNUSED) } else { count = 1; } - zend_error(E_WARNING, "count(): Parameter must be an array or an object that implements Countable"); + zend_error(E_WARNING, "%s(): Parameter must be an array or an object that implements Countable", opline->extended_value ? "sizeof" : "count"); } while (0); ZVAL_LONG(EX_VAR(opline->result.var), count); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 05c6101..7977a2a 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -9588,7 +9588,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_ } else { count = 1; } - zend_error(E_WARNING, "count(): Parameter must be an array or an object that implements Countable"); + zend_error(E_WARNING, "%s(): Parameter must be an array or an object that implements Countable", opline->extended_value ? "sizeof" : "count"); } while (0); ZVAL_LONG(EX_VAR(opline->result.var), count); @@ -20293,7 +20293,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMP_UNUSED_HANDLER( } else { count = 1; } - zend_error(E_WARNING, "count(): Parameter must be an array or an object that implements Countable"); + zend_error(E_WARNING, "%s(): Parameter must be an array or an object that implements Countable", opline->extended_value ? "sizeof" : "count"); } while (0); ZVAL_LONG(EX_VAR(opline->result.var), count); @@ -29522,7 +29522,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_VAR_UNUSED_HANDLER( } else { count = 1; } - zend_error(E_WARNING, "count(): Parameter must be an array or an object that implements Countable"); + zend_error(E_WARNING, "%s(): Parameter must be an array or an object that implements Countable", opline->extended_value ? "sizeof" : "count"); } while (0); ZVAL_LONG(EX_VAR(opline->result.var), count); @@ -50779,7 +50779,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z } else { count = 1; } - zend_error(E_WARNING, "count(): Parameter must be an array or an object that implements Countable"); + zend_error(E_WARNING, "%s(): Parameter must be an array or an object that implements Countable", opline->extended_value ? "sizeof" : "count"); } while (0); ZVAL_LONG(EX_VAR(opline->result.var), count);

« previous php.cvs (#105634) next »