summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2019-09-20 10:57:54 +0100
committerDavid Mitchell <davem@iabyn.com>2019-09-23 14:42:00 +0100
commitf417cfa90670b17255b02c7dc1a88924c102479f (patch)
tree3c2b0db38c681f9aca33e93bab8bfa1900d13c3e /perly.y
parent558b227c020be1ce3d21af4f57ae649d8a2229eb (diff)
downloadperl-f417cfa90670b17255b02c7dc1a88924c102479f.tar.gz
OP_ARGCHECK: use custom aux struct
This op is of class OP_UNOP_AUX, Ops of this class have an op_aux pointer which typically points to a variable-length malloced array of IVs, UVs, etc. However in the specific case of OP_ARGCHECK the data stored in the aux struct is fixed. So this commit casts the aux pointer to a struct containing the relevant fields (number of parameters etc), rather than referring to them as aux[0], aux[1] etc. This makes the code more readable. Should be no functional changes.
Diffstat (limited to 'perly.y')
-rw-r--r--perly.y16
1 files changed, 9 insertions, 7 deletions
diff --git a/perly.y b/perly.y
index bccbbe0f6b..b49b7c6903 100644
--- a/perly.y
+++ b/perly.y
@@ -790,7 +790,7 @@ subsigguts:
siglistornull
{
OP *sigops = $2;
- UNOP_AUX_item *aux;
+ struct op_argcheck_aux *aux;
OP *check;
if (!FEATURE_SIGNATURES_IS_ENABLED)
@@ -802,12 +802,14 @@ subsigguts:
packWARN(WARN_EXPERIMENTAL__SIGNATURES),
"The signatures feature is experimental");
- aux = (UNOP_AUX_item*)PerlMemShared_malloc(
- sizeof(UNOP_AUX_item) * 3);
- aux[0].iv = parser->sig_elems;
- aux[1].iv = parser->sig_optelems;
- aux[2].iv = parser->sig_slurpy;
- check = newUNOP_AUX(OP_ARGCHECK, 0, NULL, aux);
+ aux = (struct op_argcheck_aux*)
+ PerlMemShared_malloc(
+ sizeof(struct op_argcheck_aux));
+ aux->params = parser->sig_elems;
+ aux->opt_params = parser->sig_optelems;
+ aux->slurpy = parser->sig_slurpy;
+ check = newUNOP_AUX(OP_ARGCHECK, 0, NULL,
+ (UNOP_AUX_item *)aux);
sigops = op_prepend_elem(OP_LINESEQ, check, sigops);
sigops = op_prepend_elem(OP_LINESEQ,
newSTATEOP(0, NULL, NULL),