summaryrefslogtreecommitdiff
path: root/pad.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-08-18 15:55:59 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-08-24 23:25:35 -0700
commitc086f97a1425c2aa61dd3625b890e1236b1d4bc4 (patch)
treefd4908bcc5e2628906abfff85941eb904a64d244 /pad.c
parentf988db8ca20c402ad7c8038ee1f7a544b9e687e2 (diff)
downloadperl-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.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/pad.c b/pad.c
index 4036ddf085..e7522eb577 100644
--- a/pad.c
+++ b/pad.c
@@ -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