Skip to content

Commit dd81c5f

Browse files
committed
Rename fields of struct yy_parser_signature for clarity
The previous names were just copied from similar fields in previous signature handling code. These new names are a better fit for their current and intended future purpose.
1 parent a7eccf4 commit dd81c5f

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

op.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16476,8 +16476,16 @@ Perl_rcpv_copy(pTHX_ char *pv) {
1647616476
/* Subroutine signature parsing */
1647716477

1647816478
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 */
1648116489
char slurpy; /* the sigil of the slurpy var (or null) */
1648216490
OP *elemops; /* NULL, or an OP_LINESEQ of individual element and fence ops */
1648316491
};
@@ -16508,8 +16516,8 @@ Perl_subsignature_start(pTHX)
1650816516
Newx(signature, 1, yy_parser_signature);
1650916517
SAVEDESTRUCTOR_X(&destroy_subsignature_context, signature);
1651016518

16511-
signature->elems = 0;
16512-
signature->optelems = 0;
16519+
signature->next_argix = 0;
16520+
signature->opt_params = 0;
1651316521
signature->slurpy = 0;
1651416522

1651516523
signature->elemops = NULL;
@@ -16567,7 +16575,8 @@ Perl_subsignature_append_positional(pTHX_ PADOFFSET padix, OPCODE defmode, OP *d
1656716575
if(signature->slurpy)
1656816576
yyerror("Slurpy parameter not last");
1656916577

16570-
UV argix = signature->elems;
16578+
UV argix = signature->next_argix;
16579+
signature->next_argix++;
1657116580

1657216581
OP *varop = NULL;
1657316582
if(padix) {
@@ -16579,10 +16588,8 @@ Perl_subsignature_append_positional(pTHX_ PADOFFSET padix, OPCODE defmode, OP *d
1657916588
cUNOP_AUXx(varop)->op_aux = INT2PTR(UNOP_AUX_item *, argix);
1658016589
}
1658116590

16582-
signature->elems++;
16583-
1658416591
if(defexpr) {
16585-
signature->optelems++;
16592+
signature->opt_params++;
1658616593

1658716594
if(defexpr->op_type == OP_NULL && !(defexpr->op_flags & OPf_KIDS))
1658816595
{
@@ -16622,7 +16629,7 @@ Perl_subsignature_append_positional(pTHX_ PADOFFSET padix, OPCODE defmode, OP *d
1662216629
}
1662316630
}
1662416631
else
16625-
if(signature->optelems)
16632+
if(signature->opt_params)
1662616633
yyerror("Mandatory parameter follows optional parameter");
1662716634

1662816635
if(varop) {
@@ -16649,7 +16656,8 @@ Perl_subsignature_append_slurpy(pTHX_ I32 sigil, PADOFFSET padix)
1664916656
if(signature->slurpy)
1665016657
yyerror("Multiple slurpy parameters not allowed");
1665116658

16652-
UV argix = signature->elems;
16659+
UV argix = signature->next_argix;
16660+
/* do not increment */
1665316661

1665416662
signature->slurpy = (char)sigil;
1665516663

@@ -16689,8 +16697,8 @@ Perl_subsignature_finish(pTHX)
1668916697
struct op_argcheck_aux *aux = (struct op_argcheck_aux *)
1669016698
PerlMemShared_malloc( sizeof(struct op_argcheck_aux));
1669116699

16692-
aux->params = signature->elems;
16693-
aux->opt_params = signature->optelems;
16700+
aux->params = signature->next_argix;
16701+
aux->opt_params = signature->opt_params;
1669416702
aux->slurpy = signature->slurpy;
1669516703

1669616704
OP *check = newUNOP_AUX(OP_ARGCHECK, 0, NULL, (UNOP_AUX_item *)aux);

0 commit comments

Comments
 (0)