perl 4.0 patch 24: patch #20, continued
[p5sagit/p5-mst-13.2.git] / stab.h
1 /* $RCSfile: stab.h,v $$Revision: 4.0.1.2 $$Date: 91/11/05 18:36:15 $
2  *
3  *    Copyright (c) 1991, Larry Wall
4  *
5  *    You may distribute under the terms of either the GNU General Public
6  *    License or the Artistic License, as specified in the README file.
7  *
8  * $Log:        stab.h,v $
9  * Revision 4.0.1.2  91/11/05  18:36:15  lwall
10  * patch11: length($x) was sometimes wrong for numeric $x
11  * 
12  * Revision 4.0.1.1  91/06/07  11:56:35  lwall
13  * patch4: new copyright notice
14  * patch4: length($`), length($&), length($') now optimized to avoid string copy
15  * 
16  * Revision 4.0  91/03/20  01:39:49  lwall
17  * 4.0 baseline.
18  * 
19  */
20
21 struct stabptrs {
22     char        stbp_magic[4];
23     STR         *stbp_val;      /* scalar value */
24     struct stio *stbp_io;       /* filehandle value */
25     FCMD        *stbp_form;     /* format value */
26     ARRAY       *stbp_array;    /* array value */
27     HASH        *stbp_hash;     /* associative array value */
28     HASH        *stbp_stash;    /* symbol table for this stab */
29     SUBR        *stbp_sub;      /* subroutine value */
30     int         stbp_lastexpr;  /* used by nothing_in_common() */
31     line_t      stbp_line;      /* line first declared at (for -w) */
32     char        stbp_flags;
33 };
34
35 #if defined(CRIPPLED_CC) && (defined(iAPX286) || defined(M_I286) || defined(I80286))
36 #define MICROPORT
37 #endif
38
39 #define stab_magic(stab)        (((STBP*)(stab->str_ptr))->stbp_magic)
40 #define stab_val(stab)          (((STBP*)(stab->str_ptr))->stbp_val)
41 #define stab_io(stab)           (((STBP*)(stab->str_ptr))->stbp_io)
42 #define stab_form(stab)         (((STBP*)(stab->str_ptr))->stbp_form)
43 #define stab_xarray(stab)       (((STBP*)(stab->str_ptr))->stbp_array)
44 #ifdef  MICROPORT       /* Microport 2.4 hack */
45 ARRAY *stab_array();
46 #else
47 #define stab_array(stab)        (((STBP*)(stab->str_ptr))->stbp_array ? \
48                                  ((STBP*)(stab->str_ptr))->stbp_array : \
49                                  ((STBP*)(aadd(stab)->str_ptr))->stbp_array)
50 #endif
51 #define stab_xhash(stab)        (((STBP*)(stab->str_ptr))->stbp_hash)
52 #ifdef  MICROPORT       /* Microport 2.4 hack */
53 HASH *stab_hash();
54 #else
55 #define stab_hash(stab)         (((STBP*)(stab->str_ptr))->stbp_hash ? \
56                                  ((STBP*)(stab->str_ptr))->stbp_hash : \
57                                  ((STBP*)(hadd(stab)->str_ptr))->stbp_hash)
58 #endif                  /* Microport 2.4 hack */
59 #define stab_stash(stab)        (((STBP*)(stab->str_ptr))->stbp_stash)
60 #define stab_sub(stab)          (((STBP*)(stab->str_ptr))->stbp_sub)
61 #define stab_lastexpr(stab)     (((STBP*)(stab->str_ptr))->stbp_lastexpr)
62 #define stab_line(stab)         (((STBP*)(stab->str_ptr))->stbp_line)
63 #define stab_flags(stab)        (((STBP*)(stab->str_ptr))->stbp_flags)
64 #define stab_name(stab)         (stab->str_magic->str_ptr)
65
66 #define SF_VMAGIC 1             /* call routine to dereference STR val */
67 #define SF_MULTI 2              /* seen more than once */
68
69 struct stio {
70     FILE        *ifp;           /* ifp and ofp are normally the same */
71     FILE        *ofp;           /* but sockets need separate streams */
72 #ifdef HAS_READDIR
73     DIR         *dirp;          /* for opendir, readdir, etc */
74 #endif
75     long        lines;          /* $. */
76     long        page;           /* $% */
77     long        page_len;       /* $= */
78     long        lines_left;     /* $- */
79     char        *top_name;      /* $^ */
80     STAB        *top_stab;      /* $^ */
81     char        *fmt_name;      /* $~ */
82     STAB        *fmt_stab;      /* $~ */
83     short       subprocess;     /* -| or |- */
84     char        type;
85     char        flags;
86 };
87
88 #define IOF_ARGV 1      /* this fp iterates over ARGV */
89 #define IOF_START 2     /* check for null ARGV and substitute '-' */
90 #define IOF_FLUSH 4     /* this fp wants a flush after write op */
91
92 struct sub {
93     CMD         *cmd;
94     int         (*usersub)();
95     int         userindex;
96     STAB        *filestab;
97     long        depth;  /* >= 2 indicates recursive call */
98     ARRAY       *tosave;
99 };
100
101 #define Nullstab Null(STAB*)
102
103 STRLEN stab_len();
104
105 #define STAB_STR(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_str(stab_val(tmpstab)->str_magic) : stab_val(tmpstab))
106 #define STAB_LEN(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_len(stab_val(tmpstab)->str_magic) : str_len(stab_val(tmpstab)))
107 #define STAB_GET(s) (tmpstab = (s), str_get(stab_flags(tmpstab) & SF_VMAGIC ? stab_str(tmpstab->str_magic) : stab_val(tmpstab)))
108 #define STAB_GNUM(s) (tmpstab = (s), str_gnum(stab_flags(tmpstab) & SF_VMAGIC ? stab_str(tmpstab->str_magic) : stab_val(tmpstab)))
109
110 EXT STAB *tmpstab;
111
112 EXT STAB *stab_index[128];
113
114 EXT unsigned short statusvalue;
115
116 EXT int delaymagic INIT(0);
117 #define DM_DELAY 1
118 #define DM_REUID 2
119 #define DM_REGID 4
120
121 STAB *aadd();
122 STAB *hadd();
123 STAB *fstab();