summaryrefslogtreecommitdiff
path: root/cop.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-05-20 11:29:26 +0000
committerNicholas Clark <nick@ccl4.org>2006-05-20 11:29:26 +0000
commit7b0bddfae402018e486a2f1fa0daf4581b85b65b (patch)
tree15b7cbc8a733cb29f8a8e9286cdb4a6950316953 /cop.h
parent8ff9a42beba9f4156f50b64fd80480645efd8c5a (diff)
downloadperl-7b0bddfae402018e486a2f1fa0daf4581b85b65b.tar.gz
Abolish cop_arybase. Signal a non zero $[ with a hint flag, and store
the value in the hints structure used for %^H. p4raw-id: //depot/perl@28250
Diffstat (limited to 'cop.h')
-rw-r--r--cop.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/cop.h b/cop.h
index ed6151e24e..749b128870 100644
--- a/cop.h
+++ b/cop.h
@@ -144,7 +144,6 @@ struct cop {
GV * cop_filegv; /* file the following line # is from */
#endif
U32 cop_seq; /* parse sequence number */
- I32 cop_arybase; /* array base this line was compiled with */
line_t cop_line; /* line # of this command */
/* Beware. mg.c and warnings.pl assume the type of this is STRLEN *: */
STRLEN * cop_warnings; /* lexical warnings bitmask */
@@ -230,10 +229,26 @@ struct cop {
# define OutCopFILE(c) CopFILE(c)
#endif
-/* CopARYBASE is likely to be removed soon. */
-#define CopARYBASE(c) ((c)->cop_arybase)
-#define CopARYBASE_get(c) ((c)->cop_arybase + 0)
-#define CopARYBASE_set(c, b) STMT_START { (c)->cop_arybase = (b); } STMT_END
+/* If $[ is non-zero, it's stored in cop_hints under the key "$[", and
+ HINT_ARYBASE is set to indicate this.
+ Setting it is ineficient due to the need to create 2 mortal SVs, but as
+ using $[ is highly discouraged, no sane Perl code will be using it. */
+#define CopARYBASE_get(c) \
+ ((CopHINTS_get(c) & HINT_ARYBASE) \
+ ? SvIV(Perl_refcounted_he_fetch(aTHX_ (c)->cop_hints, 0, "$[", 2, 0, \
+ 0)) \
+ : 0)
+#define CopARYBASE_set(c, b) STMT_START { \
+ if (b || ((c)->op_private & HINT_ARYBASE)) { \
+ (c)->op_private |= HINT_ARYBASE; \
+ if ((c) == &PL_compiling) \
+ PL_hints |= HINT_LOCALIZE_HH | HINT_ARYBASE; \
+ (c)->cop_hints \
+ = Perl_refcounted_he_new(aTHX_ (c)->cop_hints, \
+ sv_2mortal(newSVpvs("$[")), \
+ sv_2mortal(newSViv(b))); \
+ } \
+ } STMT_END
/* FIXME NATIVE_HINTS if this is changed from op_private (see perl.h) */
#define CopHINTS_get(c) ((c)->op_private + 0)