Mercurial > projects > ddmd
annotate dmd/AttribDeclaration.d @ 131:206db751bd4c
dmdfe 2.037 compiles now
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Fri, 10 Sep 2010 00:27:37 +0100 |
parents | e28b18c23469 |
children | e3afd1303184 |
rev | line source |
---|---|
0 | 1 module dmd.AttribDeclaration; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.Dsymbol; |
5 import dmd.Array; | |
6 import dmd.Scope; | |
7 import dmd.ScopeDsymbol; | |
8 import dmd.LINK; | |
9 import dmd.STC; | |
10 import dmd.PROT; | |
11 import dmd.ArrayTypes; | |
12 import dmd.OutBuffer; | |
13 import dmd.HdrGenState; | |
14 | |
15 class AttribDeclaration : Dsymbol | |
16 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
17 Dsymbols decl; // array of Dsymbol's |
0 | 18 |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
19 this(Dsymbols decl) |
0 | 20 { |
21 this.decl = decl; | |
22 } | |
23 | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
24 Dsymbols include(Scope sc, ScopeDsymbol sd) |
0 | 25 { |
26 return decl; | |
27 } | |
28 | |
72 | 29 override bool addMember(Scope sc, ScopeDsymbol sd, bool memnum) |
0 | 30 { |
31 bool m = false; | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
32 auto d = include(sc, sd); |
0 | 33 |
34 if (d) | |
35 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
36 foreach(s; d) |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
37 m |= s.addMember(sc, sd, m | memnum); |
0 | 38 } |
39 | |
40 return m; | |
41 } | |
42 | |
131
206db751bd4c
dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
43 void setScopeNewSc(Scope sc, StorageClass stc, LINK linkage, PROT protection, int explicitProtection, uint structalign) |
0 | 44 { |
45 if (decl) | |
46 { | |
47 Scope newsc = sc; | |
48 if (stc != sc.stc || linkage != sc.linkage || protection != sc.protection || explicitProtection != sc.explicitProtection || structalign != sc.structalign) | |
49 { | |
50 // create new one for changes | |
82 | 51 newsc = sc.clone(); |
0 | 52 newsc.flags &= ~SCOPE.SCOPEfree; |
53 newsc.stc = stc; | |
54 newsc.linkage = linkage; | |
55 newsc.protection = protection; | |
56 newsc.explicitProtection = explicitProtection; | |
57 newsc.structalign = structalign; | |
58 } | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
59 foreach(Dsymbol s; decl) |
0 | 60 s.setScope(newsc); // yes, the only difference from semanticNewSc() |
61 if (newsc != sc) | |
62 { | |
63 sc.offset = newsc.offset; | |
64 newsc.pop(); | |
65 } | |
66 } | |
67 } | |
68 | |
131
206db751bd4c
dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
69 void semanticNewSc(Scope sc, StorageClass stc, LINK linkage, PROT protection, int explicitProtection, uint structalign) |
0 | 70 { |
71 if (decl) | |
72 { | |
73 Scope newsc = sc; | |
74 if (stc != sc.stc || linkage != sc.linkage || protection != sc.protection || explicitProtection != sc.explicitProtection || structalign != sc.structalign) | |
75 { | |
76 // create new one for changes | |
82 | 77 newsc = sc.clone(); |
0 | 78 newsc.flags &= ~SCOPE.SCOPEfree; |
79 newsc.stc = stc; | |
80 newsc.linkage = linkage; | |
81 newsc.protection = protection; | |
82 newsc.explicitProtection = explicitProtection; | |
83 newsc.structalign = structalign; | |
84 } | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
85 foreach(Dsymbol s; decl) |
0 | 86 s.semantic(newsc); |
87 if (newsc != sc) | |
88 { | |
89 sc.offset = newsc.offset; | |
90 newsc.pop(); | |
91 } | |
92 } | |
93 } | |
94 | |
72 | 95 override void semantic(Scope sc) |
0 | 96 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
97 auto d = include(sc, null); |
0 | 98 |
99 //printf("\tAttribDeclaration::semantic '%s', d = %p\n",toChars(), d); | |
100 if (d) | |
101 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
102 foreach(s; d) |
0 | 103 s.semantic(sc); |
104 } | |
105 } | |
106 | |
72 | 107 override void semantic2(Scope sc) |
0 | 108 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
109 auto d = include(sc, null); |
0 | 110 |
111 if (d) | |
112 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
113 foreach(s; d) |
0 | 114 s.semantic2(sc); |
115 } | |
116 } | |
117 | |
72 | 118 override void semantic3(Scope sc) |
0 | 119 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
120 auto d = include(sc, null); |
0 | 121 |
122 if (d) | |
123 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
124 foreach(s; d) |
0 | 125 s.semantic3(sc); |
126 } | |
127 } | |
128 | |
72 | 129 override void inlineScan() |
0 | 130 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
131 auto d = include(null, null); |
0 | 132 |
133 if (d) | |
134 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
135 foreach(s; d) |
0 | 136 { |
137 //printf("AttribDeclaration.inlineScan %s\n", s.toChars()); | |
138 s.inlineScan(); | |
139 } | |
140 } | |
141 } | |
142 | |
79 | 143 override void addComment(string comment) |
0 | 144 { |
145 if (comment !is null) | |
146 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
147 auto d = include(null, null); |
0 | 148 if (d) |
149 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
150 foreach(s; d) |
0 | 151 { |
152 //printf("AttribDeclaration::addComment %s\n", s.toChars()); | |
153 s.addComment(comment); | |
154 } | |
155 } | |
156 } | |
157 } | |
158 | |
72 | 159 override void emitComment(Scope sc) |
0 | 160 { |
161 assert(false); | |
162 } | |
163 | |
72 | 164 override string kind() |
0 | 165 { |
166 assert(false); | |
167 } | |
168 | |
72 | 169 override bool oneMember(Dsymbol* ps) |
0 | 170 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
171 auto d = include(null, null); |
49 | 172 |
173 return Dsymbol.oneMembers(d, ps); | |
0 | 174 } |
175 | |
72 | 176 override bool hasPointers() |
0 | 177 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
178 auto d = include(null, null); |
0 | 179 |
180 if (d) | |
181 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
182 foreach(s; d) |
0 | 183 { |
184 if (s.hasPointers()) | |
185 return true; | |
186 } | |
187 } | |
188 | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
189 return false; |
0 | 190 } |
191 | |
72 | 192 override void checkCtorConstInit() |
0 | 193 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
194 auto d = include(null, null); |
0 | 195 if (d) |
196 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
197 foreach(s; d) |
0 | 198 s.checkCtorConstInit(); |
199 } | |
200 } | |
201 | |
72 | 202 override void addLocalClass(ClassDeclarations aclasses) |
0 | 203 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
204 auto d = include(null, null); |
0 | 205 if (d) |
206 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
207 foreach(s; d) |
0 | 208 s.addLocalClass(aclasses); |
209 } | |
210 } | |
211 | |
72 | 212 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 213 { |
214 assert(false); | |
215 } | |
79 | 216 |
217 override void toJsonBuffer(OutBuffer buf) | |
218 { | |
219 //writef("AttribDeclaration.toJsonBuffer()\n"); | |
220 | |
221 Dsymbols d = include(null, null); | |
222 | |
223 if (d) | |
224 { | |
225 foreach (Dsymbol s; d) | |
226 { | |
227 //writef("AttribDeclaration.toJsonBuffer %s\n", s.toChars()); | |
228 s.toJsonBuffer(buf); | |
229 } | |
230 } | |
231 } | |
232 | |
72 | 233 override AttribDeclaration isAttribDeclaration() { return this; } |
0 | 234 |
72 | 235 override void toObjFile(int multiobj) // compile to .obj file |
0 | 236 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
237 auto d = include(null, null); |
0 | 238 |
239 if (d) | |
240 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
241 foreach(s; d) |
0 | 242 s.toObjFile(multiobj); |
243 } | |
244 } | |
245 | |
72 | 246 override int cvMember(ubyte* p) |
0 | 247 { |
248 assert(false); | |
249 } | |
72 | 250 } |