-/* $RCSfile: gv.h,v $$Revision: 4.1 $$Date: 92/08/07 18:26:42 $
+/* gv.h
*
- * Copyright (c) 1991, Larry Wall
+ * Copyright (c) 1991-1999, Larry Wall
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
- * $Log: gv.h,v $
- * Revision 4.1 92/08/07 18:26:42 lwall
- *
- * Revision 4.0.1.3 92/06/08 15:33:44 lwall
- * patch20: fixed confusion between a *var's real name and its effective name
- * patch20: ($<,$>) = ... didn't work on some architectures
- *
- * Revision 4.0.1.2 91/11/05 18:36:15 lwall
- * patch11: length($x) was sometimes wrong for numeric $x
- *
- * Revision 4.0.1.1 91/06/07 11:56:35 lwall
- * patch4: new copyright notice
- * patch4: length($`), length($&), length($') now optimized to avoid string copy
- *
- * Revision 4.0 91/03/20 01:39:49 lwall
- * 4.0 baseline.
- *
*/
struct gp {
struct io * gp_io; /* filehandle value */
CV * gp_form; /* format value */
AV * gp_av; /* array value */
- HV * gp_hv; /* associative array value */
+ HV * gp_hv; /* hash value */
GV * gp_egv; /* effective gv, if *glob */
CV * gp_cv; /* subroutine value */
U32 gp_cvgen; /* generational validity of cached gv_cv */
- I32 gp_lastexpr; /* used by nothing_in_common() */
+ U32 gp_flags; /* XXX unused */
line_t gp_line; /* line first declared at (for -w) */
- char gp_flags;
+ char * gp_file; /* file first declared in (for -w) */
};
#if defined(CRIPPLED_CC) && (defined(iAPX286) || defined(M_I286) || defined(I80286))
#define GvXPVGV(gv) ((XPVGV*)SvANY(gv))
-#define GvMAGIC(gv) (GvGP(gv)->gp_magic)
+#define GvGP(gv) (GvXPVGV(gv)->xgv_gp)
+#define GvNAME(gv) (GvXPVGV(gv)->xgv_name)
+#define GvNAMELEN(gv) (GvXPVGV(gv)->xgv_namelen)
+#define GvSTASH(gv) (GvXPVGV(gv)->xgv_stash)
+#define GvFLAGS(gv) (GvXPVGV(gv)->xgv_flags)
+
#define GvSV(gv) (GvGP(gv)->gp_sv)
#define GvREFCNT(gv) (GvGP(gv)->gp_refcnt)
-#define GvIO(gv) (GvGP(gv)->gp_io)
-#define GvIOn(gv) (GvIO(gv) ? \
- GvIO(gv) : \
- (GvIO(gv) = newIO()))
+#define GvIO(gv) ((gv) && SvTYPE((SV*)gv) == SVt_PVGV ? GvIOp(gv) : 0)
+#define GvIOp(gv) (GvGP(gv)->gp_io)
+#define GvIOn(gv) (GvIO(gv) ? GvIOp(gv) : GvIOp(gv_IOadd(gv)))
#define GvFORM(gv) (GvGP(gv)->gp_form)
#define GvAV(gv) (GvGP(gv)->gp_av)
+/* This macro is deprecated. Do not use! */
+#define GvREFCNT_inc(gv) ((GV*)SvREFCNT_inc(gv)) /* DO NOT USE */
+
#ifdef MICROPORT /* Microport 2.4 hack */
AV *GvAVn();
#else
#define GvCV(gv) (GvGP(gv)->gp_cv)
#define GvCVGEN(gv) (GvGP(gv)->gp_cvgen)
+#define GvCVu(gv) (GvGP(gv)->gp_cvgen ? Nullcv : GvGP(gv)->gp_cv)
-#define GvLASTEXPR(gv) (GvGP(gv)->gp_lastexpr)
+#define GvGPFLAGS(gv) (GvGP(gv)->gp_flags)
#define GvLINE(gv) (GvGP(gv)->gp_line)
-
-#define GvFLAGS(gv) (GvGP(gv)->gp_flags)
+#define GvFILE(gv) (GvGP(gv)->gp_file)
+#define GvFILEGV(gv) (gv_fetchfile(GvGP(gv)->gp_file))
#define GvEGV(gv) (GvGP(gv)->gp_egv)
-
-#define GvGP(gv) (GvXPVGV(gv)->xgv_gp)
-#define GvNAME(gv) (GvXPVGV(gv)->xgv_name)
-#define GvNAMELEN(gv) (GvXPVGV(gv)->xgv_namelen)
-#define GvENAME(gv) GvNAME(GvEGV(gv))
-
-#define GvSTASH(gv) (GvXPVGV(gv)->xgv_stash)
-#define GvESTASH(gv) GvSTASH(GvEGV(gv))
-
-struct io {
- FILE * ifp; /* ifp and ofp are normally the same */
- FILE * ofp; /* but sockets need separate streams */
-#ifdef HAS_READDIR
- DIR * dirp; /* for opendir, readdir, etc */
-#endif
- long lines; /* $. */
- long page; /* $% */
- long page_len; /* $= */
- long lines_left; /* $- */
- char * top_name; /* $^ */
- GV * top_gv; /* $^ */
- char * fmt_name; /* $~ */
- GV * fmt_gv; /* $~ */
- SV * object;
- short subprocess; /* -| or |- */
- char type;
- char flags;
-};
-
-#define IOf_ARGV 1 /* this fp iterates over ARGV */
-#define IOf_START 2 /* check for null ARGV and substitute '-' */
-#define IOf_FLUSH 4 /* this fp wants a flush after write op */
+#define GvENAME(gv) GvNAME(GvEGV(gv) ? GvEGV(gv) : gv)
+#define GvESTASH(gv) GvSTASH(GvEGV(gv) ? GvEGV(gv) : gv)
+
+#define GVf_INTRO 0x01
+#define GVf_MULTI 0x02
+#define GVf_ASSUMECV 0x04
+#define GVf_IMPORTED 0xF0
+#define GVf_IMPORTED_SV 0x10
+#define GVf_IMPORTED_AV 0x20
+#define GVf_IMPORTED_HV 0x40
+#define GVf_IMPORTED_CV 0x80
+
+#define GvINTRO(gv) (GvFLAGS(gv) & GVf_INTRO)
+#define GvINTRO_on(gv) (GvFLAGS(gv) |= GVf_INTRO)
+#define GvINTRO_off(gv) (GvFLAGS(gv) &= ~GVf_INTRO)
+
+#define GvMULTI(gv) (GvFLAGS(gv) & GVf_MULTI)
+#define GvMULTI_on(gv) (GvFLAGS(gv) |= GVf_MULTI)
+#define GvMULTI_off(gv) (GvFLAGS(gv) &= ~GVf_MULTI)
+
+#define GvASSUMECV(gv) (GvFLAGS(gv) & GVf_ASSUMECV)
+#define GvASSUMECV_on(gv) (GvFLAGS(gv) |= GVf_ASSUMECV)
+#define GvASSUMECV_off(gv) (GvFLAGS(gv) &= ~GVf_ASSUMECV)
+
+#define GvIMPORTED(gv) (GvFLAGS(gv) & GVf_IMPORTED)
+#define GvIMPORTED_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED)
+#define GvIMPORTED_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED)
+
+#define GvIMPORTED_SV(gv) (GvFLAGS(gv) & GVf_IMPORTED_SV)
+#define GvIMPORTED_SV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_SV)
+#define GvIMPORTED_SV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_SV)
+
+#define GvIMPORTED_AV(gv) (GvFLAGS(gv) & GVf_IMPORTED_AV)
+#define GvIMPORTED_AV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_AV)
+#define GvIMPORTED_AV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_AV)
+
+#define GvIMPORTED_HV(gv) (GvFLAGS(gv) & GVf_IMPORTED_HV)
+#define GvIMPORTED_HV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_HV)
+#define GvIMPORTED_HV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_HV)
+
+#define GvIMPORTED_CV(gv) (GvFLAGS(gv) & GVf_IMPORTED_CV)
+#define GvIMPORTED_CV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_CV)
+#define GvIMPORTED_CV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_CV)
#define Nullgv Null(GV*)
#define DM_EGID 0x020
#define DM_DELAY 0x100
+/*
+ * symbol creation flags, for use in gv_fetchpv() and get_*v()
+ */
+#define GV_ADD 0x01 /* add, if symbol not already there */
+#define GV_ADDMULTI 0x02 /* add, pretending it has been added already */
+#define GV_ADDWARN 0x04 /* add, but warn if symbol wasn't already there */
+#define GV_ADDINEVAL 0x08 /* add, as though we're doing so within an eval */
+#define GV_NOINIT 0x10 /* add, but don't init symbol, if type != PVGV */
+#define GV_ADDOUR 0x20 /* add "our" variable */