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.19 by root, Sun Aug 30 14:34:41 2009 UTC vs.
Revision 1.25 by root, Sun May 18 18:44:08 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)); \
101 { 107 {
102 /* I have no clue what this is */ 108 /* I have no clue what this is */
103 /* maybe some placeholder for our variables for eval? */ 109 /* maybe some placeholder for our variables for eval? */
104 /* it doesn't seem to reference anything, so we should be able to ignore it */ 110 /* it doesn't seem to reference anything, so we should be able to ignore it */
105 } 111 }
106 else 112 else if (SvMAGICAL (sv)) /* name-pads use SvMAGIC for other purposes */
107 { 113 {
108 MAGIC *mg = SvMAGIC (sv); 114 MAGIC *mg = SvMAGIC (sv);
109 115
110 while (mg) 116 while (mg)
111 { 117 {
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");
226 { 233 {
227 MAGIC *mg = mg_find (sv, PERL_MAGIC_defelem); 234 MAGIC *mg = mg_find (sv, PERL_MAGIC_defelem);
228 235
229 if (mg && mg->mg_obj) 236 if (mg && mg->mg_obj)
230 res_pair (form ("the target for the lvalue hash element '%.*s',", 237 res_pair (form ("the target for the lvalue hash element '%.*s',",
231 SvCUR (mg->mg_obj), SvPV_nolen (mg->mg_obj))); 238 (int)SvCUR (mg->mg_obj), SvPV_nolen (mg->mg_obj)));
232 else 239 else
233 res_pair (form ("the target for the lvalue array element #%d,", LvTARGOFF (sv))); 240 res_pair (form ("the target for the lvalue array element #%d,", LvTARGOFF (sv)));
234 } 241 }
235 else 242 else
236 res_pair (form ("an lvalue reference target (type '%c', ofs %d, len %d),", 243 res_pair (form ("an lvalue reference target (type '%c', ofs %d, len %d),",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines