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