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.6 by root, Sat Dec 29 21:04:46 2007 UTC vs.
Revision 1.8 by root, Sun Apr 27 05:59:06 2008 UTC

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 av_push (av, sv_rvweaken (newRV_inc (sv))); \ 20 av_push (av, sv_rvweaken (newRV_inc (sv))); \
21 if (rmagical) SvRMAGICAL_off (sv); \
20 av_push (about, newRV_noinc ((SV *)av)); \ 22 av_push (about, newRV_noinc ((SV *)av)); \
21 } 23 } while (0)
22 24
23#define res_gv(sigil) \ 25#define res_gv(sigil) \
24 { \ 26 do { \
25 AV *av = newAV (); \ 27 AV *av = newAV (); \
26 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, \
27 HvNAME (GvSTASH (sv)), \ 29 HvNAME (GvSTASH (sv)), \
28 GvNAMELEN (sv), GvNAME (sv) ? GvNAME (sv) : "<anonymous>"), \ 30 GvNAMELEN (sv), GvNAME (sv) ? GvNAME (sv) : "<anonymous>"), \
29 0)); \ 31 0)); \
30 av_push (about, newRV_noinc ((SV *)av)); \ 32 av_push (about, newRV_noinc ((SV *)av)); \
31 } 33 } while (0)
32 34
33MODULE = Devel::FindRef PACKAGE = Devel::FindRef 35MODULE = Devel::FindRef PACKAGE = Devel::FindRef
34 36
35PROTOTYPES: ENABLE 37PROTOTYPES: ENABLE
36 38
117 119
118 case SVt_PVCV: 120 case SVt_PVCV:
119 { 121 {
120 int depth = CvDEPTH (sv); 122 int depth = CvDEPTH (sv);
121 123
124 /* Anonymous subs have a padlist but zero depth */
125 if (!depth && CvPADLIST (sv))
126 depth = 1;
127
122 if (depth) 128 if (depth)
123 { 129 {
124 AV *padlist = CvPADLIST (sv); 130 AV *padlist = CvPADLIST (sv);
125 131
126 while (depth) 132 while (depth)
127 { 133 {
128 AV *pad = (AV *)AvARRAY (padlist)[depth]; 134 AV *pad = (AV *)AvARRAY (padlist)[depth];
129 135
130 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 */
131 137
132 for (i = AvFILLp (pad); i--; ) 138 for (i = AvFILLp (pad) + 1; i--; )
133 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))
134 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 }
135 149
136 --depth; 150 --depth;
137 } 151 }
138 } 152 }
153
154 if (CvCONST (sv) && (SV*)CvXSUBANY (sv).any_ptr == targ)
155 res_pair ("the constant value of");
156
157 if (!CvWEAKOUTSIDE (sv) && (SV*)CvOUTSIDE (sv) == targ)
158 res_pair ("the containing scope for");
139 } 159 }
140 160
141 break; 161 break;
142 162
143 case SVt_PVGV: 163 case SVt_PVGV:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines