]> git.vpit.fr Git - perl/modules/Lexical-Types.git/blobdiff - Types.xs
Really be compatible with the OP_PARENT feature
[perl/modules/Lexical-Types.git] / Types.xs
index 02e5da71947dad06be2ab3c875f8eca5e2550949..43544760bdb2f4198ba4f7f20782294afc1f2f43 100644 (file)
--- a/Types.xs
+++ b/Types.xs
 # define HvNAMELEN_get(H) strlen(HvNAME_get(H))
 #endif
 
-#ifndef OP_SIBLING
-# define OP_SIBLING(O) ((O)->op_sibling)
+#ifndef OpSIBLING
+# ifdef OP_SIBLING
+#  define OpSIBLING(O) OP_SIBLING(O)
+# else
+#  define OpSIBLING(O) ((O)->op_sibling)
+# endif
 #endif
 
 #ifndef SvREFCNT_inc_simple_void_NN
@@ -687,7 +691,9 @@ STATIC OP *lt_pp_padrange(pTHX) {
   base  = PL_op->op_targ;
   count = PL_op->op_private & OPpPADRANGE_COUNTMASK;
 
-  for (i = 0, p = roi.padxv_start; i < count && p; ++i, p = OP_SIBLING(p)) {
+  for (i = 0, p = roi.padxv_start; i < count && p; ++i, p = p->op_next) {
+   while (p->op_type == OP_NULL)
+    p = p->op_next;
    lt_op_padxv_info oi;
    if (p->op_type == OP_PADSV && lt_padxv_map_fetch(p, &oi))
     lt_op_padxv_info_call(&oi, PAD_SV(base + i));
@@ -806,7 +812,7 @@ STATIC int lt_maybe_padrange_setup(pTHX_ OP *o, const OP *start) {
 
  count = o->op_private & OPpPADRANGE_COUNTMASK;
 
- for (i = 0, p = start; i < count && p; ++i, p = OP_SIBLING(p)) {
+ for (i = 0, p = start; i < count && p; ++i, p = p->op_next) {
   if (p->op_type == OP_PADSV) {
    /* In a padrange sequence, either all lexicals are typed, or none are.
     * Thus we can stop at the first padsv op. However, note that these
@@ -858,8 +864,15 @@ STATIC void lt_peep_rec(pTHX_ OP *o, ptable *seen) {
                                        && !(o->op_flags & OPf_SPECIAL)) {
      /* A padrange op is guaranteed to have previously been a pushmark.
       * Moreover, for non-special padrange ops (i.e. that aren't for
-      * my (...) = @_), the original padxv ops are its siblings. */
-     lt_maybe_padrange_setup(o, OP_SIBLING(o));
+      * my (...) = @_), the first original padxv is its sibling or nephew.
+      */
+     OP *kid = OpSIBLING(o);
+     if (kid->op_type == OP_NULL && kid->op_flags & OPf_KIDS) {
+      kid = kUNOP->op_first;
+      if (kid->op_type == OP_NULL)
+       kid = OpSIBLING(kid);
+     }
+     lt_maybe_padrange_setup(o, kid);
     }
     break;
    case OP_AASSIGN: {
@@ -872,7 +885,7 @@ STATIC void lt_peep_rec(pTHX_ OP *o, ptable *seen) {
                           && op->op_flags & OPf_SPECIAL) {
      const OP *start = cUNOPx(cBINOPo->op_last)->op_first;
      if (start->op_type == OP_PUSHMARK)
-      start = OP_SIBLING(start);
+      start = OpSIBLING(start);
      lt_maybe_padrange_setup(op, start);
     }
     break;