… | |
… | |
13 | #endif |
13 | #endif |
14 | |
14 | |
15 | #if !PERL_VERSION_ATLEAST (5,10,0) |
15 | #if !PERL_VERSION_ATLEAST (5,10,0) |
16 | # define SvPAD_OUR(dummy) 0 |
16 | # define SvPAD_OUR(dummy) 0 |
17 | #endif |
17 | #endif |
|
|
18 | |
|
|
19 | /* pre-5.10 perls always succeed, with 5.10, we have to check first apparently */ |
|
|
20 | #ifndef GvNAME_HEK |
|
|
21 | # define GvNAME_HEK(sv) 1 |
|
|
22 | #endif |
|
|
23 | |
|
|
24 | #ifndef PadARRAY |
|
|
25 | # define PadARRAY(pad) AvARRAY (pad) |
|
|
26 | # define PadlistARRAY(pl) ((PAD **)AvARRAY (pl)) |
|
|
27 | #endif |
|
|
28 | |
18 | |
29 | |
19 | #define res_pair(text) \ |
30 | #define res_pair(text) \ |
20 | do { \ |
31 | do { \ |
21 | AV *av = newAV (); \ |
32 | AV *av = newAV (); \ |
22 | av_push (av, newSVpv (text, 0)); \ |
33 | av_push (av, newSVpv (text, 0)); \ |
… | |
… | |
32 | av_push (av, newSVpv (text, 0)); \ |
43 | av_push (av, newSVpv (text, 0)); \ |
33 | av_push (about, newRV_noinc ((SV *)av)); \ |
44 | av_push (about, newRV_noinc ((SV *)av)); \ |
34 | } while (0) |
45 | } while (0) |
35 | |
46 | |
36 | #define res_gv(sigil) \ |
47 | #define res_gv(sigil) \ |
37 | res_text (form ("in the global %c%s::%.*s", sigil, \ |
48 | res_text (form ("the global %c%s::%.*s", sigil, \ |
38 | HvNAME (GvSTASH (sv)), \ |
49 | HvNAME (GvSTASH (sv)), \ |
39 | GvNAMELEN (sv), \ |
50 | GvNAME_HEK (sv) ? GvNAMELEN (sv) : 11, \ |
40 | GvNAME (sv) ? GvNAME (sv) : "<anonymous>")) |
51 | GvNAME_HEK (sv) ? GvNAME (sv) : "<anonymous>")) |
41 | |
52 | |
42 | MODULE = Devel::FindRef PACKAGE = Devel::FindRef |
53 | MODULE = Devel::FindRef PACKAGE = Devel::FindRef |
43 | |
54 | |
44 | PROTOTYPES: ENABLE |
55 | PROTOTYPES: ENABLE |
45 | |
56 | |
… | |
… | |
127 | { |
138 | { |
128 | case SVt_PVAV: |
139 | case SVt_PVAV: |
129 | if (AvREAL (sv)) |
140 | if (AvREAL (sv)) |
130 | for (i = AvFILLp (sv) + 1; i--; ) |
141 | for (i = AvFILLp (sv) + 1; i--; ) |
131 | if (AvARRAY (sv)[i] == targ) |
142 | if (AvARRAY (sv)[i] == targ) |
132 | res_pair (form ("in array element %d of", i)); |
143 | res_pair (form ("the array element %d of", i)); |
133 | |
144 | |
134 | break; |
145 | break; |
135 | |
146 | |
136 | case SVt_PVHV: |
147 | case SVt_PVHV: |
137 | if (hv_iterinit ((HV *)sv)) |
148 | if (hv_iterinit ((HV *)sv)) |
138 | { |
149 | { |
139 | HE *he; |
150 | HE *he; |
140 | |
151 | |
141 | while ((he = hv_iternext ((HV *)sv))) |
152 | while ((he = hv_iternext ((HV *)sv))) |
142 | if (HeVAL (he) == targ) |
153 | if (HeVAL (he) == targ) |
143 | res_pair (form ("in the member '%.*s' of", HeKLEN (he), HeKEY (he))); |
154 | res_pair (form ("the hash member '%.*s' of", HeKLEN (he), HeKEY (he))); |
144 | } |
155 | } |
145 | |
156 | |
146 | break; |
157 | break; |
147 | |
158 | |
148 | case SVt_PVCV: |
159 | case SVt_PVCV: |
… | |
… | |
153 | if (CvANON (sv) && !depth && CvPADLIST (sv)) |
164 | if (CvANON (sv) && !depth && CvPADLIST (sv)) |
154 | depth = 1; |
165 | depth = 1; |
155 | |
166 | |
156 | if (depth) |
167 | if (depth) |
157 | { |
168 | { |
158 | AV *padlist = CvPADLIST (sv); |
169 | PADLIST *padlist = CvPADLIST (sv); |
159 | |
170 | |
160 | while (depth) |
171 | while (depth) |
161 | { |
172 | { |
162 | AV *pad = (AV *)AvARRAY (padlist)[depth]; |
173 | PAD *pad = PadlistARRAY (padlist)[depth]; |
163 | |
174 | |
164 | av_push (excl, newSVuv (PTR2UV (pad))); /* exclude pads themselves from being found */ |
175 | av_push (excl, newSVuv (PTR2UV (pad))); /* exclude pads themselves from being found */ |
165 | |
176 | |
166 | /* The 0th pad slot is @_ */ |
177 | /* The 0th pad slot is @_ */ |
167 | if (AvARRAY (pad)[0] == targ) |
178 | if (PadARRAY (pad)[0] == targ) |
168 | res_pair ("the argument array for"); |
179 | res_pair ("the argument array for"); |
169 | |
180 | |
170 | for (i = AvFILLp (pad) + 1; --i; ) |
181 | for (i = AvFILLp (pad) + 1; --i; ) |
171 | if (AvARRAY (pad)[i] == targ) |
182 | if (AvARRAY (pad)[i] == targ) |
172 | { |
183 | { |
173 | /* Values from constant functions are stored in the pad without any name */ |
184 | /* Values from constant functions are stored in the pad without any name */ |
174 | SV *name_sv = AvARRAY (AvARRAY (padlist)[0])[i]; |
185 | SV *name_sv = PadARRAY (PadlistARRAY (padlist)[0])[i]; |
175 | |
186 | |
176 | if (name_sv && SvPOK (name_sv)) |
187 | if (name_sv && SvPOK (name_sv)) |
177 | res_pair (form ("in the lexical '%s' in", SvPVX (name_sv))); |
188 | res_pair (form ("the lexical '%s' in", SvPVX (name_sv))); |
178 | else |
189 | else |
179 | res_pair ("in an unnamed lexical in"); |
190 | res_pair ("an unnamed lexical in"); |
180 | } |
191 | } |
181 | |
192 | |
182 | --depth; |
193 | --depth; |
183 | } |
194 | } |
184 | } |
195 | } |
… | |
… | |
221 | { |
232 | { |
222 | MAGIC *mg = mg_find (sv, PERL_MAGIC_defelem); |
233 | MAGIC *mg = mg_find (sv, PERL_MAGIC_defelem); |
223 | |
234 | |
224 | if (mg && mg->mg_obj) |
235 | if (mg && mg->mg_obj) |
225 | res_pair (form ("the target for the lvalue hash element '%.*s',", |
236 | res_pair (form ("the target for the lvalue hash element '%.*s',", |
226 | SvCUR (mg->mg_obj), SvPV_nolen (mg->mg_obj))); |
237 | (int)SvCUR (mg->mg_obj), SvPV_nolen (mg->mg_obj))); |
227 | else |
238 | else |
228 | res_pair (form ("the target for the lvalue array element #%d,", LvTARGOFF (sv))); |
239 | res_pair (form ("the target for the lvalue array element #%d,", LvTARGOFF (sv))); |
229 | } |
240 | } |
230 | else |
241 | else |
231 | res_pair (form ("an lvalue reference target (type '%c', ofs %d, len %d),", |
242 | res_pair (form ("an lvalue reference target (type '%c', ofs %d, len %d),", |