summaryrefslogtreecommitdiff
path: root/inline.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-11-03 22:18:11 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-11-13 04:49:43 -0800
commit03414f05f41ecc10f644b53e455358ae8125d158 (patch)
tree4e43886a0a737a67e023c64195858cd14a62a83e /inline.h
parent7a2b740ab541f1d6fadd7282391ae3fda8c1c3af (diff)
downloadperl-03414f05f41ecc10f644b53e455358ae8125d158.tar.gz
Account for string eval when const-izing sub(){$x}
If we have a string eval in the same scope as the variable, it is potentially in value context.
Diffstat (limited to 'inline.h')
-rw-r--r--inline.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/inline.h b/inline.h
index 109247426f..cde2c540e2 100644
--- a/inline.h
+++ b/inline.h
@@ -90,6 +90,41 @@ S_MgBYTEPOS(pTHX_ MAGIC *mg, SV *sv, const char *s, STRLEN len)
}
#endif
+/* ------------------------------- pad.h ------------------------------ */
+
+#if defined(PERL_IN_PAD_C) || defined(PERL_IN_OP_C)
+PERL_STATIC_INLINE bool
+PadnameIN_SCOPE(const PADNAME * const pn, const U32 seq)
+{
+ /* is seq within the range _LOW to _HIGH ?
+ * This is complicated by the fact that PL_cop_seqmax
+ * may have wrapped around at some point */
+ if (COP_SEQ_RANGE_LOW(pn) == PERL_PADSEQ_INTRO)
+ return FALSE; /* not yet introduced */
+
+ if (COP_SEQ_RANGE_HIGH(pn) == PERL_PADSEQ_INTRO) {
+ /* in compiling scope */
+ if (
+ (seq > COP_SEQ_RANGE_LOW(pn))
+ ? (seq - COP_SEQ_RANGE_LOW(pn) < (U32_MAX >> 1))
+ : (COP_SEQ_RANGE_LOW(pn) - seq > (U32_MAX >> 1))
+ )
+ return TRUE;
+ }
+ else if (
+ (COP_SEQ_RANGE_LOW(pn) > COP_SEQ_RANGE_HIGH(pn))
+ ?
+ ( seq > COP_SEQ_RANGE_LOW(pn)
+ || seq <= COP_SEQ_RANGE_HIGH(pn))
+
+ : ( seq > COP_SEQ_RANGE_LOW(pn)
+ && seq <= COP_SEQ_RANGE_HIGH(pn))
+ )
+ return TRUE;
+ return FALSE;
+}
+#endif
+
/* ----------------------------- regexp.h ----------------------------- */
PERL_STATIC_INLINE struct regexp *