|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-11-05 17:40 UTC] willfitch@php.net
[2015-04-15 14:00 UTC] cmb@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cmb
[2015-04-15 14:00 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 01:00:01 2025 UTC |
Description: ------------ now php use call_user_func_array() function dynamic call other function of unsure paramters, but the function performance slow than $function() call function and about 50%, but variable functions can not call dynamic paramters other, call_user_func() and call_user_func_array() can not call protected and private method of object so i think php add call_func syntax instead call function ways my think is below, use foreach pcode comply SEND_VAR to function: 1. Zend/zend_language_scanner.l add code: <ST_IN_SCRIPTING>"call_func" { return T_CALL_FUNC; } 2.Zend/zend_language_parser.y add code: find **function_call:** section append code: | T_CALL_FUNC '(' call_function_name function_call_array_parameters ')' { zend_do_end_function_call(&$3, &$$, &$4, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} then add: call_function_name: variable {zend_do_end_variable_parse(&$3, BP_VAR_R, 0 TSRMLS_CC);zend_do_begin_dynamic_function_call(&$3, 0 TSRMLS_CC);} | T_STRING {$$=$3;zend_do_begin_dynamic_function_call(&$3, 0 TSRMLS_CC);} ; function_call_array_parameter: { Z_LVAL($$.u.constant)=0; } | expr {zend_do_pass_array_parameters(&$4, ZEND_SEND_VAL, Z_LVAL($$.u.constant) TSRMLS_CC)} ; 3.Zend/zend_compile.c add zend_do_pass_array_parameters() function: void zend_do_pass_array_parameters(znode * expr, zend_uchar op, int offset TSRMLS_DC) /* {{{ */ { zend_op *opline; znode last_container; znode *result; expr->u.opline_num = get_next_op_number(CG(active_op_array)); opline = get_next_op(CG(active_op_array) TSRMLS_CC); /* Preform array reset */ opline->opcode = ZEND_FE_RESET; opline->result.op_type = IS_VAR; opline->result.u.var = get_temporary_variable(CG(active_op_array)); opline->op1 = *array; SET_UNUSED(opline->op2); opline->extended_value = is_variable ? ZEND_FE_RESET_VARIABLE : 0; dummy_opline.result = opline->result; zend_stack_push(&CG(foreach_copy_stack), (void *) &dummy_opline, sizeof (zend_op)); /* save the location of FE_FETCH */ //as_token->u.opline_num = get_next_op_number(CG(active_op_array)); opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_FE_FETCH; opline->result.op_type = IS_VAR; opline->result.u.var = get_temporary_variable(CG(active_op_array)); opline->op1 = dummy_opline.result; opline->extended_value = 0; SET_UNUSED(opline->op2); opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_OP_DATA; result = opline->result; zend_do_pass_param(result, op, offset TSRMLS_CC); SET_UNUSED(opline->op1); SET_UNUSED(opline->op2); SET_UNUSED(opline->result); zend_do_foreach_end(expr) }