LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include <bio.h> | 5 #include <bio.h> |
6 | 6 |
7 #undef OAPPEND | 7 #undef OAPPEND |
8 | 8 |
9 // avoid <ctype.h> | 9 // avoid <ctype.h> |
10 #undef isblank | 10 #undef isblank |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 { | 204 { |
205 EscUnknown, | 205 EscUnknown, |
206 EscHeap, | 206 EscHeap, |
207 EscScope, | 207 EscScope, |
208 EscNone, | 208 EscNone, |
209 EscNever, | 209 EscNever, |
210 }; | 210 }; |
211 | 211 |
212 struct Node | 212 struct Node |
213 { | 213 { |
| 214 // Tree structure. |
| 215 // Generic recursive walks should follow these fields. |
| 216 Node* left; |
| 217 Node* right; |
| 218 Node* ntest; |
| 219 Node* nincr; |
| 220 NodeList* ninit; |
| 221 NodeList* nbody; |
| 222 NodeList* nelse; |
| 223 NodeList* list; |
| 224 NodeList* rlist; |
| 225 |
214 uchar op; | 226 uchar op; |
215 uchar ullman; // sethi/ullman number | 227 uchar ullman; // sethi/ullman number |
216 uchar addable; // type of addressability - 0 is not addressable | 228 uchar addable; // type of addressability - 0 is not addressable |
217 uchar trecur; // to detect loops | 229 uchar trecur; // to detect loops |
218 uchar etype; // op for OASOP, etype for OTYPE, exclam for exp
ort | 230 uchar etype; // op for OASOP, etype for OTYPE, exclam for exp
ort |
219 uchar class; // PPARAM, PAUTO, PEXTERN, etc | 231 uchar class; // PPARAM, PAUTO, PEXTERN, etc |
220 uchar method; // OCALLMETH name | 232 uchar method; // OCALLMETH name |
221 uchar embedded; // ODCLFIELD embedded type | 233 uchar embedded; // ODCLFIELD embedded type |
222 uchar colas; // OAS resulting from := | 234 uchar colas; // OAS resulting from := |
223 uchar diag; // already printed error about this | 235 uchar diag; // already printed error about this |
224 uchar esc; // EscXXX | 236 uchar esc; // EscXXX |
225 uchar funcdepth; | 237 uchar funcdepth; |
226 uchar builtin; // built-in name, like len or close | 238 uchar builtin; // built-in name, like len or close |
227 uchar walkdef; | 239 uchar walkdef; |
228 uchar typecheck; | 240 uchar typecheck; |
229 uchar local; | 241 uchar local; |
230 uchar initorder; | 242 uchar initorder; |
231 uchar dodata; // compile literal assignment as data statement | 243 uchar dodata; // compile literal assignment as data statement |
232 uchar used; | 244 uchar used; |
233 uchar isddd; | 245 uchar isddd; |
234 uchar pun; // don't registerize variable ONAME | 246 uchar pun; // don't registerize variable ONAME |
235 uchar readonly; | 247 uchar readonly; |
236 uchar implicit; // don't show in printout | 248 uchar implicit; // don't show in printout |
237 | 249 |
238 // most nodes | 250 // most nodes |
239 Node* left; | |
240 Node* right; | |
241 Type* type; | 251 Type* type; |
242 Type* realtype; // as determined by typecheck | 252 Type* realtype; // as determined by typecheck |
243 NodeList* list; | |
244 NodeList* rlist; | |
245 Node* orig; // original form, for printing, and tracking cop
ies of ONAMEs | 253 Node* orig; // original form, for printing, and tracking cop
ies of ONAMEs |
246 | |
247 // for-body | |
248 NodeList* ninit; | |
249 Node* ntest; | |
250 Node* nincr; | |
251 NodeList* nbody; | |
252 | |
253 // if-body | |
254 NodeList* nelse; | |
255 | |
256 // cases | |
257 Node* ncase; | |
258 | 254 |
259 // func | 255 // func |
260 Node* nname; | 256 Node* nname; |
261 Node* shortname; | 257 Node* shortname; |
262 NodeList* enter; | 258 NodeList* enter; |
263 NodeList* exit; | 259 NodeList* exit; |
264 NodeList* cvars; // closure params | 260 NodeList* cvars; // closure params |
265 NodeList* dcl; // autodcl for this func/closure | 261 NodeList* dcl; // autodcl for this func/closure |
266 | 262 |
267 // OLITERAL/OREGISTER | 263 // OLITERAL/OREGISTER |
(...skipping 14 matching lines...) Expand all Loading... |
282 // ONAME closure param with PPARAMREF | 278 // ONAME closure param with PPARAMREF |
283 Node* outer; // outer PPARAMREF in nested closure | 279 Node* outer; // outer PPARAMREF in nested closure |
284 Node* closure; // ONAME/PHEAP <-> ONAME/PPARAMREF | 280 Node* closure; // ONAME/PHEAP <-> ONAME/PPARAMREF |
285 | 281 |
286 // OPACK | 282 // OPACK |
287 Pkg* pkg; | 283 Pkg* pkg; |
288 | 284 |
289 // Escape analysis. | 285 // Escape analysis. |
290 NodeList* escflowsrc; // flow(this, src) | 286 NodeList* escflowsrc; // flow(this, src) |
291 int escloopdepth; // -1: global, 0: not set, function top level:1,
increased inside function for every loop or label to mark scopes | 287 int escloopdepth; // -1: global, 0: not set, function top level:1,
increased inside function for every loop or label to mark scopes |
292 int escfloodgen; // increased for every flood to detect loops | |
293 | 288 |
294 Sym* sym; // various | 289 Sym* sym; // various |
295 int32 vargen; // unique name for OTYPE/ONAME | 290 int32 vargen; // unique name for OTYPE/ONAME |
296 int32 lineno; | 291 int32 lineno; |
297 int32 endlineno; | 292 int32 endlineno; |
298 vlong xoffset; | 293 vlong xoffset; |
299 int32 stkdelta; // offset added by stack frame compaction phase. | 294 int32 stkdelta; // offset added by stack frame compaction phase. |
300 int32 ostk; | 295 int32 ostk; |
301 int32 iota; | 296 int32 iota; |
| 297 uint32 walkgen; |
302 }; | 298 }; |
303 #define N ((Node*)0) | 299 #define N ((Node*)0) |
304 EXTERN» int32» walkgen; | 300 |
| 301 /* |
| 302 * Every node has a walkgen field. |
| 303 * If you want to do a traversal of a node graph that |
| 304 * might contain duplicates and want to avoid |
| 305 * visiting the same nodes twice, increment walkgen |
| 306 * before starting. Then before processing a node, do |
| 307 * |
| 308 *» if(n->walkgen == walkgen) |
| 309 *» » return; |
| 310 *» n->walkgen = walkgen; |
| 311 * |
| 312 * Such a walk cannot call another such walk recursively, |
| 313 * because of the use of the global walkgen. |
| 314 */ |
| 315 EXTERN» uint32» walkgen; |
305 | 316 |
306 struct NodeList | 317 struct NodeList |
307 { | 318 { |
308 Node* n; | 319 Node* n; |
309 NodeList* next; | 320 NodeList* next; |
310 NodeList* end; | 321 NodeList* end; |
311 }; | 322 }; |
312 | 323 |
313 enum | 324 enum |
314 { | 325 { |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 Type* structfirst(Iter *s, Type **nn); | 1193 Type* structfirst(Iter *s, Type **nn); |
1183 Type* structnext(Iter *s); | 1194 Type* structnext(Iter *s); |
1184 Node* syslook(char *name, int copy); | 1195 Node* syslook(char *name, int copy); |
1185 Type* tounsigned(Type *t); | 1196 Type* tounsigned(Type *t); |
1186 Node* treecopy(Node *n); | 1197 Node* treecopy(Node *n); |
1187 Type* typ(int et); | 1198 Type* typ(int et); |
1188 uint32 typehash(Type *t); | 1199 uint32 typehash(Type *t); |
1189 void ullmancalc(Node *n); | 1200 void ullmancalc(Node *n); |
1190 void umagic(Magic *m); | 1201 void umagic(Magic *m); |
1191 void warn(char *fmt, ...); | 1202 void warn(char *fmt, ...); |
| 1203 void warnl(int line, char *fmt, ...); |
1192 void yyerror(char *fmt, ...); | 1204 void yyerror(char *fmt, ...); |
1193 void yyerrorl(int line, char *fmt, ...); | 1205 void yyerrorl(int line, char *fmt, ...); |
1194 | 1206 |
1195 /* | 1207 /* |
1196 * swt.c | 1208 * swt.c |
1197 */ | 1209 */ |
1198 void typecheckswitch(Node *n); | 1210 void typecheckswitch(Node *n); |
1199 void walkswitch(Node *sw); | 1211 void walkswitch(Node *sw); |
1200 | 1212 |
1201 /* | 1213 /* |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 Node* nodarg(Type*, int); | 1301 Node* nodarg(Type*, int); |
1290 void nopout(Prog*); | 1302 void nopout(Prog*); |
1291 void patch(Prog*, Prog*); | 1303 void patch(Prog*, Prog*); |
1292 Prog* unpatch(Prog*); | 1304 Prog* unpatch(Prog*); |
1293 void zfile(Biobuf *b, char *p, int n); | 1305 void zfile(Biobuf *b, char *p, int n); |
1294 void zhist(Biobuf *b, int line, vlong offset); | 1306 void zhist(Biobuf *b, int line, vlong offset); |
1295 void zname(Biobuf *b, Sym *s, int t); | 1307 void zname(Biobuf *b, Sym *s, int t); |
1296 void data(void); | 1308 void data(void); |
1297 void text(void); | 1309 void text(void); |
1298 | 1310 |
LEFT | RIGHT |