diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-08-18 15:55:59 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-24 23:25:35 -0700 |
commit | c086f97a1425c2aa61dd3625b890e1236b1d4bc4 (patch) | |
tree | fd4908bcc5e2628906abfff85941eb904a64d244 /pad.c | |
parent | f988db8ca20c402ad7c8038ee1f7a544b9e687e2 (diff) | |
download | perl-c086f97a1425c2aa61dd3625b890e1236b1d4bc4.tar.gz |
Add find_rundefsv2 function
Subs in the CORE package with a (_) prototype will use this.
This accepts a CV and a sequence number, so that one can
use it to find the $_ in the caller’s scope. It only uses
the topmost call of a subroutine that is being called recur-
sively, so it’s not really a general-purpose function. But
it suffices for &CORE::abs and friends.
Diffstat (limited to 'pad.c')
-rw-r--r-- | pad.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -994,6 +994,24 @@ Perl_find_rundefsv(pTHX) return PAD_SVl(po); } +SV * +Perl_find_rundefsv2(pTHX_ CV *cv, U32 seq) +{ + SV *namesv; + int flags; + PADOFFSET po; + + PERL_ARGS_ASSERT_FIND_RUNDEFSV2; + + po = pad_findlex("$_", 2, 0, cv, seq, 1, + NULL, &namesv, &flags); + + if (po == NOT_IN_PAD || SvPAD_OUR(namesv)) + return DEFSV; + + return AvARRAY((PAD*) (AvARRAY(CvPADLIST(cv))[CvDEPTH(cv)]))[po]; +} + /* =for apidoc m|PADOFFSET|pad_findlex|const char *namepv|STRLEN namelen|U32 flags|const CV* cv|U32 seq|int warn|SV** out_capture|SV** out_name_sv|int *out_flags |