Move PAD_FAKELEX_ANON and PAD_FAKELEX_MULTI to pad.h, export them via
[p5sagit/p5-mst-13.2.git] / pad.h
diff --git a/pad.h b/pad.h
index b234e63..44e9385 100644 (file)
--- a/pad.h
+++ b/pad.h
@@ -30,7 +30,69 @@ typedef U64TYPE PADOFFSET;
 #   endif
 #endif
 #define NOT_IN_PAD ((PADOFFSET) -1)
+
+/* B.xs needs these for the benefit of B::Deparse */ 
+/* Low range end is exclusive (valid from the cop seq after this one) */
+/* High range end is inclusive (valid up to this cop seq) */
+
+#if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
+#  define COP_SEQ_RANGE_LOW(sv)                                                \
+       (({ SV *const _svi = (SV *) (sv);                               \
+         assert(SvTYPE(_svi) == SVt_NV || SvTYPE(_svi) >= SVt_PVNV);   \
+         assert(SvTYPE(_svi) != SVt_PVAV);                             \
+         assert(SvTYPE(_svi) != SVt_PVHV);                             \
+         assert(SvTYPE(_svi) != SVt_PVCV);                             \
+         assert(SvTYPE(_svi) != SVt_PVFM);                             \
+         assert(!isGV_with_GP(_svi));                                  \
+         ((XPVNV*) SvANY(_svi))->xnv_u.xpad_cop_seq.xlow;              \
+        }))
+#  define COP_SEQ_RANGE_HIGH(sv)                                       \
+       (({ SV *const _svi = (SV *) (sv);                               \
+         assert(SvTYPE(_svi) == SVt_NV || SvTYPE(_svi) >= SVt_PVNV);   \
+         assert(SvTYPE(_svi) != SVt_PVAV);                             \
+         assert(SvTYPE(_svi) != SVt_PVHV);                             \
+         assert(SvTYPE(_svi) != SVt_PVCV);                             \
+         assert(SvTYPE(_svi) != SVt_PVFM);                             \
+         assert(!isGV_with_GP(_svi));                                  \
+         ((XPVNV*) SvANY(_svi))->xnv_u.xpad_cop_seq.xhigh;             \
+        }))
+#  define PARENT_PAD_INDEX(sv)                                         \
+       (({ SV *const _svi = (SV *) (sv);                               \
+         assert(SvTYPE(_svi) == SVt_NV || SvTYPE(_svi) >= SVt_PVNV);   \
+         assert(SvTYPE(_svi) != SVt_PVAV);                             \
+         assert(SvTYPE(_svi) != SVt_PVHV);                             \
+         assert(SvTYPE(_svi) != SVt_PVCV);                             \
+         assert(SvTYPE(_svi) != SVt_PVFM);                             \
+         assert(!isGV_with_GP(_svi));                                  \
+         ((XPVNV*) SvANY(_svi))->xnv_u.xpad_cop_seq.xlow;              \
+        }))
+#  define PARENT_FAKELEX_FLAGS(sv)                                     \
+       (({ SV *const _svi = (SV *) (sv);                               \
+         assert(SvTYPE(_svi) == SVt_NV || SvTYPE(_svi) >= SVt_PVNV);   \
+         assert(SvTYPE(_svi) != SVt_PVAV);                             \
+         assert(SvTYPE(_svi) != SVt_PVHV);                             \
+         assert(SvTYPE(_svi) != SVt_PVCV);                             \
+         assert(SvTYPE(_svi) != SVt_PVFM);                             \
+         assert(!isGV_with_GP(_svi));                                  \
+         ((XPVNV*) SvANY(_svi))->xnv_u.xpad_cop_seq.xhigh;             \
+        }))
+#else
+#  define COP_SEQ_RANGE_LOW(sv)                \
+       (0 + (((XPVNV*) SvANY(sv))->xnv_u.xpad_cop_seq.xlow))
+#  define COP_SEQ_RANGE_HIGH(sv)       \
+       (0 + (((XPVNV*) SvANY(sv))->xnv_u.xpad_cop_seq.xhigh))
+
+
+#  define PARENT_PAD_INDEX(sv)         \
+       (0 + (((XPVNV*) SvANY(sv))->xnv_u.xpad_cop_seq.xlow))
+#  define PARENT_FAKELEX_FLAGS(sv)     \
+       (0 + (((XPVNV*) SvANY(sv))->xnv_u.xpad_cop_seq.xhigh))
+#endif
+
+/* Flags set in the SvIVX field of FAKE namesvs */
+    
+#define PAD_FAKELEX_ANON   1 /* the lex is declared in an ANON, or ... */
+#define PAD_FAKELEX_MULTI  2 /* the lex can be instantiated multiple times */
 
 /* flags for the pad_new() function */
 
@@ -50,14 +112,20 @@ typedef enum {
  * whether PL_comppad and PL_curpad are consistent and whether they have
  * active values */
 
+#ifndef PERL_MAD
+#  define pad_peg(label)
+#endif
+
 #ifdef DEBUGGING
 #  define ASSERT_CURPAD_LEGAL(label) \
+    pad_peg(label); \
     if (PL_comppad ? (AvARRAY(PL_comppad) != PL_curpad) : (PL_curpad != 0))  \
        Perl_croak(aTHX_ "panic: illegal pad in %s: 0x%"UVxf"[0x%"UVxf"]",\
            label, PTR2UV(PL_comppad), PTR2UV(PL_curpad));
 
 
 #  define ASSERT_CURPAD_ACTIVE(label) \
+    pad_peg(label); \
     if (!PL_comppad || (AvARRAY(PL_comppad) != PL_curpad))               \
        Perl_croak(aTHX_ "panic: invalid pad in %s: 0x%"UVxf"[0x%"UVxf"]",\
            label, PTR2UV(PL_comppad), PTR2UV(PL_curpad));
@@ -141,17 +209,17 @@ Restore the old pad saved into the local variable opad by PAD_SAVE_LOCAL()
            ? AvARRAY((AV*)(AvARRAY(padlist)[1]))[po] : NULL;
     
 
-#define PAD_SET_CUR_NOSAVE(padlist,n) \
-       PL_comppad = (PAD*) (AvARRAY(padlist)[n]);              \
+#define PAD_SET_CUR_NOSAVE(padlist,nth) \
+       PL_comppad = (PAD*) (AvARRAY(padlist)[nth]);            \
        PL_curpad = AvARRAY(PL_comppad);                        \
        DEBUG_Xv(PerlIO_printf(Perl_debug_log,                  \
              "Pad 0x%"UVxf"[0x%"UVxf"] set_cur    depth=%d\n", \
-             PTR2UV(PL_comppad), PTR2UV(PL_curpad), (int)(n)));
+             PTR2UV(PL_comppad), PTR2UV(PL_curpad), (int)(nth)));
 
 
-#define PAD_SET_CUR(padlist,n) \
+#define PAD_SET_CUR(padlist,nth) \
        SAVECOMPPAD();                                          \
-       PAD_SET_CUR_NOSAVE(padlist,n);
+       PAD_SET_CUR_NOSAVE(padlist,nth);
 
 
 #define PAD_SAVE_SETNULLPAD()  SAVECOMPPAD(); \
@@ -226,7 +294,7 @@ ling pad (lvalue) to C<gen>.  Note that C<SvCUR_set> is hijacked for this purpos
 #define PAD_COMPNAME_TYPE(po) pad_compname_type(po)
 
 #define PAD_COMPNAME_OURSTASH(po) \
-    (GvSTASH(*av_fetch(PL_comppad_name, (po), FALSE)))
+    (OURSTASH(*av_fetch(PL_comppad_name, (po), FALSE)))
 
 #define PAD_COMPNAME_GEN(po) SvCUR(AvARRAY(PL_comppad_name)[po])