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.9 by root, Fri Jul 11 15:29:48 2008 UTC vs.
Revision 1.12 by root, Sat Jul 19 01:17:12 2008 UTC

24 av_push (av, sv_rvweaken (newRV_inc (sv))); \ 24 av_push (av, sv_rvweaken (newRV_inc (sv))); \
25 if (rmagical) SvRMAGICAL_off (sv); \ 25 if (rmagical) SvRMAGICAL_off (sv); \
26 av_push (about, newRV_noinc ((SV *)av)); \ 26 av_push (about, newRV_noinc ((SV *)av)); \
27 } while (0) 27 } while (0)
28 28
29#define res_gv(sigil) \ 29#define res_text(text) \
30 do { \ 30 do { \
31 AV *av = newAV (); \ 31 AV *av = newAV (); \
32 av_push (av, newSVpv (form ("in the global %c%s::%.*s", sigil, \ 32 av_push (av, newSVpv (text, 0)); \
33 HvNAME (GvSTASH (sv)), \
34 GvNAMELEN (sv), GvNAME (sv) ? GvNAME (sv) : "<anonymous>"), \
35 0)); \
36 av_push (about, newRV_noinc ((SV *)av)); \ 33 av_push (about, newRV_noinc ((SV *)av)); \
37 } while (0) 34 } while (0)
38 35
36#define res_gv(sigil) \
37 res_text (form ("in the global %c%s::%.*s", sigil, \
38 HvNAME (GvSTASH (sv)), \
39 GvNAMELEN (sv), \
40 GvNAME (sv) ? GvNAME (sv) : "<anonymous>"))
41
39MODULE = Devel::FindRef PACKAGE = Devel::FindRef 42MODULE = Devel::FindRef PACKAGE = Devel::FindRef
40 43
41PROTOTYPES: ENABLE 44PROTOTYPES: ENABLE
42 45
43SV * 46SV *
44ptr2ref (IV ptr) 47ptr2ref (UV ptr)
45 CODE: 48 CODE:
46 RETVAL = newRV_inc (INT2PTR (SV *, ptr)); 49 RETVAL = newRV_inc (INT2PTR (SV *, ptr));
50 OUTPUT:
51 RETVAL
52
53UV
54ref2ptr (SV *rv)
55 CODE:
56 RETVAL = PTR2UV (SvRV (rv));
47 OUTPUT: 57 OUTPUT:
48 RETVAL 58 RETVAL
49 59
50void 60void
51find_ (SV *target) 61find_ (SV *target)
79 if ((rmagical = SvRMAGICAL (sv))) 89 if ((rmagical = SvRMAGICAL (sv)))
80 SvRMAGICAL_off (sv); 90 SvRMAGICAL_off (sv);
81 91
82 if (SvTYPE (sv) >= SVt_PVMG) 92 if (SvTYPE (sv) >= SVt_PVMG)
83 { 93 {
84
85 if (SvTYPE (sv) != SVt_PVMG || SvPAD_OUR (sv)) 94 if (SvTYPE (sv) == SVt_PVMG && SvPAD_OUR (sv))
95 {
96 /* I have no clue what this is */
97 /* maybe some placeholder for our variables for eval? */
98 /* it doesn't seem to reference anything, so we should be able to ignore it */
99 }
100 else
86 { 101 {
87 MAGIC *mg = SvMAGIC (sv); 102 MAGIC *mg = SvMAGIC (sv);
88 103
89 while (mg) 104 while (mg)
90 { 105 {
130 case SVt_PVCV: 145 case SVt_PVCV:
131 { 146 {
132 int depth = CvDEPTH (sv); 147 int depth = CvDEPTH (sv);
133 148
134 /* Anonymous subs have a padlist but zero depth */ 149 /* Anonymous subs have a padlist but zero depth */
135 if (!depth && CvPADLIST (sv)) 150 if (CvANON (sv) && !depth && CvPADLIST (sv))
136 depth = 1; 151 depth = 1;
137 152
138 if (depth) 153 if (depth)
139 { 154 {
140 AV *padlist = CvPADLIST (sv); 155 AV *padlist = CvPADLIST (sv);
164 if (CvCONST (sv) && (SV*)CvXSUBANY (sv).any_ptr == targ) 179 if (CvCONST (sv) && (SV*)CvXSUBANY (sv).any_ptr == targ)
165 res_pair ("the constant value of"); 180 res_pair ("the constant value of");
166 181
167 if (!CvWEAKOUTSIDE (sv) && (SV*)CvOUTSIDE (sv) == targ) 182 if (!CvWEAKOUTSIDE (sv) && (SV*)CvOUTSIDE (sv) == targ)
168 res_pair ("the containing scope for"); 183 res_pair ("the containing scope for");
184
185 if (sv == targ && CvANON (sv))
186 if (CvSTART (sv)
187 && CvSTART (sv)->op_type == OP_NEXTSTATE
188 && CopLINE ((COP *)CvSTART (sv)))
189 res_text (form ("the closure created at %s:%d",
190 CopFILE ((COP *)CvSTART (sv)) ? CopFILE ((COP *)CvSTART (sv)) : "<unknown>",
191 CopLINE ((COP *)CvSTART (sv))));
192 else
193 res_text (form ("the closure created somewhere in file %s (PLEASE REPORT!)",
194 CvFILE (sv) ? CvFILE (sv) : "<unknown>"));
169 } 195 }
170 196
171 break; 197 break;
172 198
173 case SVt_PVGV: 199 case SVt_PVGV:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines