develooper Front page | perl.perl5.porters | Postings from November 2014

[perl #123109] [PATCH 3/5] op.c: regularize OP_AELEMFAST_LEX vs OP_AELEMFAST setup.

From:
Jim Cromie
Date:
November 2, 2014 21:03
Subject:
[perl #123109] [PATCH 3/5] op.c: regularize OP_AELEMFAST_LEX vs OP_AELEMFAST setup.
Message ID:
rt-4.0.18-18670-1414962154-337.123109-75-0@perl.org
# New Ticket Created by  Jim Cromie 
# Please include the string:  [perl #123109]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=123109 >


A previous patch promoted CHANGE_TYPE as the "normal" way to
initialize op_type and op_ppaddr fields.  This suggests that
Perl_rpeep()s tweaking of OP_AELEMFAST and OP_AELEMFAST_LEX is
something of a special case.

It turns out that these are pretty normal too; since regen/opcode.pl
insures that PL_ppaddr[OP_AELEMFAST_LEX] == PL_ppaddr[OP_AELEMFAST],
the invariant: o->op_ppaddr == PL_ppaddr[o->op_type] holds after both
the OP_AELEMFAST and OP_AELEMFAST_LEX branches, and the stronger
semantics of CHANGE_TYPE() can be used to communicate this normality.
---
 op.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/op.c b/op.c
index f259e68..de5f93d 100644
--- a/op.c
+++ b/op.c
@@ -12282,15 +12282,14 @@ Perl_rpeep(pTHX_ OP *o)
 		    op_null(pop);
 		    o->op_flags |= pop->op_next->op_flags & OPf_MOD;
 		    o->op_next = pop->op_next->op_next;
-		    o->op_ppaddr = PL_ppaddr[OP_AELEMFAST];
 		    o->op_private = (U8)i;
 		    if (o->op_type == OP_GV) {
 			gv = cGVOPo_gv;
 			GvAVn(gv);
-			o->op_type = OP_AELEMFAST;
+                        CHANGE_TYPE(o, OP_AELEMFAST);
 		    }
 		    else
-			o->op_type = OP_AELEMFAST_LEX;
+                        CHANGE_TYPE(o, OP_AELEMFAST_LEX);
 		}
 		if (o->op_type != OP_GV)
 		    break;
-- 
1.8.3.1




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About