@@ -16476,8 +16476,16 @@ Perl_rcpv_copy(pTHX_ char *pv) {
16476
16476
/* Subroutine signature parsing */
16477
16477
16478
16478
struct yy_parser_signature {
16479
- UV elems; /* number of signature elements seen so far */
16480
- UV optelems; /* number of optional signature elems seen */
16479
+ /* A note on terminology. We call each variable that appears in a
16480
+ * signature a "parameter", and each scalar value the caller passes in at
16481
+ * call time we call an "argument".
16482
+ * Each scalar parameter variable will correspond to one argument value.
16483
+ * The complication arises when we consider a slurpy array or hash
16484
+ * parameter. Here, while it is exactly one *parameter*, it may account
16485
+ * zero or more arguments.
16486
+ */
16487
+ UV next_argix; /* the argument index of the next parameter we add */
16488
+ UV opt_params; /* number of optional scalar parameters */
16481
16489
char slurpy; /* the sigil of the slurpy var (or null) */
16482
16490
OP *elemops; /* NULL, or an OP_LINESEQ of individual element and fence ops */
16483
16491
};
@@ -16508,8 +16516,8 @@ Perl_subsignature_start(pTHX)
16508
16516
Newx(signature, 1, yy_parser_signature);
16509
16517
SAVEDESTRUCTOR_X(&destroy_subsignature_context, signature);
16510
16518
16511
- signature->elems = 0;
16512
- signature->optelems = 0;
16519
+ signature->next_argix = 0;
16520
+ signature->opt_params = 0;
16513
16521
signature->slurpy = 0;
16514
16522
16515
16523
signature->elemops = NULL;
@@ -16567,7 +16575,8 @@ Perl_subsignature_append_positional(pTHX_ PADOFFSET padix, OPCODE defmode, OP *d
16567
16575
if(signature->slurpy)
16568
16576
yyerror("Slurpy parameter not last");
16569
16577
16570
- UV argix = signature->elems;
16578
+ UV argix = signature->next_argix;
16579
+ signature->next_argix++;
16571
16580
16572
16581
OP *varop = NULL;
16573
16582
if(padix) {
@@ -16579,10 +16588,8 @@ Perl_subsignature_append_positional(pTHX_ PADOFFSET padix, OPCODE defmode, OP *d
16579
16588
cUNOP_AUXx(varop)->op_aux = INT2PTR(UNOP_AUX_item *, argix);
16580
16589
}
16581
16590
16582
- signature->elems++;
16583
-
16584
16591
if(defexpr) {
16585
- signature->optelems ++;
16592
+ signature->opt_params ++;
16586
16593
16587
16594
if(defexpr->op_type == OP_NULL && !(defexpr->op_flags & OPf_KIDS))
16588
16595
{
@@ -16622,7 +16629,7 @@ Perl_subsignature_append_positional(pTHX_ PADOFFSET padix, OPCODE defmode, OP *d
16622
16629
}
16623
16630
}
16624
16631
else
16625
- if(signature->optelems )
16632
+ if(signature->opt_params )
16626
16633
yyerror("Mandatory parameter follows optional parameter");
16627
16634
16628
16635
if(varop) {
@@ -16649,7 +16656,8 @@ Perl_subsignature_append_slurpy(pTHX_ I32 sigil, PADOFFSET padix)
16649
16656
if(signature->slurpy)
16650
16657
yyerror("Multiple slurpy parameters not allowed");
16651
16658
16652
- UV argix = signature->elems;
16659
+ UV argix = signature->next_argix;
16660
+ /* do not increment */
16653
16661
16654
16662
signature->slurpy = (char)sigil;
16655
16663
@@ -16689,8 +16697,8 @@ Perl_subsignature_finish(pTHX)
16689
16697
struct op_argcheck_aux *aux = (struct op_argcheck_aux *)
16690
16698
PerlMemShared_malloc( sizeof(struct op_argcheck_aux));
16691
16699
16692
- aux->params = signature->elems ;
16693
- aux->opt_params = signature->optelems ;
16700
+ aux->params = signature->next_argix ;
16701
+ aux->opt_params = signature->opt_params ;
16694
16702
aux->slurpy = signature->slurpy;
16695
16703
16696
16704
OP *check = newUNOP_AUX(OP_ARGCHECK, 0, NULL, (UNOP_AUX_item *)aux);
0 commit comments