Subject: | [PATCH] Pad changes in 5.17.4-to-be |
This module no longer compiles with bleadperl. Attached is a patch. See
http://perl5.git.perl.org/perl.git/commitdiff/86b9d29366 and
http://perl5.git.perl.org/perl.git/commitdiff/35e035ccb for more information.
Subject: | open_uCzjUK3j.txt |
diff -rup Eval-Compile-0.10-j8v_qy/Compile.xs Eval-Compile-0.10-raBUMW/Compile.xs
--- Eval-Compile-0.10-j8v_qy/Compile.xs 2010-12-13 06:33:15.000000000 -0800
+++ Eval-Compile-0.10-raBUMW/Compile.xs 2012-08-22 18:03:35.000000000 -0700
@@ -22,6 +22,27 @@
# define COP_SEQ_RANGE_HIGH(sv) U_32(SvUVX(sv))
#endif
+#ifndef PAD_ARRAY
+typedef AV PADNAMELIST;
+typedef SV PADNAME;
+# if PERL_VERSION < 9
+typedef AV PADLIST;
+typedef AV PAD;
+# endif
+# define PADLIST_ARRAY AvARRAY
+# define PADLIST_NAMES(pl) (*PADLIST_ARRAY(pl))
+# define PADNAMELIST_ARRAY AvARRAY
+# define PADNAMELIST_MAX AvFILLp
+# define PAD_ARRAY AvARRAY
+# define PAD_MAX AvFILLp
+# define PADNAME_PV(pn) (SvPOKp(pn) ? SvPVX(pn) : NULL)
+# define PADNAME_LEN(pn) SvCUR(pn)
+# define PADNAME_isOUR(pn) !!(SvFLAGS(pn) & SVpad_OUR)
+# define PADNAME_OUTER(pn) !!SvFAKE(pn)
+# define PADNAME_SV(pn) pn
+#endif
+
+
/* For development testing */
#ifdef PADWALKER_DEBUGGING
@@ -65,10 +86,10 @@ my_av_pushpvn( pTHX_ AV *av, char *p, ST
void _show_cvpad( CV *cv ){
if ( cv && CvPADLIST( cv ) ){
- AV *padlist = CvPADLIST( cv );
- AV * padnames = (AV *)(AvARRAY(padlist)[0]);
+ PADLIST *padlist = CvPADLIST( cv );
+ PADNAMELIST * padnames = PADLIST_NAMES(padlist);
I32 i;
- I32 namefill = AvFILLp( padnames );
+ I32 namefill = PADNAMELIST_MAX( padnames );
CV *cvout;
if ( PL_DBsub && cv == GvCV(PL_DBsub) ){
fprintf( stderr, " DB::sub");
@@ -83,12 +104,13 @@ void _show_cvpad( CV *cv ){
cvout = CvOUTSIDE( cvout );
} while( cvout );
for(i=0; i<=namefill; ++i){
- SV *name_sv;
+ PADNAME *name_sv;
STRLEN name_len;
- name_sv = AvARRAY( padnames )[i];
- if (name_sv && SvPOKp(name_sv) && ( name_len = SvCUR(name_sv)) > 1) {
- char* name_str = SvPVX(name_sv);
- bool is_my = ((SvFLAGS(name_sv) & SVpad_OUR) == 0);
+ name_sv = PADNAMELIST_ARRAY( padnames )[i];
+ if (name_sv && PADNAME_PV(name_sv)
+ && ( name_len = PADNAME_LEN(name_sv)) > 1) {
+ char* name_str = PADNAME_PV(name_sv);
+ bool is_my = !PADNAME_isOUR(name_sv);
if ( is_my ) {
fprintf( stderr, " %s(%d,%d)", name_str, COP_SEQ_RANGE_LOW(name_sv), COP_SEQ_RANGE_HIGH(name_sv) );
}
@@ -99,10 +121,10 @@ void _show_cvpad( CV *cv ){
typedef struct my_closure{
CV *closure_cv;
- AV **closure_pad;
+ PAD **closure_pad;
long stack_depth;
CV *outer;
- AV **outer_pad;
+ PAD **outer_pad;
I32 outer_depth;
I32 offset_size;
I32 *position;
@@ -119,17 +141,17 @@ cl_prepare_closure( pTHX_ p_closure cl,
I32
find_sv( CV * cv, I32 cv_depth, U32 cop_seq, SV *val ){
I32 i;
- AV *pad;
- AV *padval;
- AV *padname;
+ PADLIST *pad;
+ PAD *padval;
+ PADNAMELIST *padname;
pad= CvPADLIST( cv );
if (!pad)
return -1;
- padval = (AV *)AvARRAY( pad )[cv_depth];
- padname = (AV *)AvARRAY( pad )[0];
- for ( i=0; i<=AvFILLp( padval ); ++i){
- if ( AvARRAY( padval )[i] == val ){
- if ( SvFAKE(AvELT( padname, i))){
+ padval = PADLIST_ARRAY( pad )[cv_depth];
+ padname = PADLIST_NAMES(pad);
+ for ( i=0; i<=PAD_MAX( padval ); ++i){
+ if ( PAD_ARRAY( padval )[i] == val ){
+ if ( PADNAME_OUTER(AvELT( padname, i))){
// fprintf( stderr, "==!!!===%d\n", i);
return -2;
}
@@ -148,15 +170,15 @@ void cl_init( pTHX_ p_closure cl, AV*tem
U32 context_seq;
CV *curcv;
I32 curcv_depth;
- AV *names;
- AV *values;
+ PADNAMELIST *names;
+ PAD *values;
long stack_depth;
int i;
bool context_match;
if ( ! cl->ok )
return;
if (cv && CvPADLIST( cv ) ){
- AV *padlist = CvPADLIST( cv );
+ PADLIST *padlist = CvPADLIST( cv );
if (CvDEPTH(cv)){
croak( "Fail compile: cv is running" );
}
@@ -202,16 +224,16 @@ void cl_init( pTHX_ p_closure cl, AV*tem
if ( ! CvPADLIST( curcv ))
return;
- names = (AV *)(AvARRAY(padlist)[0]);
- values =(AV *)(AvARRAY(padlist)[1]);
- for (i=0; i<= AvFILLp( names ) ; ++i ){
- SV *name_sv;
+ names = PADLIST_NAMES(padlist);
+ values =PADLIST_ARRAY(padlist)[1];
+ for (i=0; i<= PADNAMELIST_MAX( names ) ; ++i ){
+ PADNAME *name_sv;
SV *val_sv;
- name_sv = (AvARRAY(names)[i]);
- val_sv = AvARRAY( values )[i];
- if ( SvPOKp(name_sv) && SvFAKE(name_sv)
- && 0 == (SvFLAGS(name_sv) & SVpad_OUR )
- && SvCUR(name_sv) > 1 ){
+ name_sv = (PADNAMELIST_ARRAY(names)[i]);
+ val_sv = PAD_ARRAY( values )[i];
+ if ( PADNAME_PV(name_sv) && PADNAME_OUTER(name_sv)
+ && !PADNAME_isOUR(name_sv)
+ && PADNAME_LEN(name_sv) > 1 ){
++(cl->offset_size);
}
}
@@ -228,13 +250,13 @@ void cl_init( pTHX_ p_closure cl, AV*tem
cl->offset_size = 0;
for (i=0; i<= AvFILLp( names ) ; ++i ){
- SV *name_sv;
+ PADNAME *name_sv;
SV *val_sv;
name_sv = (AvARRAY(names)[i]);
val_sv = AvARRAY( values )[i];
- if ( SvPOKp(name_sv) && SvFAKE(name_sv)
- && 0 == (SvFLAGS(name_sv) & SVpad_OUR )
- && SvCUR(name_sv) > 1 ){
+ if ( PADNAME_PV(name_sv) && PADNAME_OUTER(name_sv)
+ && !PADNAME_isOUR(name_sv)
+ && PADNAME_LEN(name_sv) > 1 ){
I32 position;
position = find_sv( curcv, curcv_depth, context_seq, val_sv);
//fprintf( stderr, "%d=\n", position );
@@ -246,8 +268,8 @@ void cl_init( pTHX_ p_closure cl, AV*tem
cl->position[ cl->offset_size++] = i;
}
}
- cl->outer_pad =( AV **) AvARRAY( CvPADLIST( curcv ));
- cl->closure_pad = ( AV **)AvARRAY( CvPADLIST( cl->closure_cv ));
+ cl->outer_pad = PADLIST_ARRAY( CvPADLIST( curcv ));
+ cl->closure_pad = PADLIST_ARRAY( CvPADLIST( cl->closure_cv ));
cl_prepare_closure( aTHX_ cl, 0 );
//fprintf( stderr, "\n");
}
@@ -258,8 +280,8 @@ cl_prepare_closure( pTHX_ p_closure cl,
I32 i;
I32 j;
I32 cv_depth = cl->outer_depth;
- SV **out_values = AvARRAY(cl->outer_pad[cv_depth]);
- SV **closure_values = AvARRAY(cl->closure_pad[1]);
+ SV **out_values = PAD_ARRAY(cl->outer_pad[cv_depth]);
+ SV **closure_values = PAD_ARRAY(cl->closure_pad[1]);
if ( !cl->ok )
return;
@@ -545,8 +567,8 @@ void
callers( CV * cv, SV *eval_string )
PREINIT:
int i;
- AV *names;
- AV *values;
+ PADNAMELIST *names;
+ PAD *values;
CV *subcv;
long subcv_depth;
long stack_depth;
@@ -555,7 +577,7 @@ callers( CV * cv, SV *eval_string )
AV *results;
PPCODE:
if (cv && CvPADLIST( cv ) ){
- AV *padlist = CvPADLIST( cv );
+ PADLIST *padlist = CvPADLIST( cv );
if (CvDEPTH(cv)){
croak( "Fail compile: cv is running" );
}
@@ -596,18 +618,19 @@ callers( CV * cv, SV *eval_string )
_show_cvpad( cxstack[ stack_depth ].blk_sub.cv );
- names = (AV *)(AvARRAY(padlist)[0]);
- values =(AV *)(AvARRAY(padlist)[1]);
+ names = PADLIST_NAMES(padlist);
+ values =PADLIST_ARRAY(padlist)[1];
- for (i=0; i<= AvFILLp( names ) ; ++i ){
- SV *name_sv;
+ for (i=0; i<= PADNAMELIST_MAX( names ) ; ++i ){
+ PADNAME *padn;
SV *val_sv;
- name_sv = (AvARRAY(names)[i]);
- val_sv = AvARRAY( values )[i];
- if ( SvPOKp(name_sv) && SvFAKE(name_sv)
- && 0 == (SvFLAGS(name_sv) & SVpad_OUR )
- && SvCUR(name_sv) > 1 ){
+ padn = (PADNAMELIST_ARRAY(names)[i]);
+ val_sv = PAD_ARRAY( values )[i];
+ if ( PADNAME_PV(padn) && PADNAME_OUTER(padn)
+ && !PADNAME_isOUR(padn)
+ && PADNAME_LEN(padn) > 1 ){
I32 position;
+ SV * const name_sv = PADNAME_SV(padn);
XPUSHs(name_sv);
mXPUSHi( i );
position = find_sv( subcv, subcv_depth, context_seq, val_sv);