Mercurial > projects > ldc
annotate dmd/attrib.c @ 1256:6af2359b433a
Change needed for mingw
author | Kelly Wilson <wilsonk cpsc.ucalgary.ca> |
---|---|
date | Wed, 22 Apr 2009 14:40:56 -0600 |
parents | e961851fb8be |
children | 229e02867307 |
rev | line source |
---|---|
159 | 1 |
2 // Compiler implementation of the D programming language | |
1195
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
3 // Copyright (c) 1999-2009 by Digital Mars |
159 | 4 // All Rights Reserved |
5 // written by Walter Bright | |
6 // http://www.digitalmars.com | |
7 // License for redistribution is by either the Artistic License | |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | |
9 // See the included readme.txt for details. | |
10 | |
11 #include <stdio.h> | |
12 #include <stdlib.h> | |
13 #include <assert.h> | |
14 | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
15 #include "rmem.h" |
159 | 16 |
17 #include "init.h" | |
18 #include "declaration.h" | |
19 #include "attrib.h" | |
20 #include "cond.h" | |
21 #include "scope.h" | |
22 #include "id.h" | |
23 #include "expression.h" | |
24 #include "dsymbol.h" | |
25 #include "aggregate.h" | |
26 #include "module.h" | |
27 #include "parse.h" | |
28 #include "template.h" | |
29 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
30 #if IN_LLVM |
159 | 31 #include "../gen/enums.h" |
32 | |
986
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
876
diff
changeset
|
33 #include "llvm/Support/CommandLine.h" |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
876
diff
changeset
|
34 |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
876
diff
changeset
|
35 static llvm::cl::opt<bool> ignoreUnsupportedPragmas("ignore", |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
876
diff
changeset
|
36 llvm::cl::desc("Ignore unsupported pragmas"), |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
876
diff
changeset
|
37 llvm::cl::ZeroOrMore); |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
876
diff
changeset
|
38 |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
39 #endif |
986
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
876
diff
changeset
|
40 |
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
876
diff
changeset
|
41 |
658
50383e476c7e
Upgraded frontend to DMD 1.035
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
571
diff
changeset
|
42 extern void obj_includelib(const char *name); |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
43 |
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
44 #if IN_DMD |
336 | 45 void obj_startaddress(Symbol *s); |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
46 #endif |
159 | 47 |
48 | |
49 /********************************* AttribDeclaration ****************************/ | |
50 | |
51 AttribDeclaration::AttribDeclaration(Array *decl) | |
52 : Dsymbol() | |
53 { | |
54 this->decl = decl; | |
55 } | |
56 | |
57 Array *AttribDeclaration::include(Scope *sc, ScopeDsymbol *sd) | |
58 { | |
59 return decl; | |
60 } | |
61 | |
62 int AttribDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) | |
63 { | |
64 int m = 0; | |
65 Array *d = include(sc, sd); | |
66 | |
67 if (d) | |
68 { | |
336 | 69 for (unsigned i = 0; i < d->dim; i++) |
70 { Dsymbol *s = (Dsymbol *)d->data[i]; | |
159 | 71 m |= s->addMember(sc, sd, m | memnum); |
72 } | |
73 } | |
74 return m; | |
75 } | |
76 | |
77 void AttribDeclaration::semantic(Scope *sc) | |
78 { | |
79 Array *d = include(sc, NULL); | |
80 | |
336 | 81 //printf("\tAttribDeclaration::semantic '%s', d = %p\n",toChars(), d); |
159 | 82 if (d) |
83 { | |
84 for (unsigned i = 0; i < d->dim; i++) | |
85 { | |
86 Dsymbol *s = (Dsymbol *)d->data[i]; | |
87 | |
88 s->semantic(sc); | |
89 } | |
90 } | |
91 } | |
92 | |
93 void AttribDeclaration::semantic2(Scope *sc) | |
94 { | |
95 Array *d = include(sc, NULL); | |
96 | |
97 if (d) | |
98 { | |
336 | 99 for (unsigned i = 0; i < d->dim; i++) |
100 { Dsymbol *s = (Dsymbol *)d->data[i]; | |
159 | 101 s->semantic2(sc); |
102 } | |
103 } | |
104 } | |
105 | |
106 void AttribDeclaration::semantic3(Scope *sc) | |
107 { | |
108 Array *d = include(sc, NULL); | |
109 | |
110 if (d) | |
111 { | |
336 | 112 for (unsigned i = 0; i < d->dim; i++) |
113 { Dsymbol *s = (Dsymbol *)d->data[i]; | |
159 | 114 s->semantic3(sc); |
115 } | |
116 } | |
117 } | |
118 | |
119 void AttribDeclaration::inlineScan() | |
120 { | |
121 Array *d = include(NULL, NULL); | |
122 | |
123 if (d) | |
124 { | |
336 | 125 for (unsigned i = 0; i < d->dim; i++) |
126 { Dsymbol *s = (Dsymbol *)d->data[i]; | |
159 | 127 //printf("AttribDeclaration::inlineScan %s\n", s->toChars()); |
128 s->inlineScan(); | |
129 } | |
130 } | |
131 } | |
132 | |
133 void AttribDeclaration::addComment(unsigned char *comment) | |
134 { | |
135 if (comment) | |
136 { | |
137 Array *d = include(NULL, NULL); | |
138 | |
139 if (d) | |
140 { | |
336 | 141 for (unsigned i = 0; i < d->dim; i++) |
142 { Dsymbol *s = (Dsymbol *)d->data[i]; | |
159 | 143 //printf("AttribDeclaration::addComment %s\n", s->toChars()); |
144 s->addComment(comment); | |
145 } | |
146 } | |
147 } | |
148 } | |
149 | |
150 void AttribDeclaration::emitComment(Scope *sc) | |
151 { | |
152 //printf("AttribDeclaration::emitComment(sc = %p)\n", sc); | |
153 | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
154 /* A general problem with this, illustrated by BUGZILLA 2516, |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
155 * is that attributes are not transmitted through to the underlying |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
156 * member declarations for template bodies, because semantic analysis |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
157 * is not done for template declaration bodies |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
158 * (only template instantiations). |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
159 * Hence, Ddoc omits attributes from template members. |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
160 */ |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
161 |
159 | 162 Array *d = include(NULL, NULL); |
163 | |
164 if (d) | |
165 { | |
336 | 166 for (unsigned i = 0; i < d->dim; i++) |
167 { Dsymbol *s = (Dsymbol *)d->data[i]; | |
159 | 168 //printf("AttribDeclaration::emitComment %s\n", s->toChars()); |
169 s->emitComment(sc); | |
170 } | |
171 } | |
172 } | |
173 | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
174 #if IN_DMD |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
175 |
336 | 176 void AttribDeclaration::toObjFile(int multiobj) |
159 | 177 { |
178 Array *d = include(NULL, NULL); | |
179 | |
180 if (d) | |
181 { | |
336 | 182 for (unsigned i = 0; i < d->dim; i++) |
183 { Dsymbol *s = (Dsymbol *)d->data[i]; | |
184 s->toObjFile(multiobj); | |
159 | 185 } |
186 } | |
187 } | |
188 | |
189 int AttribDeclaration::cvMember(unsigned char *p) | |
190 { | |
191 int nwritten = 0; | |
192 int n; | |
193 Array *d = include(NULL, NULL); | |
194 | |
195 if (d) | |
196 { | |
336 | 197 for (unsigned i = 0; i < d->dim; i++) |
198 { Dsymbol *s = (Dsymbol *)d->data[i]; | |
159 | 199 n = s->cvMember(p); |
200 if (p) | |
201 p += n; | |
202 nwritten += n; | |
203 } | |
204 } | |
205 return nwritten; | |
206 } | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
207 #endif |
159 | 208 |
209 int AttribDeclaration::hasPointers() | |
210 { | |
211 Array *d = include(NULL, NULL); | |
212 | |
213 if (d) | |
214 { | |
215 for (size_t i = 0; i < d->dim; i++) | |
216 { | |
217 Dsymbol *s = (Dsymbol *)d->data[i]; | |
218 if (s->hasPointers()) | |
219 return 1; | |
220 } | |
221 } | |
222 return 0; | |
223 } | |
224 | |
336 | 225 const char *AttribDeclaration::kind() |
159 | 226 { |
227 return "attribute"; | |
228 } | |
229 | |
230 int AttribDeclaration::oneMember(Dsymbol **ps) | |
231 { | |
232 Array *d = include(NULL, NULL); | |
233 | |
234 return Dsymbol::oneMembers(d, ps); | |
235 } | |
236 | |
237 void AttribDeclaration::checkCtorConstInit() | |
238 { | |
239 Array *d = include(NULL, NULL); | |
240 | |
241 if (d) | |
242 { | |
336 | 243 for (unsigned i = 0; i < d->dim; i++) |
244 { Dsymbol *s = (Dsymbol *)d->data[i]; | |
159 | 245 s->checkCtorConstInit(); |
246 } | |
247 } | |
248 } | |
249 | |
250 /**************************************** | |
251 */ | |
252 | |
253 void AttribDeclaration::addLocalClass(ClassDeclarations *aclasses) | |
336 | 254 { |
159 | 255 Array *d = include(NULL, NULL); |
256 | |
257 if (d) | |
258 { | |
336 | 259 for (unsigned i = 0; i < d->dim; i++) |
260 { Dsymbol *s = (Dsymbol *)d->data[i]; | |
159 | 261 s->addLocalClass(aclasses); |
262 } | |
263 } | |
264 } | |
265 | |
266 | |
267 void AttribDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
268 { | |
269 if (decl) | |
270 { | |
271 buf->writenl(); | |
272 buf->writeByte('{'); | |
273 buf->writenl(); | |
274 for (unsigned i = 0; i < decl->dim; i++) | |
275 { | |
276 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
277 | |
278 buf->writestring(" "); | |
279 s->toCBuffer(buf, hgs); | |
280 } | |
281 buf->writeByte('}'); | |
282 } | |
283 else | |
284 buf->writeByte(';'); | |
285 buf->writenl(); | |
286 } | |
287 | |
288 /************************* StorageClassDeclaration ****************************/ | |
289 | |
290 StorageClassDeclaration::StorageClassDeclaration(unsigned stc, Array *decl) | |
291 : AttribDeclaration(decl) | |
292 { | |
293 this->stc = stc; | |
294 } | |
295 | |
296 Dsymbol *StorageClassDeclaration::syntaxCopy(Dsymbol *s) | |
297 { | |
298 StorageClassDeclaration *scd; | |
299 | |
300 assert(!s); | |
301 scd = new StorageClassDeclaration(stc, Dsymbol::arraySyntaxCopy(decl)); | |
302 return scd; | |
303 } | |
304 | |
305 void StorageClassDeclaration::semantic(Scope *sc) | |
306 { | |
307 if (decl) | |
308 { unsigned stc_save = sc->stc; | |
309 | |
310 if (stc & (STCauto | STCscope | STCstatic | STCextern)) | |
311 sc->stc &= ~(STCauto | STCscope | STCstatic | STCextern); | |
312 sc->stc |= stc; | |
313 for (unsigned i = 0; i < decl->dim; i++) | |
314 { | |
315 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
316 | |
317 s->semantic(sc); | |
318 } | |
319 sc->stc = stc_save; | |
320 } | |
321 else | |
322 sc->stc = stc; | |
323 } | |
324 | |
1195
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
325 void StorageClassDeclaration::stcToCBuffer(OutBuffer *buf, int stc) |
159 | 326 { |
327 struct SCstring | |
328 { | |
329 int stc; | |
330 enum TOK tok; | |
331 }; | |
332 | |
333 static SCstring table[] = | |
334 { | |
335 { STCauto, TOKauto }, | |
336 { STCscope, TOKscope }, | |
337 { STCstatic, TOKstatic }, | |
338 { STCextern, TOKextern }, | |
339 { STCconst, TOKconst }, | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
340 // { STCinvariant, TOKimmutable }, |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
341 // { STCshared, TOKshared }, |
159 | 342 { STCfinal, TOKfinal }, |
343 { STCabstract, TOKabstract }, | |
344 { STCsynchronized, TOKsynchronized }, | |
345 { STCdeprecated, TOKdeprecated }, | |
346 { STCoverride, TOKoverride }, | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
347 // { STCnothrow, TOKnothrow }, |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
348 // { STCpure, TOKpure }, |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
349 // { STCref, TOKref }, |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
350 // { STCtls, TOKtls }, |
159 | 351 }; |
352 | |
353 for (int i = 0; i < sizeof(table)/sizeof(table[0]); i++) | |
354 { | |
355 if (stc & table[i].stc) | |
356 { | |
357 buf->writestring(Token::toChars(table[i].tok)); | |
1195
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
358 buf->writeByte(' '); |
159 | 359 } |
360 } | |
1195
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
361 } |
159 | 362 |
1195
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
363 void StorageClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) |
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
364 { |
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
365 stcToCBuffer(buf, stc); |
159 | 366 AttribDeclaration::toCBuffer(buf, hgs); |
367 } | |
368 | |
369 /********************************* LinkDeclaration ****************************/ | |
370 | |
371 LinkDeclaration::LinkDeclaration(enum LINK p, Array *decl) | |
372 : AttribDeclaration(decl) | |
373 { | |
374 //printf("LinkDeclaration(linkage = %d, decl = %p)\n", p, decl); | |
375 linkage = p; | |
376 } | |
377 | |
378 Dsymbol *LinkDeclaration::syntaxCopy(Dsymbol *s) | |
379 { | |
380 LinkDeclaration *ld; | |
381 | |
382 assert(!s); | |
383 ld = new LinkDeclaration(linkage, Dsymbol::arraySyntaxCopy(decl)); | |
384 return ld; | |
385 } | |
386 | |
387 void LinkDeclaration::semantic(Scope *sc) | |
388 { | |
389 //printf("LinkDeclaration::semantic(linkage = %d, decl = %p)\n", linkage, decl); | |
390 if (decl) | |
391 { enum LINK linkage_save = sc->linkage; | |
392 | |
393 sc->linkage = linkage; | |
394 for (unsigned i = 0; i < decl->dim; i++) | |
395 { | |
396 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
397 | |
398 s->semantic(sc); | |
399 } | |
400 sc->linkage = linkage_save; | |
401 } | |
402 else | |
403 { | |
404 sc->linkage = linkage; | |
405 } | |
406 } | |
407 | |
408 void LinkDeclaration::semantic3(Scope *sc) | |
409 { | |
410 //printf("LinkDeclaration::semantic3(linkage = %d, decl = %p)\n", linkage, decl); | |
411 if (decl) | |
412 { enum LINK linkage_save = sc->linkage; | |
413 | |
414 sc->linkage = linkage; | |
415 for (unsigned i = 0; i < decl->dim; i++) | |
416 { | |
417 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
418 | |
419 s->semantic3(sc); | |
420 } | |
421 sc->linkage = linkage_save; | |
422 } | |
423 else | |
424 { | |
425 sc->linkage = linkage; | |
426 } | |
427 } | |
428 | |
429 void LinkDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
846
diff
changeset
|
430 { const char *p; |
159 | 431 |
432 switch (linkage) | |
433 { | |
434 case LINKd: p = "D"; break; | |
435 case LINKc: p = "C"; break; | |
436 case LINKcpp: p = "C++"; break; | |
437 case LINKwindows: p = "Windows"; break; | |
438 case LINKpascal: p = "Pascal"; break; | |
723
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
716
diff
changeset
|
439 |
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
716
diff
changeset
|
440 // LDC |
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
716
diff
changeset
|
441 case LINKintrinsic: p = "Intrinsic"; break; |
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
716
diff
changeset
|
442 |
159 | 443 default: |
444 assert(0); | |
445 break; | |
446 } | |
447 buf->writestring("extern ("); | |
448 buf->writestring(p); | |
449 buf->writestring(") "); | |
450 AttribDeclaration::toCBuffer(buf, hgs); | |
451 } | |
452 | |
453 char *LinkDeclaration::toChars() | |
454 { | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
846
diff
changeset
|
455 return (char *)"extern ()"; |
159 | 456 } |
457 | |
458 /********************************* ProtDeclaration ****************************/ | |
459 | |
460 ProtDeclaration::ProtDeclaration(enum PROT p, Array *decl) | |
461 : AttribDeclaration(decl) | |
462 { | |
463 protection = p; | |
464 //printf("decl = %p\n", decl); | |
465 } | |
466 | |
467 Dsymbol *ProtDeclaration::syntaxCopy(Dsymbol *s) | |
468 { | |
469 ProtDeclaration *pd; | |
470 | |
471 assert(!s); | |
472 pd = new ProtDeclaration(protection, Dsymbol::arraySyntaxCopy(decl)); | |
473 return pd; | |
474 } | |
475 | |
476 void ProtDeclaration::semantic(Scope *sc) | |
477 { | |
478 if (decl) | |
479 { enum PROT protection_save = sc->protection; | |
480 int explicitProtection_save = sc->explicitProtection; | |
481 | |
482 sc->protection = protection; | |
483 sc->explicitProtection = 1; | |
484 for (unsigned i = 0; i < decl->dim; i++) | |
485 { | |
486 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
487 | |
488 s->semantic(sc); | |
489 } | |
490 sc->protection = protection_save; | |
491 sc->explicitProtection = explicitProtection_save; | |
492 } | |
493 else | |
494 { sc->protection = protection; | |
495 sc->explicitProtection = 1; | |
496 } | |
497 } | |
498 | |
499 void ProtDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
846
diff
changeset
|
500 { const char *p; |
159 | 501 |
502 switch (protection) | |
503 { | |
504 case PROTprivate: p = "private"; break; | |
505 case PROTpackage: p = "package"; break; | |
506 case PROTprotected: p = "protected"; break; | |
507 case PROTpublic: p = "public"; break; | |
508 case PROTexport: p = "export"; break; | |
509 default: | |
510 assert(0); | |
511 break; | |
512 } | |
513 buf->writestring(p); | |
514 AttribDeclaration::toCBuffer(buf, hgs); | |
515 } | |
516 | |
517 /********************************* AlignDeclaration ****************************/ | |
518 | |
710
20a5180f2e80
Make align(n), n != 1 an error.
Christian Kamm <kamm incasoftware de>
parents:
663
diff
changeset
|
519 AlignDeclaration::AlignDeclaration(Loc loc, unsigned sa, Array *decl) |
159 | 520 : AttribDeclaration(decl) |
521 { | |
710
20a5180f2e80
Make align(n), n != 1 an error.
Christian Kamm <kamm incasoftware de>
parents:
663
diff
changeset
|
522 this->loc = loc; |
159 | 523 salign = sa; |
524 } | |
525 | |
526 Dsymbol *AlignDeclaration::syntaxCopy(Dsymbol *s) | |
527 { | |
528 AlignDeclaration *ad; | |
529 | |
530 assert(!s); | |
710
20a5180f2e80
Make align(n), n != 1 an error.
Christian Kamm <kamm incasoftware de>
parents:
663
diff
changeset
|
531 ad = new AlignDeclaration(loc, salign, Dsymbol::arraySyntaxCopy(decl)); |
159 | 532 return ad; |
533 } | |
534 | |
535 void AlignDeclaration::semantic(Scope *sc) | |
536 { | |
737
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
537 // LDC |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
538 // we only support packed structs, as from the spec: align(1) struct Packed { ... } |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
539 // other alignments are simply ignored. my tests show this is what llvm-gcc does too ... |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
540 |
159 | 541 //printf("\tAlignDeclaration::semantic '%s'\n",toChars()); |
542 if (decl) | |
543 { unsigned salign_save = sc->structalign; | |
544 | |
545 for (unsigned i = 0; i < decl->dim; i++) | |
546 { | |
547 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
548 | |
737
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
549 if (s->isStructDeclaration() && salign == 1) |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
550 { |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
551 sc->structalign = salign; |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
552 s->semantic(sc); |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
553 sc->structalign = salign_save; |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
554 } |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
555 else |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
556 { |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
557 s->semantic(sc); |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
558 } |
159 | 559 } |
560 sc->structalign = salign_save; | |
561 } | |
562 else | |
737
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
563 assert(0 && "what kind of align use triggers this?"); |
159 | 564 } |
565 | |
566 | |
567 void AlignDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
568 { | |
569 buf->printf("align (%d)", salign); | |
570 AttribDeclaration::toCBuffer(buf, hgs); | |
571 } | |
572 | |
573 /********************************* AnonDeclaration ****************************/ | |
574 | |
575 AnonDeclaration::AnonDeclaration(Loc loc, int isunion, Array *decl) | |
576 : AttribDeclaration(decl) | |
577 { | |
578 this->loc = loc; | |
579 this->isunion = isunion; | |
580 this->scope = NULL; | |
581 this->sem = 0; | |
582 } | |
583 | |
584 Dsymbol *AnonDeclaration::syntaxCopy(Dsymbol *s) | |
585 { | |
586 AnonDeclaration *ad; | |
587 | |
588 assert(!s); | |
589 ad = new AnonDeclaration(loc, isunion, Dsymbol::arraySyntaxCopy(decl)); | |
590 return ad; | |
591 } | |
592 | |
593 void AnonDeclaration::semantic(Scope *sc) | |
594 { | |
595 //printf("\tAnonDeclaration::semantic %s %p\n", isunion ? "union" : "struct", this); | |
596 | |
597 Scope *scx = NULL; | |
598 if (scope) | |
599 { sc = scope; | |
600 scx = scope; | |
601 scope = NULL; | |
602 } | |
603 | |
604 assert(sc->parent); | |
605 | |
606 Dsymbol *parent = sc->parent->pastMixin(); | |
607 AggregateDeclaration *ad = parent->isAggregateDeclaration(); | |
608 | |
609 if (!ad || (!ad->isStructDeclaration() && !ad->isClassDeclaration())) | |
610 { | |
611 error("can only be a part of an aggregate"); | |
612 return; | |
613 } | |
614 | |
615 if (decl) | |
616 { | |
617 AnonymousAggregateDeclaration aad; | |
618 int adisunion; | |
619 | |
620 if (sc->anonAgg) | |
621 { ad = sc->anonAgg; | |
622 adisunion = sc->inunion; | |
623 } | |
624 else | |
625 adisunion = ad->isUnionDeclaration() != NULL; | |
626 | |
627 // printf("\tsc->anonAgg = %p\n", sc->anonAgg); | |
628 // printf("\tad = %p\n", ad); | |
629 // printf("\taad = %p\n", &aad); | |
630 | |
631 sc = sc->push(); | |
632 sc->anonAgg = &aad; | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
633 sc->stc &= ~(STCauto | STCscope | STCstatic | STCtls); |
159 | 634 sc->inunion = isunion; |
635 sc->offset = 0; | |
636 sc->flags = 0; | |
637 aad.structalign = sc->structalign; | |
638 aad.parent = ad; | |
846
bc982f1ad106
Merged DMD 1.037 frontend
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
816
diff
changeset
|
639 |
159 | 640 for (unsigned i = 0; i < decl->dim; i++) |
641 { | |
642 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
643 | |
644 s->semantic(sc); | |
645 if (isunion) | |
646 sc->offset = 0; | |
647 if (aad.sizeok == 2) | |
648 { | |
649 break; | |
650 } | |
651 } | |
652 sc = sc->pop(); | |
653 | |
654 // If failed due to forward references, unwind and try again later | |
655 if (aad.sizeok == 2) | |
656 { | |
657 ad->sizeok = 2; | |
658 //printf("\tsetting ad->sizeok %p to 2\n", ad); | |
659 if (!sc->anonAgg) | |
660 { | |
661 scope = scx ? scx : new Scope(*sc); | |
662 scope->setNoFree(); | |
663 scope->module->addDeferredSemantic(this); | |
664 } | |
665 //printf("\tforward reference %p\n", this); | |
666 return; | |
667 } | |
668 if (sem == 0) | |
669 { Module::dprogress++; | |
670 sem = 1; | |
671 //printf("\tcompleted %p\n", this); | |
672 } | |
673 else | |
674 ;//printf("\talready completed %p\n", this); | |
675 | |
676 // 0 sized structs are set to 1 byte | |
677 if (aad.structsize == 0) | |
678 { | |
679 aad.structsize = 1; | |
680 aad.alignsize = 1; | |
681 } | |
682 | |
683 // Align size of anonymous aggregate | |
684 //printf("aad.structalign = %d, aad.alignsize = %d, sc->offset = %d\n", aad.structalign, aad.alignsize, sc->offset); | |
685 ad->alignmember(aad.structalign, aad.alignsize, &sc->offset); | |
686 //ad->structsize = sc->offset; | |
687 //printf("sc->offset = %d\n", sc->offset); | |
688 | |
689 // Add members of aad to ad | |
737
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
690 //printf("\tadding members of aad (%p) to '%s'\n", &aad, ad->toChars()); |
159 | 691 for (unsigned i = 0; i < aad.fields.dim; i++) |
692 { | |
693 VarDeclaration *v = (VarDeclaration *)aad.fields.data[i]; | |
694 | |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
695 // LDC |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
696 v->offset2 = sc->offset; |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
697 |
159 | 698 v->offset += sc->offset; |
737
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
699 |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
700 // LDC |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
701 if (!v->anonDecl) |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
702 v->anonDecl = this; |
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
703 |
159 | 704 ad->fields.push(v); |
705 } | |
706 | |
707 // Add size of aad to ad | |
708 if (adisunion) | |
709 { | |
710 if (aad.structsize > ad->structsize) | |
711 ad->structsize = aad.structsize; | |
712 sc->offset = 0; | |
713 } | |
714 else | |
715 { | |
716 ad->structsize = sc->offset + aad.structsize; | |
717 sc->offset = ad->structsize; | |
718 } | |
719 | |
720 if (ad->alignsize < aad.alignsize) | |
721 ad->alignsize = aad.alignsize; | |
722 } | |
723 } | |
724 | |
725 | |
726 void AnonDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
727 { | |
728 buf->printf(isunion ? "union" : "struct"); | |
729 buf->writestring("\n{\n"); | |
730 if (decl) | |
731 { | |
732 for (unsigned i = 0; i < decl->dim; i++) | |
733 { | |
734 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
735 | |
736 //buf->writestring(" "); | |
737 s->toCBuffer(buf, hgs); | |
738 } | |
739 } | |
740 buf->writestring("}\n"); | |
741 } | |
742 | |
336 | 743 const char *AnonDeclaration::kind() |
159 | 744 { |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
846
diff
changeset
|
745 return (isunion ? "anonymous union" : "anonymous struct"); |
159 | 746 } |
747 | |
748 /********************************* PragmaDeclaration ****************************/ | |
749 | |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
750 static bool parseStringExp(Expression* e, std::string& res) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
751 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
752 StringExp *s = NULL; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
753 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
754 e = e->optimize(WANTvalue); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
755 if (e->op == TOKstring && (s = (StringExp *)e)) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
756 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
757 char* str = (char*)s->string; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
758 res = str; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
759 return true; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
760 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
761 return false; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
762 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
763 |
159 | 764 PragmaDeclaration::PragmaDeclaration(Loc loc, Identifier *ident, Expressions *args, Array *decl) |
765 : AttribDeclaration(decl) | |
766 { | |
767 this->loc = loc; | |
768 this->ident = ident; | |
769 this->args = args; | |
770 } | |
771 | |
772 Dsymbol *PragmaDeclaration::syntaxCopy(Dsymbol *s) | |
773 { | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
774 //printf("PragmaDeclaration::syntaxCopy(%s)\n", toChars()); |
159 | 775 PragmaDeclaration *pd; |
776 | |
777 assert(!s); | |
778 pd = new PragmaDeclaration(loc, ident, | |
779 Expression::arraySyntaxCopy(args), Dsymbol::arraySyntaxCopy(decl)); | |
780 return pd; | |
781 } | |
782 | |
783 void PragmaDeclaration::semantic(Scope *sc) | |
784 { // Should be merged with PragmaStatement | |
785 | |
786 #if IN_LLVM | |
787 int llvm_internal = 0; | |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
788 std::string arg1str; |
159 | 789 |
790 #endif | |
791 | |
792 //printf("\tPragmaDeclaration::semantic '%s'\n",toChars()); | |
793 if (ident == Id::msg) | |
794 { | |
795 if (args) | |
796 { | |
797 for (size_t i = 0; i < args->dim; i++) | |
798 { | |
799 Expression *e = (Expression *)args->data[i]; | |
800 | |
801 e = e->semantic(sc); | |
802 e = e->optimize(WANTvalue | WANTinterpret); | |
803 if (e->op == TOKstring) | |
804 { | |
805 StringExp *se = (StringExp *)e; | |
794
661384d6a936
Fix warnings on x86-64. By fvbommel.
Christian Kamm <kamm incasoftware de>
parents:
737
diff
changeset
|
806 fprintf(stdmsg, "%.*s", (int)se->len, (char*)se->string); |
159 | 807 } |
808 else | |
809 error("string expected for message, not '%s'", e->toChars()); | |
810 } | |
811 fprintf(stdmsg, "\n"); | |
812 } | |
813 goto Lnodecl; | |
814 } | |
815 else if (ident == Id::lib) | |
816 { | |
817 if (!args || args->dim != 1) | |
818 error("string expected for library name"); | |
819 else | |
820 { | |
821 Expression *e = (Expression *)args->data[0]; | |
822 | |
823 e = e->semantic(sc); | |
824 e = e->optimize(WANTvalue | WANTinterpret); | |
825 args->data[0] = (void *)e; | |
826 if (e->op != TOKstring) | |
827 error("string expected for library name, not '%s'", e->toChars()); | |
828 else if (global.params.verbose) | |
829 { | |
830 StringExp *se = (StringExp *)e; | |
831 char *name = (char *)mem.malloc(se->len + 1); | |
832 memcpy(name, se->string, se->len); | |
833 name[se->len] = 0; | |
834 printf("library %s\n", name); | |
835 mem.free(name); | |
836 } | |
837 } | |
838 goto Lnodecl; | |
839 } | |
840 #if IN_GCC | |
841 else if (ident == Id::GNU_asm) | |
842 { | |
843 if (! args || args->dim != 2) | |
844 error("identifier and string expected for asm name"); | |
845 else | |
846 { | |
847 Expression *e; | |
848 Declaration *d = NULL; | |
849 StringExp *s = NULL; | |
850 | |
851 e = (Expression *)args->data[0]; | |
852 e = e->semantic(sc); | |
853 if (e->op == TOKvar) | |
854 { | |
855 d = ((VarExp *)e)->var; | |
856 if (! d->isFuncDeclaration() && ! d->isVarDeclaration()) | |
857 d = NULL; | |
858 } | |
859 if (!d) | |
860 error("first argument of GNU_asm must be a function or variable declaration"); | |
861 | |
862 e = (Expression *)args->data[1]; | |
863 e = e->semantic(sc); | |
864 e = e->optimize(WANTvalue); | |
865 if (e->op == TOKstring && ((StringExp *)e)->sz == 1) | |
866 s = ((StringExp *)e); | |
867 else | |
868 error("second argument of GNU_asm must be a char string"); | |
869 | |
870 if (d && s) | |
871 d->c_ident = Lexer::idPool((char*) s->string); | |
872 } | |
873 goto Lnodecl; | |
874 } | |
875 #endif | |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
876 |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
877 // LDC |
159 | 878 #if IN_LLVM |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
879 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
880 // pragma(intrinsic, "string") { funcdecl(s) } |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
881 else if (ident == Id::intrinsic) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
882 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
883 Expression* expr = (Expression *)args->data[0]; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
884 expr = expr->semantic(sc); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
885 if (!args || args->dim != 1 || !parseStringExp(expr, arg1str)) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
886 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
887 error("requires exactly 1 string literal parameter"); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
888 fatal(); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
889 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
890 llvm_internal = LLVMintrinsic; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
891 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
892 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
893 // pragma(notypeinfo) { typedecl(s) } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
894 else if (ident == Id::no_typeinfo) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
895 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
896 if (args && args->dim > 0) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
897 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
898 error("takes no parameters"); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
899 fatal(); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
900 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
901 llvm_internal = LLVMno_typeinfo; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
902 } |
159 | 903 |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
904 // pragma(nomoduleinfo) ; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
905 else if (ident == Id::no_moduleinfo) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
906 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
907 if (args && args->dim > 0) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
908 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
909 error("takes no parameters"); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
910 fatal(); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
911 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
912 llvm_internal = LLVMno_moduleinfo; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
913 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
914 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
915 // pragma(alloca) { funcdecl(s) } |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
916 else if (ident == Id::Alloca) |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
917 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
918 if (args && args->dim > 0) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
919 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
920 error("takes no parameters"); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
921 fatal(); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
922 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
923 llvm_internal = LLVMalloca; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
924 } |
159 | 925 |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
926 // pragma(va_start) { templdecl(s) } |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
927 else if (ident == Id::vastart) |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
928 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
929 if (args && args->dim > 0) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
930 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
931 error("takes no parameters"); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
932 fatal(); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
933 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
934 llvm_internal = LLVMva_start; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
935 } |
159 | 936 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
937 // pragma(va_copy) { funcdecl(s) } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
938 else if (ident == Id::vacopy) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
939 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
940 if (args && args->dim > 0) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
941 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
942 error("takes no parameters"); |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
943 fatal(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
944 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
945 llvm_internal = LLVMva_copy; |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
946 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
947 |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
948 // pragma(va_end) { funcdecl(s) } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
949 else if (ident == Id::vaend) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
950 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
951 if (args && args->dim > 0) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
952 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
953 error("takes no parameters"); |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
954 fatal(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
955 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
956 llvm_internal = LLVMva_end; |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
957 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
958 |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
959 // pragma(va_arg) { templdecl(s) } |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
960 else if (ident == Id::vaarg) |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
961 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
962 if (args && args->dim > 0) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
963 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
964 error("takes no parameters"); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
965 fatal(); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
966 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
967 llvm_internal = LLVMva_arg; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
968 } |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
969 |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
970 // pragma(ldc, "string") { templdecl(s) } |
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
971 else if (ident == Id::ldc) |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
972 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
973 Expression* expr = (Expression *)args->data[0]; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
974 expr = expr->semantic(sc); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
975 if (!args || args->dim != 1 || !parseStringExp(expr, arg1str)) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
976 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
977 error("requires exactly 1 string literal parameter"); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
978 fatal(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
979 } |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
980 else if (arg1str == "verbose") |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
981 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
982 sc->module->llvmForceLogging = true; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
983 } |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
984 else |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
985 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
986 error("command '%s' invalid"); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
987 fatal(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
988 } |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
989 } |
159 | 990 |
1152
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
991 // pragma(llvm_inline_asm) { templdecl(s) } |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
992 else if (ident == Id::llvm_inline_asm) |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
993 { |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
994 if (args && args->dim > 0) |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
995 { |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
996 error("takes no parameters"); |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
997 fatal(); |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
998 } |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
999 llvm_internal = LLVMinline_asm; |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1000 } |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1001 |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
1002 #endif // LDC |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1003 |
986
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
876
diff
changeset
|
1004 else if (ignoreUnsupportedPragmas) |
159 | 1005 { |
1006 if (global.params.verbose) | |
1007 { | |
1008 /* Print unrecognized pragmas | |
1009 */ | |
1010 printf("pragma %s", ident->toChars()); | |
1011 if (args) | |
1012 { | |
1013 for (size_t i = 0; i < args->dim; i++) | |
1014 { | |
1015 Expression *e = (Expression *)args->data[i]; | |
1016 e = e->semantic(sc); | |
1017 e = e->optimize(WANTvalue | WANTinterpret); | |
1018 if (i == 0) | |
1019 printf(" ("); | |
1020 else | |
1021 printf(","); | |
1022 printf("%s", e->toChars()); | |
1023 } | |
1024 if (args->dim) | |
1025 printf(")"); | |
1026 } | |
1027 printf("\n"); | |
1028 } | |
1029 goto Lnodecl; | |
1030 } | |
1031 else | |
1032 error("unrecognized pragma(%s)", ident->toChars()); | |
1033 | |
1034 if (decl) | |
1035 { | |
1036 for (unsigned i = 0; i < decl->dim; i++) | |
1037 { | |
1038 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
1039 | |
1040 s->semantic(sc); | |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1041 |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
1042 // LDC |
159 | 1043 #if IN_LLVM |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1044 |
159 | 1045 if (llvm_internal) |
1046 { | |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1047 if (s->llvmInternal) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1048 { |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
1049 error("multiple LDC specific pragmas not allowed not affect the same declaration ('%s' at '%s')", s->toChars(), s->loc.toChars()); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1050 fatal(); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1051 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1052 switch(llvm_internal) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1053 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1054 case LLVMintrinsic: |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1055 if (FuncDeclaration* fd = s->isFuncDeclaration()) |
159 | 1056 { |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1057 fd->llvmInternal = llvm_internal; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1058 fd->intrinsicName = arg1str; |
723
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
716
diff
changeset
|
1059 fd->linkage = LINKintrinsic; |
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
716
diff
changeset
|
1060 ((TypeFunction*)fd->type)->linkage = LINKintrinsic; |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1061 } |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1062 else if (TemplateDeclaration* td = s->isTemplateDeclaration()) |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1063 { |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1064 td->llvmInternal = llvm_internal; |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1065 td->intrinsicName = arg1str; |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1066 } |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1067 else |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1068 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1069 error("only allowed on function declarations"); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1070 fatal(); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1071 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1072 break; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1073 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1074 case LLVMva_start: |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1075 case LLVMva_arg: |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1076 if (TemplateDeclaration* td = s->isTemplateDeclaration()) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1077 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1078 if (td->parameters->dim != 1) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1079 { |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1080 error("the '%s' pragma template must have exactly one template parameter", ident->toChars()); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1081 fatal(); |
159 | 1082 } |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1083 else if (!td->onemember) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1084 { |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1085 error("the '%s' pragma template must have exactly one member", ident->toChars()); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1086 fatal(); |
159 | 1087 } |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1088 else if (td->overnext || td->overroot) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1089 { |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1090 error("the '%s' pragma template must not be overloaded", ident->toChars()); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1091 fatal(); |
159 | 1092 } |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1093 td->llvmInternal = llvm_internal; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1094 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1095 else |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1096 { |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1097 error("the '%s' pragma is only allowed on template declarations", ident->toChars()); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1098 fatal(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1099 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1100 break; |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1101 |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1102 case LLVMva_copy: |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1103 case LLVMva_end: |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1104 if (FuncDeclaration* fd = s->isFuncDeclaration()) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1105 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1106 fd->llvmInternal = llvm_internal; |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1107 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1108 else |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1109 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1110 error("the '%s' pragma is only allowed on function declarations", ident->toChars()); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1111 fatal(); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1112 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1113 break; |
159 | 1114 |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1115 case LLVMno_typeinfo: |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1116 s->llvmInternal = llvm_internal; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1117 break; |
159 | 1118 |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1119 case LLVMalloca: |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1120 if (FuncDeclaration* fd = s->isFuncDeclaration()) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1121 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1122 fd->llvmInternal = llvm_internal; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1123 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1124 else |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1125 { |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1126 error("the '%s' pragma must only be used on function declarations of type 'void* function(uint nbytes)'", ident->toChars()); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1127 fatal(); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1128 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1129 break; |
159 | 1130 |
1152
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1131 case LLVMinline_asm: |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1132 if (TemplateDeclaration* td = s->isTemplateDeclaration()) |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1133 { |
1153
4454126b4345
Added support for single D type register return from __asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1152
diff
changeset
|
1134 if (td->parameters->dim > 1) |
1152
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1135 { |
1153
4454126b4345
Added support for single D type register return from __asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1152
diff
changeset
|
1136 error("the '%s' pragma template must have exactly zero or one template parameters", ident->toChars()); |
1152
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1137 fatal(); |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1138 } |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1139 else if (!td->onemember) |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1140 { |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1141 error("the '%s' pragma template must have exactly one member", ident->toChars()); |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1142 fatal(); |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1143 } |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1144 td->llvmInternal = llvm_internal; |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1145 } |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1146 else |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1147 { |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1148 error("the '%s' pragma is only allowed on template declarations", ident->toChars()); |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1149 fatal(); |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1150 } |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1151 break; |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1152 |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1153 default: |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
1154 warning("the LDC specific pragma '%s' is not yet implemented, ignoring", ident->toChars()); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1155 } |
159 | 1156 } |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1157 |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
1158 #endif // LDC |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
1159 |
159 | 1160 } |
1161 } | |
1162 return; | |
1163 | |
1164 Lnodecl: | |
1165 if (decl) | |
1166 error("pragma is missing closing ';'"); | |
1167 } | |
1168 | |
1169 int PragmaDeclaration::oneMember(Dsymbol **ps) | |
1170 { | |
1171 *ps = NULL; | |
1172 return TRUE; | |
1173 } | |
1174 | |
336 | 1175 const char *PragmaDeclaration::kind() |
159 | 1176 { |
1177 return "pragma"; | |
1178 } | |
1179 | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
1180 #if IN_DMD |
336 | 1181 void PragmaDeclaration::toObjFile(int multiobj) |
159 | 1182 { |
1183 if (ident == Id::lib) | |
1184 { | |
1185 assert(args && args->dim == 1); | |
1186 | |
1187 Expression *e = (Expression *)args->data[0]; | |
1188 | |
1189 assert(e->op == TOKstring); | |
1190 | |
1191 StringExp *se = (StringExp *)e; | |
1192 char *name = (char *)mem.malloc(se->len + 1); | |
1193 memcpy(name, se->string, se->len); | |
1194 name[se->len] = 0; | |
1195 obj_includelib(name); | |
1196 } | |
1195
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
1197 #if DMDV2 |
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
1198 else if (ident == Id::startaddress) |
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
1199 { |
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
1200 assert(args && args->dim == 1); |
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
1201 Expression *e = (Expression *)args->data[0]; |
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
1202 Dsymbol *sa = getDsymbol(e); |
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
1203 FuncDeclaration *f = sa->isFuncDeclaration(); |
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
1204 assert(f); |
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
1205 Symbol *s = f->toSymbol(); |
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
1206 obj_startaddress(s); |
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
1207 } |
e961851fb8be
Merged DMD 1.042.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1153
diff
changeset
|
1208 #endif |
336 | 1209 AttribDeclaration::toObjFile(multiobj); |
159 | 1210 } |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
1211 #endif |
159 | 1212 |
1213 void PragmaDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
1214 { | |
1215 buf->printf("pragma(%s", ident->toChars()); | |
1216 if (args) | |
1217 { | |
1218 for (size_t i = 0; i < args->dim; i++) | |
1219 { | |
1220 Expression *e = (Expression *)args->data[i]; | |
1221 | |
1222 buf->writestring(", "); | |
1223 e->toCBuffer(buf, hgs); | |
1224 } | |
1225 } | |
1226 buf->writestring(")"); | |
1227 AttribDeclaration::toCBuffer(buf, hgs); | |
1228 } | |
1229 | |
1230 | |
1231 /********************************* ConditionalDeclaration ****************************/ | |
1232 | |
1233 ConditionalDeclaration::ConditionalDeclaration(Condition *condition, Array *decl, Array *elsedecl) | |
1234 : AttribDeclaration(decl) | |
1235 { | |
1236 //printf("ConditionalDeclaration::ConditionalDeclaration()\n"); | |
1237 this->condition = condition; | |
1238 this->elsedecl = elsedecl; | |
1239 } | |
1240 | |
1241 Dsymbol *ConditionalDeclaration::syntaxCopy(Dsymbol *s) | |
1242 { | |
1243 ConditionalDeclaration *dd; | |
1244 | |
1245 assert(!s); | |
1246 dd = new ConditionalDeclaration(condition->syntaxCopy(), | |
1247 Dsymbol::arraySyntaxCopy(decl), | |
1248 Dsymbol::arraySyntaxCopy(elsedecl)); | |
1249 return dd; | |
1250 } | |
1251 | |
1252 | |
1253 int ConditionalDeclaration::oneMember(Dsymbol **ps) | |
1254 { | |
1255 //printf("ConditionalDeclaration::oneMember(), inc = %d\n", condition->inc); | |
1256 if (condition->inc) | |
1257 { | |
1258 Array *d = condition->include(NULL, NULL) ? decl : elsedecl; | |
1259 return Dsymbol::oneMembers(d, ps); | |
1260 } | |
1261 *ps = NULL; | |
1262 return TRUE; | |
1263 } | |
1264 | |
1265 void ConditionalDeclaration::emitComment(Scope *sc) | |
1266 { | |
1267 //printf("ConditionalDeclaration::emitComment(sc = %p)\n", sc); | |
1268 if (condition->inc) | |
1269 { | |
1270 AttribDeclaration::emitComment(sc); | |
1271 } | |
876
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1272 else if (sc->docbuf) |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1273 { |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1274 /* If generating doc comment, be careful because if we're inside |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1275 * a template, then include(NULL, NULL) will fail. |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1276 */ |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1277 Array *d = decl ? decl : elsedecl; |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1278 for (unsigned i = 0; i < d->dim; i++) |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1279 { Dsymbol *s = (Dsymbol *)d->data[i]; |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1280 s->emitComment(sc); |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1281 } |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1282 } |
159 | 1283 } |
1284 | |
1285 // Decide if 'then' or 'else' code should be included | |
1286 | |
1287 Array *ConditionalDeclaration::include(Scope *sc, ScopeDsymbol *sd) | |
1288 { | |
1289 //printf("ConditionalDeclaration::include()\n"); | |
1290 assert(condition); | |
1291 return condition->include(sc, sd) ? decl : elsedecl; | |
1292 } | |
1293 | |
1294 | |
1295 void ConditionalDeclaration::addComment(unsigned char *comment) | |
1296 { | |
1297 /* Because addComment is called by the parser, if we called | |
1298 * include() it would define a version before it was used. | |
1299 * But it's no problem to drill down to both decl and elsedecl, | |
1300 * so that's the workaround. | |
1301 */ | |
1302 | |
1303 if (comment) | |
1304 { | |
1305 Array *d = decl; | |
1306 | |
1307 for (int j = 0; j < 2; j++) | |
1308 { | |
1309 if (d) | |
1310 { | |
1311 for (unsigned i = 0; i < d->dim; i++) | |
1312 { Dsymbol *s; | |
1313 | |
1314 s = (Dsymbol *)d->data[i]; | |
1315 //printf("ConditionalDeclaration::addComment %s\n", s->toChars()); | |
1316 s->addComment(comment); | |
1317 } | |
1318 } | |
1319 d = elsedecl; | |
1320 } | |
1321 } | |
1322 } | |
1323 | |
1324 void ConditionalDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
1325 { | |
1326 condition->toCBuffer(buf, hgs); | |
1327 if (decl || elsedecl) | |
1328 { | |
1329 buf->writenl(); | |
1330 buf->writeByte('{'); | |
1331 buf->writenl(); | |
1332 if (decl) | |
1333 { | |
1334 for (unsigned i = 0; i < decl->dim; i++) | |
1335 { | |
1336 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
1337 | |
1338 buf->writestring(" "); | |
1339 s->toCBuffer(buf, hgs); | |
1340 } | |
1341 } | |
1342 buf->writeByte('}'); | |
1343 if (elsedecl) | |
1344 { | |
1345 buf->writenl(); | |
1346 buf->writestring("else"); | |
1347 buf->writenl(); | |
1348 buf->writeByte('{'); | |
1349 buf->writenl(); | |
1350 for (unsigned i = 0; i < elsedecl->dim; i++) | |
1351 { | |
1352 Dsymbol *s = (Dsymbol *)elsedecl->data[i]; | |
1353 | |
1354 buf->writestring(" "); | |
1355 s->toCBuffer(buf, hgs); | |
1356 } | |
1357 buf->writeByte('}'); | |
1358 } | |
1359 } | |
1360 else | |
1361 buf->writeByte(':'); | |
1362 buf->writenl(); | |
1363 } | |
1364 | |
1365 /***************************** StaticIfDeclaration ****************************/ | |
1366 | |
1367 StaticIfDeclaration::StaticIfDeclaration(Condition *condition, | |
1368 Array *decl, Array *elsedecl) | |
1369 : ConditionalDeclaration(condition, decl, elsedecl) | |
1370 { | |
1371 //printf("StaticIfDeclaration::StaticIfDeclaration()\n"); | |
1372 sd = NULL; | |
1373 addisdone = 0; | |
1374 } | |
1375 | |
1376 | |
1377 Dsymbol *StaticIfDeclaration::syntaxCopy(Dsymbol *s) | |
1378 { | |
1379 StaticIfDeclaration *dd; | |
1380 | |
1381 assert(!s); | |
1382 dd = new StaticIfDeclaration(condition->syntaxCopy(), | |
1383 Dsymbol::arraySyntaxCopy(decl), | |
1384 Dsymbol::arraySyntaxCopy(elsedecl)); | |
1385 return dd; | |
1386 } | |
1387 | |
1388 | |
1389 int StaticIfDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) | |
1390 { | |
336 | 1391 //printf("StaticIfDeclaration::addMember() '%s'\n",toChars()); |
159 | 1392 /* This is deferred until semantic(), so that |
1393 * expressions in the condition can refer to declarations | |
1394 * in the same scope, such as: | |
1395 * | |
1396 * template Foo(int i) | |
1397 * { | |
1398 * const int j = i + 1; | |
1399 * static if (j == 3) | |
1400 * const int k; | |
1401 * } | |
1402 */ | |
1403 this->sd = sd; | |
1404 int m = 0; | |
1405 | |
1406 if (memnum == 0) | |
1407 { m = AttribDeclaration::addMember(sc, sd, memnum); | |
1408 addisdone = 1; | |
1409 } | |
1410 return m; | |
1411 } | |
1412 | |
1413 | |
1414 void StaticIfDeclaration::semantic(Scope *sc) | |
1415 { | |
1416 Array *d = include(sc, sd); | |
1417 | |
336 | 1418 //printf("\tStaticIfDeclaration::semantic '%s', d = %p\n",toChars(), d); |
159 | 1419 if (d) |
1420 { | |
1421 if (!addisdone) | |
1422 { AttribDeclaration::addMember(sc, sd, 1); | |
1423 addisdone = 1; | |
1424 } | |
1425 | |
1426 for (unsigned i = 0; i < d->dim; i++) | |
1427 { | |
1428 Dsymbol *s = (Dsymbol *)d->data[i]; | |
1429 | |
1430 s->semantic(sc); | |
1431 } | |
1432 } | |
1433 } | |
1434 | |
336 | 1435 const char *StaticIfDeclaration::kind() |
159 | 1436 { |
1437 return "static if"; | |
1438 } | |
1439 | |
1440 | |
1441 /***************************** CompileDeclaration *****************************/ | |
1442 | |
1443 CompileDeclaration::CompileDeclaration(Loc loc, Expression *exp) | |
1444 : AttribDeclaration(NULL) | |
1445 { | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
846
diff
changeset
|
1446 //printf("CompileDeclaration(loc = %d)\n", loc.linnum); |
336 | 1447 this->loc = loc; |
159 | 1448 this->exp = exp; |
1449 this->sd = NULL; | |
336 | 1450 this->compiled = 0; |
159 | 1451 } |
1452 | |
1453 Dsymbol *CompileDeclaration::syntaxCopy(Dsymbol *s) | |
1454 { | |
1455 //printf("CompileDeclaration::syntaxCopy('%s')\n", toChars()); | |
1456 CompileDeclaration *sc = new CompileDeclaration(loc, exp->syntaxCopy()); | |
1457 return sc; | |
1458 } | |
1459 | |
1460 int CompileDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) | |
1461 { | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1462 //printf("CompileDeclaration::addMember(sc = %p, memnum = %d)\n", sc, memnum); |
159 | 1463 this->sd = sd; |
336 | 1464 if (memnum == 0) |
1465 { /* No members yet, so parse the mixin now | |
1466 */ | |
1467 compileIt(sc); | |
1468 memnum |= AttribDeclaration::addMember(sc, sd, memnum); | |
1469 compiled = 1; | |
1470 } | |
159 | 1471 return memnum; |
1472 } | |
1473 | |
336 | 1474 void CompileDeclaration::compileIt(Scope *sc) |
1475 { | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
846
diff
changeset
|
1476 //printf("CompileDeclaration::compileIt(loc = %d)\n", loc.linnum); |
336 | 1477 exp = exp->semantic(sc); |
1478 exp = resolveProperties(sc, exp); | |
1479 exp = exp->optimize(WANTvalue | WANTinterpret); | |
1480 if (exp->op != TOKstring) | |
1481 { exp->error("argument to mixin must be a string, not (%s)", exp->toChars()); | |
1482 } | |
1483 else | |
1484 { | |
1485 StringExp *se = (StringExp *)exp; | |
1486 se = se->toUTF8(sc); | |
1487 Parser p(sc->module, (unsigned char *)se->string, se->len, 0); | |
1488 p.loc = loc; | |
1489 p.nextToken(); | |
1490 decl = p.parseDeclDefs(0); | |
1491 if (p.token.value != TOKeof) | |
1492 exp->error("incomplete mixin declaration (%s)", se->toChars()); | |
1493 } | |
1494 } | |
1495 | |
159 | 1496 void CompileDeclaration::semantic(Scope *sc) |
1497 { | |
1498 //printf("CompileDeclaration::semantic()\n"); | |
336 | 1499 |
1500 if (!compiled) | |
1501 { | |
1502 compileIt(sc); | |
1503 AttribDeclaration::addMember(sc, sd, 0); | |
1504 compiled = 1; | |
159 | 1505 } |
1506 AttribDeclaration::semantic(sc); | |
1507 } | |
1508 | |
1509 void CompileDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
1510 { | |
1511 buf->writestring("mixin("); | |
1512 exp->toCBuffer(buf, hgs); | |
1513 buf->writestring(");"); | |
1514 buf->writenl(); | |
1515 } |