Commit | Line | Data |
---|---|---|
79072805 LW |
1 | /* $RCSfile: arg.h,v $$Revision: 4.1 $$Date: 92/08/07 17:18:16 $ |
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: arg.h,v $ | |
9 | */ | |
10 | ||
11 | /* | |
12 | * The fields of BASEOP are: | |
13 | * op_next Pointer to next ppcode to execute after this one. | |
14 | * (Top level pre-grafted op points to first op, | |
15 | * but this is replaced when op is grafted in, when | |
16 | * this op will point to the real next op, and the new | |
17 | * parent takes over role of remembering starting op.) | |
18 | * op_ppaddr Pointer to current ppcode's function. | |
19 | * op_type The type of the operation. | |
20 | * op_flags Flags common to all operations. See OPf_* below. | |
21 | * op_private Flags peculiar to a particular operation (BUT, | |
22 | * by default, set to the number of children until | |
23 | * the operation is privatized by a check routine, | |
24 | * which may or may not check number of children). | |
25 | */ | |
26 | ||
27 | typedef U16 PADOFFSET; | |
28 | ||
29 | #ifdef DEBUGGING | |
30 | #define OPCODE opcode | |
31 | #else | |
32 | #define OPCODE U16 | |
33 | #endif | |
34 | ||
35 | #define BASEOP \ | |
36 | OP* op_next; \ | |
37 | OP* op_sibling; \ | |
38 | OP* (*op_ppaddr)(); \ | |
39 | PADOFFSET op_targ; \ | |
40 | OPCODE op_type; \ | |
41 | U16 op_seq; \ | |
42 | char op_flags; \ | |
43 | char op_private; | |
44 | ||
85e6fe83 | 45 | #define GIMME (op->op_flags & OPf_KNOW ? op->op_flags & OPf_LIST : cxstack[cxstack_ix].blk_gimme) |
79072805 LW |
46 | |
47 | /* Public flags */ | |
48 | #define OPf_LIST 1 /* Do operator in list context. */ | |
49 | #define OPf_KNOW 2 /* Context is known. */ | |
50 | #define OPf_KIDS 4 /* There is a firstborn child. */ | |
51 | #define OPf_PARENS 8 /* This operator was parenthesized. */ | |
463ee0b2 | 52 | /* (Or block needs explicit scope entry.) */ |
79072805 LW |
53 | #define OPf_STACKED 16 /* Some arg is arriving on the stack. */ |
54 | #define OPf_LVAL 32 /* Certified reference (lvalue). */ | |
93a17b20 | 55 | #define OPf_INTRO 64 /* Lvalue must be localized */ |
79072805 LW |
56 | #define OPf_SPECIAL 128 /* Do something weird for this op: */ |
57 | /* On local LVAL, don't init local value. */ | |
58 | /* On OP_SORT, subroutine is inlined. */ | |
59 | /* On OP_NOT, inversion was implicit. */ | |
60 | /* On file tests, we fstat filehandle */ | |
61 | /* On truncate, we truncate filehandle */ | |
62 | /* On control verbs, we saw no label */ | |
63 | /* On flipflop, we saw ... instead of .. */ | |
64 | /* On UNOPs, saw bare parens, e.g. eof(). */ | |
65 | /* On OP_ENTERSUBR || OP_NULL, saw a "do". */ | |
66 | ||
67 | /* Private for OP_ASSIGN */ | |
68 | #define OPpASSIGN_COMMON 1 /* Left & right have syms in common. */ | |
69 | ||
70 | /* Private for OP_TRANS */ | |
71 | #define OPpTRANS_SQUASH 1 | |
72 | #define OPpTRANS_DELETE 2 | |
73 | #define OPpTRANS_COMPLEMENT 4 | |
74 | ||
75 | /* Private for OP_REPEAT */ | |
76 | #define OPpREPEAT_DOLIST 1 /* List replication. */ | |
77 | ||
85e6fe83 LW |
78 | /* Private for OP_ENTERSUBR, OP_RV2?V, OP_?ELEM */ |
79 | /* (lower bits carry hints) */ | |
80 | #define OPpDEREF_DB 32 /* Debug subroutine. */ | |
81 | #define OPpDEREF_AV 64 /* Want ref to AV. */ | |
82 | #define OPpDEREF_HV 128 /* Want ref to HV. */ | |
79072805 LW |
83 | |
84 | /* Private for OP_CONST */ | |
85 | #define OPpCONST_BARE 1 /* Was a bare word (filehandle?). */ | |
86 | ||
87 | /* Private for OP_FLIP/FLOP */ | |
88 | #define OPpFLIP_LINENUM 1 /* Range arg potentially a line num. */ | |
89 | ||
ed6116ce LW |
90 | /* Private for OP_LIST */ |
91 | #define OPpLIST_GUESSED 1 /* Guessed that pushmark was needed. */ | |
92 | ||
79072805 LW |
93 | struct op { |
94 | BASEOP | |
95 | }; | |
96 | ||
97 | struct unop { | |
98 | BASEOP | |
99 | OP * op_first; | |
100 | }; | |
101 | ||
102 | struct binop { | |
103 | BASEOP | |
104 | OP * op_first; | |
105 | OP * op_last; | |
106 | }; | |
107 | ||
108 | struct logop { | |
109 | BASEOP | |
110 | OP * op_first; | |
111 | OP * op_other; | |
112 | }; | |
113 | ||
114 | struct condop { | |
115 | BASEOP | |
116 | OP * op_first; | |
117 | OP * op_true; | |
118 | OP * op_false; | |
119 | }; | |
120 | ||
121 | struct listop { | |
122 | BASEOP | |
123 | OP * op_first; | |
124 | OP * op_last; | |
125 | U32 op_children; | |
126 | }; | |
127 | ||
128 | struct pmop { | |
129 | BASEOP | |
130 | OP * op_first; | |
131 | OP * op_last; | |
132 | U32 op_children; | |
133 | OP * op_pmreplroot; | |
134 | OP * op_pmreplstart; | |
135 | PMOP * op_pmnext; /* list of all scanpats */ | |
136 | REGEXP * op_pmregexp; /* compiled expression */ | |
137 | SV * op_pmshort; /* for a fast bypass of execute() */ | |
138 | short op_pmflags; | |
139 | char op_pmslen; | |
140 | }; | |
141 | #define PMf_USED 1 /* pm has been used once already */ | |
142 | #define PMf_ONCE 2 /* use pattern only once per reset */ | |
143 | #define PMf_SCANFIRST 4 /* initial constant not anchored */ | |
144 | #define PMf_ALL 8 /* initial constant is whole pat */ | |
145 | #define PMf_SKIPWHITE 16 /* skip leading whitespace for split */ | |
146 | #define PMf_FOLD 32 /* case insensitivity */ | |
147 | #define PMf_CONST 64 /* subst replacement is constant */ | |
148 | #define PMf_KEEP 128 /* keep 1st runtime pattern forever */ | |
149 | #define PMf_GLOBAL 256 /* pattern had a g modifier */ | |
150 | #define PMf_RUNTIME 512 /* pattern coming in on the stack */ | |
151 | #define PMf_EVAL 1024 /* evaluating replacement as expr */ | |
85e6fe83 | 152 | #define PMf_WHITE 2048 /* pattern is \s+ */ |
79072805 LW |
153 | |
154 | struct svop { | |
155 | BASEOP | |
156 | SV * op_sv; | |
157 | }; | |
158 | ||
159 | struct gvop { | |
160 | BASEOP | |
161 | GV * op_gv; | |
162 | }; | |
163 | ||
164 | struct pvop { | |
165 | BASEOP | |
166 | char * op_pv; | |
167 | }; | |
168 | ||
169 | struct cvop { | |
170 | BASEOP | |
171 | CV * op_cv; | |
172 | OP * op_cont; | |
173 | }; | |
174 | ||
175 | struct loop { | |
176 | BASEOP | |
177 | OP * op_first; | |
178 | OP * op_last; | |
179 | U32 op_children; | |
180 | OP * op_redoop; | |
181 | OP * op_nextop; | |
182 | OP * op_lastop; | |
183 | }; | |
184 | ||
185 | #define cUNOP ((UNOP*)op) | |
186 | #define cBINOP ((BINOP*)op) | |
187 | #define cLISTOP ((LISTOP*)op) | |
188 | #define cLOGOP ((LOGOP*)op) | |
189 | #define cCONDOP ((CONDOP*)op) | |
190 | #define cPMOP ((PMOP*)op) | |
191 | #define cSVOP ((SVOP*)op) | |
192 | #define cGVOP ((GVOP*)op) | |
193 | #define cPVOP ((PVOP*)op) | |
194 | #define cCVOP ((CVOP*)op) | |
195 | #define cCOP ((COP*)op) | |
196 | #define cLOOP ((LOOP*)op) | |
197 | ||
198 | #define kUNOP ((UNOP*)kid) | |
199 | #define kBINOP ((BINOP*)kid) | |
200 | #define kLISTOP ((LISTOP*)kid) | |
201 | #define kLOGOP ((LOGOP*)kid) | |
202 | #define kCONDOP ((CONDOP*)kid) | |
203 | #define kPMOP ((PMOP*)kid) | |
204 | #define kSVOP ((SVOP*)kid) | |
205 | #define kGVOP ((GVOP*)kid) | |
206 | #define kPVOP ((PVOP*)kid) | |
207 | #define kCVOP ((CVOP*)kid) | |
208 | #define kCOP ((COP*)kid) | |
209 | #define kLOOP ((LOOP*)kid) | |
210 | ||
211 | #define Nullop Null(OP*) | |
212 |