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