ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Devel-FindRef/FindRef.xs
(Generate patch)

Comparing Devel-FindRef/FindRef.xs (file contents):
Revision 1.20 by root, Tue Sep 8 18:12:07 2009 UTC vs.
Revision 1.24 by root, Fri May 16 07:43:52 2014 UTC

18 18
19/* pre-5.10 perls always succeed, with 5.10, we have to check first apparently */ 19/* pre-5.10 perls always succeed, with 5.10, we have to check first apparently */
20#ifndef GvNAME_HEK 20#ifndef GvNAME_HEK
21# define GvNAME_HEK(sv) 1 21# define GvNAME_HEK(sv) 1
22#endif 22#endif
23
24#ifndef PadARRAY
25# define PadARRAY(pad) AvARRAY (pad)
26# define PadlistARRAY(pl) ((PAD **)AvARRAY (pl))
27#endif
28
23 29
24#define res_pair(text) \ 30#define res_pair(text) \
25 do { \ 31 do { \
26 AV *av = newAV (); \ 32 AV *av = newAV (); \
27 av_push (av, newSVpv (text, 0)); \ 33 av_push (av, newSVpv (text, 0)); \
143 { 149 {
144 HE *he; 150 HE *he;
145 151
146 while ((he = hv_iternext ((HV *)sv))) 152 while ((he = hv_iternext ((HV *)sv)))
147 if (HeVAL (he) == targ) 153 if (HeVAL (he) == targ)
148 res_pair (form ("the member '%.*s' of", HeKLEN (he), HeKEY (he))); 154 res_pair (form ("the hash member '%.*s' of", HeKLEN (he), HeKEY (he)));
149 } 155 }
150 156
151 break; 157 break;
152 158
153 case SVt_PVCV: 159 case SVt_PVCV:
154 { 160 {
155 int depth = CvDEPTH (sv); 161 PADLIST *padlist = CvPADLIST (sv);
156 162
157 /* Anonymous subs have a padlist but zero depth */
158 if (CvANON (sv) && !depth && CvPADLIST (sv))
159 depth = 1;
160
161 if (depth) 163 if (padlist)
162 { 164 {
163 AV *padlist = CvPADLIST (sv); 165 int depth = CvDEPTH (sv);
166
167 /* Anonymous subs have a padlist but zero depth */
168 /* some hacks switch CvANON off, so we just blindly assume a minimum of 1 */
169 if (!depth)
170 depth = 1;
164 171
165 while (depth) 172 while (depth)
166 { 173 {
167 AV *pad = (AV *)AvARRAY (padlist)[depth]; 174 PAD *pad = PadlistARRAY (padlist)[depth];
168 175
169 av_push (excl, newSVuv (PTR2UV (pad))); /* exclude pads themselves from being found */ 176 av_push (excl, newSVuv (PTR2UV (pad))); /* exclude pads themselves from being found */
170 177
171 /* The 0th pad slot is @_ */ 178 /* The 0th pad slot is @_ */
172 if (AvARRAY (pad)[0] == targ) 179 if (PadARRAY (pad)[0] == targ)
173 res_pair ("the argument array for"); 180 res_pair ("the argument array for");
174 181
175 for (i = AvFILLp (pad) + 1; --i; ) 182 for (i = AvFILLp (pad) + 1; --i; )
176 if (AvARRAY (pad)[i] == targ) 183 if (AvARRAY (pad)[i] == targ)
177 { 184 {
178 /* Values from constant functions are stored in the pad without any name */ 185 /* Values from constant functions are stored in the pad without any name */
179 SV *name_sv = AvARRAY (AvARRAY (padlist)[0])[i]; 186 SV *name_sv = PadARRAY (PadlistARRAY (padlist)[0])[i];
180 187
181 if (name_sv && SvPOK (name_sv)) 188 if (name_sv && SvPOK (name_sv))
182 res_pair (form ("the lexical '%s' in", SvPVX (name_sv))); 189 res_pair (form ("the lexical '%s' in", SvPVX (name_sv)));
183 else 190 else
184 res_pair ("an unnamed lexical in"); 191 res_pair ("an unnamed lexical in");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines