LEFT | RIGHT |
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 /* | 5 /* |
6 * static initialization | 6 * static initialization |
7 */ | 7 */ |
8 | 8 |
9 #include <u.h> | 9 #include <u.h> |
10 #include <libc.h> | 10 #include <libc.h> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 init1(n->type->nname, out); | 43 init1(n->type->nname, out); |
44 } | 44 } |
45 | 45 |
46 if(n->op != ONAME) | 46 if(n->op != ONAME) |
47 return; | 47 return; |
48 switch(n->class) { | 48 switch(n->class) { |
49 case PEXTERN: | 49 case PEXTERN: |
50 case PFUNC: | 50 case PFUNC: |
51 break; | 51 break; |
52 default: | 52 default: |
53 » » if(isblank(n) && n->curfn == N && n->defn != N && n->defn->inito
rder == InitNotStarted) | 53 » » if(isblank(n) && n->curfn == N && n->defn != N && n->defn->inito
rder == InitNotStarted) { |
54 » » » break; | 54 » » » // blank names initialization is part of init() but not |
| 55 » » » // when they are inside a function. |
| 56 » » » break; |
| 57 » » } |
55 return; | 58 return; |
56 } | 59 } |
57 | 60 |
58 if(n->initorder == InitDone) | 61 if(n->initorder == InitDone) |
59 return; | 62 return; |
60 if(n->initorder == InitPending) { | 63 if(n->initorder == InitPending) { |
61 if(n->class == PFUNC) | 64 if(n->class == PFUNC) |
62 return; | 65 return; |
63 | 66 |
64 // if there have already been errors printed, | 67 // if there have already been errors printed, |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 if(p->cap == 0) | 1417 if(p->cap == 0) |
1415 p->cap = 4; | 1418 p->cap = 4; |
1416 else | 1419 else |
1417 p->cap *= 2; | 1420 p->cap *= 2; |
1418 p->e = realloc(p->e, p->cap*sizeof p->e[0]); | 1421 p->e = realloc(p->e, p->cap*sizeof p->e[0]); |
1419 if(p->e == nil) | 1422 if(p->e == nil) |
1420 fatal("out of memory"); | 1423 fatal("out of memory"); |
1421 } | 1424 } |
1422 return &p->e[p->len++]; | 1425 return &p->e[p->len++]; |
1423 } | 1426 } |
LEFT | RIGHT |