@@ -3308,14 +3308,21 @@ static uint32_t zend_get_arg_num(zend_function *fn, zend_string *arg_name) {
3308
3308
return (uint32_t ) -1 ;
3309
3309
}
3310
3310
3311
- uint32_t zend_compile_args (zend_ast * ast , zend_function * fbc ) /* {{{ */
3311
+ uint32_t zend_compile_args (
3312
+ zend_ast * ast , zend_function * fbc , bool * may_have_extra_named_args ) /* {{{ */
3312
3313
{
3313
3314
zend_ast_list * args = zend_ast_get_list (ast );
3314
3315
uint32_t i ;
3315
3316
zend_bool uses_arg_unpack = 0 ;
3317
+ uint32_t arg_count = 0 ; /* number of arguments not including unpacks */
3318
+
3319
+ /* Whether named arguments are used syntactically, to enforce language level limitations.
3320
+ * May not actually use named argument passing. */
3316
3321
zend_bool uses_named_args = 0 ;
3322
+ /* Whether there may be any undef arguments due to the use of named arguments. */
3317
3323
zend_bool may_have_undef = 0 ;
3318
- uint32_t arg_count = 0 ; /* number of arguments not including unpacks */
3324
+ /* Whether there may be any extra named arguments collected into a variadic. */
3325
+ * may_have_extra_named_args = 0 ;
3319
3326
3320
3327
for (i = 0 ; i < args -> children ; ++ i ) {
3321
3328
zend_ast * arg = args -> child [i ];
@@ -3342,6 +3349,7 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc) /* {{{ */
3342
3349
3343
3350
/* Unpack may contain named arguments. */
3344
3351
may_have_undef = 1 ;
3352
+ * may_have_extra_named_args = 1 ;
3345
3353
continue ;
3346
3354
}
3347
3355
@@ -3367,7 +3375,9 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc) /* {{{ */
3367
3375
}
3368
3376
3369
3377
if (arg_name ) {
3378
+ // TODO: These could be made more precise if fbc is known.
3370
3379
may_have_undef = 1 ;
3380
+ * may_have_extra_named_args = 1 ;
3371
3381
}
3372
3382
} else {
3373
3383
if (uses_arg_unpack ) {
@@ -3509,19 +3519,6 @@ static inline zend_bool zend_args_contain_unpack_or_named(zend_ast_list *args) /
3509
3519
}
3510
3520
/* }}} */
3511
3521
3512
- static inline zend_bool zend_args_contain_named (zend_ast_list * args ) /* {{{ */
3513
- {
3514
- uint32_t i ;
3515
- for (i = 0 ; i < args -> children ; ++ i ) {
3516
- zend_ast * arg = args -> child [i ];
3517
- if (arg -> kind == ZEND_AST_NAMED_ARG ) {
3518
- return 1 ;
3519
- }
3520
- }
3521
- return 0 ;
3522
- }
3523
- /* }}} */
3524
-
3525
3522
ZEND_API zend_uchar zend_get_call_op (const zend_op * init_op , zend_function * fbc ) /* {{{ */
3526
3523
{
3527
3524
if (fbc ) {
@@ -3553,8 +3550,9 @@ void zend_compile_call_common(znode *result, zend_ast *args_ast, zend_function *
3553
3550
zend_op * opline ;
3554
3551
uint32_t opnum_init = get_next_op_number () - 1 ;
3555
3552
uint32_t arg_count ;
3553
+ bool may_have_extra_named_args ;
3556
3554
3557
- arg_count = zend_compile_args (args_ast , fbc );
3555
+ arg_count = zend_compile_args (args_ast , fbc , & may_have_extra_named_args );
3558
3556
3559
3557
zend_do_extended_fcall_begin ();
3560
3558
@@ -3566,8 +3564,8 @@ void zend_compile_call_common(znode *result, zend_ast *args_ast, zend_function *
3566
3564
}
3567
3565
3568
3566
opline = zend_emit_op (result , zend_get_call_op (opline , fbc ), NULL , NULL );
3569
- if (zend_args_contain_named ( zend_ast_get_list ( args_ast )) ) {
3570
- opline -> extended_value = ZEND_FCALL_HAS_NAMED_ARGS ;
3567
+ if (may_have_extra_named_args ) {
3568
+ opline -> extended_value = ZEND_FCALL_MAY_HAVE_EXTRA_NAMED_PARAMS ;
3571
3569
}
3572
3570
zend_do_extended_fcall_end ();
3573
3571
}
0 commit comments