summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-12-20 20:13:12 +0000
committerNicholas Clark <nick@ccl4.org>2005-12-20 20:13:12 +0000
commit62d55b227f6b1e95d65e7faf12ed22fd467e4c0e (patch)
tree878ebaec9c22b6cea9c0ddb9e303b2ea782dc6f4 /gv.c
parentb204bbd55f0b19ee3a808931bc9154c7a5183948 (diff)
downloadperl-62d55b227f6b1e95d65e7faf12ed22fd467e4c0e.tar.gz
Take care in toke.c not to convert constant subroutine reference
proxies into full blown PVGVs with PVCVs, and recognise them and inline their values. Adds a new function gv_const_sv(gv) to return the value of the constant subroutine from a GV, and adds a cv parameter to S_intuit_method. p4raw-id: //depot/perl@26427
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gv.c b/gv.c
index 9e4dcad977..418e08c7d2 100644
--- a/gv.c
+++ b/gv.c
@@ -122,6 +122,25 @@ Perl_gv_fetchfile(pTHX_ const char *name)
return gv;
}
+/*
+=for apidoc gv_const_sv
+
+If C<gv> is a typeglob whose subroutine entry is a constant sub eligible for
+inlining, or C<gv> is a placeholder reference that would be promoted to such
+a typeglob, then returns the value returned by the sub. Otherwise, returns
+NULL.
+
+=cut
+*/
+
+SV *
+Perl_gv_const_sv(pTHX_ GV *gv)
+{
+ if (SvTYPE(gv) == SVt_PVGV)
+ return cv_const_sv(GvCVu(gv));
+ return SvROK(gv) ? SvRV(gv) : NULL;
+}
+
void
Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi)
{