… | |
… | |
11 | #if !PERL_VERSION_ATLEAST (5,8,9) |
11 | #if !PERL_VERSION_ATLEAST (5,8,9) |
12 | # define SVt_LAST 16 |
12 | # define SVt_LAST 16 |
13 | #endif |
13 | #endif |
14 | |
14 | |
15 | #define res_pair(text) \ |
15 | #define res_pair(text) \ |
16 | { \ |
16 | do { \ |
17 | AV *av = newAV (); \ |
17 | AV *av = newAV (); \ |
18 | av_push (av, newSVpv (text, 0)); \ |
18 | av_push (av, newSVpv (text, 0)); \ |
19 | if (rmagical) SvRMAGICAL_on (sv); \ |
19 | if (rmagical) SvRMAGICAL_on (sv); \ |
20 | av_push (av, sv_rvweaken (newRV_inc (sv))); \ |
20 | av_push (av, sv_rvweaken (newRV_inc (sv))); \ |
21 | if (rmagical) SvRMAGICAL_off (sv); \ |
21 | if (rmagical) SvRMAGICAL_off (sv); \ |
22 | av_push (about, newRV_noinc ((SV *)av)); \ |
22 | av_push (about, newRV_noinc ((SV *)av)); \ |
23 | } |
23 | } while (0) |
24 | |
24 | |
25 | #define res_gv(sigil) \ |
25 | #define res_gv(sigil) \ |
26 | { \ |
26 | do { \ |
27 | AV *av = newAV (); \ |
27 | AV *av = newAV (); \ |
28 | av_push (av, newSVpv (form ("in the global %c%s::%.*s", sigil, \ |
28 | av_push (av, newSVpv (form ("in the global %c%s::%.*s", sigil, \ |
29 | HvNAME (GvSTASH (sv)), \ |
29 | HvNAME (GvSTASH (sv)), \ |
30 | GvNAMELEN (sv), GvNAME (sv) ? GvNAME (sv) : "<anonymous>"), \ |
30 | GvNAMELEN (sv), GvNAME (sv) ? GvNAME (sv) : "<anonymous>"), \ |
31 | 0)); \ |
31 | 0)); \ |
32 | av_push (about, newRV_noinc ((SV *)av)); \ |
32 | av_push (about, newRV_noinc ((SV *)av)); \ |
33 | } |
33 | } while (0) |
34 | |
34 | |
35 | MODULE = Devel::FindRef PACKAGE = Devel::FindRef |
35 | MODULE = Devel::FindRef PACKAGE = Devel::FindRef |
36 | |
36 | |
37 | PROTOTYPES: ENABLE |
37 | PROTOTYPES: ENABLE |
38 | |
38 | |
… | |
… | |
119 | |
119 | |
120 | case SVt_PVCV: |
120 | case SVt_PVCV: |
121 | { |
121 | { |
122 | int depth = CvDEPTH (sv); |
122 | int depth = CvDEPTH (sv); |
123 | |
123 | |
|
|
124 | /* Anonymous subs have a padlist but zero depth */ |
124 | if (!depth && CvPADLIST(sv)) |
125 | if (!depth && CvPADLIST (sv)) |
125 | depth = 1; |
126 | depth = 1; |
126 | |
127 | |
127 | if (depth) |
128 | if (depth) |
128 | { |
129 | { |
129 | AV *padlist = CvPADLIST (sv); |
130 | AV *padlist = CvPADLIST (sv); |
… | |
… | |
134 | |
135 | |
135 | av_push (excl, newSVuv (PTR2UV (pad))); /* exclude pads themselves from being found */ |
136 | av_push (excl, newSVuv (PTR2UV (pad))); /* exclude pads themselves from being found */ |
136 | |
137 | |
137 | for (i = AvFILLp (pad) + 1; i--; ) |
138 | for (i = AvFILLp (pad) + 1; i--; ) |
138 | if (AvARRAY (pad)[i] == targ) |
139 | if (AvARRAY (pad)[i] == targ) |
|
|
140 | { |
|
|
141 | /* Values from constant functions are stored in the pad without any name */ |
|
|
142 | SV *name_sv = AvARRAY (AvARRAY (padlist)[0])[i]; |
|
|
143 | |
|
|
144 | if (name_sv && SvPOK (name_sv)) |
139 | res_pair (form ("in the lexical '%s' in", SvPVX (AvARRAY (AvARRAY (padlist)[0])[i]))); |
145 | res_pair (form ("in the lexical '%s' in", SvPVX (name_sv))); |
|
|
146 | else |
|
|
147 | res_pair ("in an unnamed lexical in"); |
|
|
148 | } |
140 | |
149 | |
141 | --depth; |
150 | --depth; |
142 | } |
151 | } |
143 | } |
152 | } |
144 | |
153 | |
|
|
154 | if (CvCONST (sv) && (SV*)CvXSUBANY (sv).any_ptr == targ) |
|
|
155 | res_pair ("the constant value of"); |
|
|
156 | |
145 | if ((SV*)CvOUTSIDE(sv) == targ) |
157 | if (!CvWEAKOUTSIDE (sv) && (SV*)CvOUTSIDE (sv) == targ) |
146 | res_pair ("the containing scope for"); |
158 | res_pair ("the containing scope for"); |
147 | } |
159 | } |
148 | |
160 | |
149 | break; |
161 | break; |
150 | |
162 | |