Mercurial > projects > ldc
annotate dmd/attrib.c @ 1152:521dd1626d76
Added initial support for raw LLVM inline asm.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Sat, 28 Mar 2009 06:32:06 +0100 |
parents | dbe4af57b240 |
children | 4454126b4345 |
rev | line source |
---|---|
159 | 1 |
2 // Compiler implementation of the D programming language | |
336 | 3 // Copyright (c) 1999-2008 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 | |
325 void StorageClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
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 int written = 0; | |
354 for (int i = 0; i < sizeof(table)/sizeof(table[0]); i++) | |
355 { | |
356 if (stc & table[i].stc) | |
357 { | |
358 if (written) | |
359 buf->writeByte(' '); | |
360 written = 1; | |
361 buf->writestring(Token::toChars(table[i].tok)); | |
362 } | |
363 } | |
364 | |
365 AttribDeclaration::toCBuffer(buf, hgs); | |
366 } | |
367 | |
368 /********************************* LinkDeclaration ****************************/ | |
369 | |
370 LinkDeclaration::LinkDeclaration(enum LINK p, Array *decl) | |
371 : AttribDeclaration(decl) | |
372 { | |
373 //printf("LinkDeclaration(linkage = %d, decl = %p)\n", p, decl); | |
374 linkage = p; | |
375 } | |
376 | |
377 Dsymbol *LinkDeclaration::syntaxCopy(Dsymbol *s) | |
378 { | |
379 LinkDeclaration *ld; | |
380 | |
381 assert(!s); | |
382 ld = new LinkDeclaration(linkage, Dsymbol::arraySyntaxCopy(decl)); | |
383 return ld; | |
384 } | |
385 | |
386 void LinkDeclaration::semantic(Scope *sc) | |
387 { | |
388 //printf("LinkDeclaration::semantic(linkage = %d, decl = %p)\n", linkage, decl); | |
389 if (decl) | |
390 { enum LINK linkage_save = sc->linkage; | |
391 | |
392 sc->linkage = linkage; | |
393 for (unsigned i = 0; i < decl->dim; i++) | |
394 { | |
395 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
396 | |
397 s->semantic(sc); | |
398 } | |
399 sc->linkage = linkage_save; | |
400 } | |
401 else | |
402 { | |
403 sc->linkage = linkage; | |
404 } | |
405 } | |
406 | |
407 void LinkDeclaration::semantic3(Scope *sc) | |
408 { | |
409 //printf("LinkDeclaration::semantic3(linkage = %d, decl = %p)\n", linkage, decl); | |
410 if (decl) | |
411 { enum LINK linkage_save = sc->linkage; | |
412 | |
413 sc->linkage = linkage; | |
414 for (unsigned i = 0; i < decl->dim; i++) | |
415 { | |
416 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
417 | |
418 s->semantic3(sc); | |
419 } | |
420 sc->linkage = linkage_save; | |
421 } | |
422 else | |
423 { | |
424 sc->linkage = linkage; | |
425 } | |
426 } | |
427 | |
428 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
|
429 { const char *p; |
159 | 430 |
431 switch (linkage) | |
432 { | |
433 case LINKd: p = "D"; break; | |
434 case LINKc: p = "C"; break; | |
435 case LINKcpp: p = "C++"; break; | |
436 case LINKwindows: p = "Windows"; break; | |
437 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
|
438 |
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
716
diff
changeset
|
439 // LDC |
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
716
diff
changeset
|
440 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
|
441 |
159 | 442 default: |
443 assert(0); | |
444 break; | |
445 } | |
446 buf->writestring("extern ("); | |
447 buf->writestring(p); | |
448 buf->writestring(") "); | |
449 AttribDeclaration::toCBuffer(buf, hgs); | |
450 } | |
451 | |
452 char *LinkDeclaration::toChars() | |
453 { | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
846
diff
changeset
|
454 return (char *)"extern ()"; |
159 | 455 } |
456 | |
457 /********************************* ProtDeclaration ****************************/ | |
458 | |
459 ProtDeclaration::ProtDeclaration(enum PROT p, Array *decl) | |
460 : AttribDeclaration(decl) | |
461 { | |
462 protection = p; | |
463 //printf("decl = %p\n", decl); | |
464 } | |
465 | |
466 Dsymbol *ProtDeclaration::syntaxCopy(Dsymbol *s) | |
467 { | |
468 ProtDeclaration *pd; | |
469 | |
470 assert(!s); | |
471 pd = new ProtDeclaration(protection, Dsymbol::arraySyntaxCopy(decl)); | |
472 return pd; | |
473 } | |
474 | |
475 void ProtDeclaration::semantic(Scope *sc) | |
476 { | |
477 if (decl) | |
478 { enum PROT protection_save = sc->protection; | |
479 int explicitProtection_save = sc->explicitProtection; | |
480 | |
481 sc->protection = protection; | |
482 sc->explicitProtection = 1; | |
483 for (unsigned i = 0; i < decl->dim; i++) | |
484 { | |
485 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
486 | |
487 s->semantic(sc); | |
488 } | |
489 sc->protection = protection_save; | |
490 sc->explicitProtection = explicitProtection_save; | |
491 } | |
492 else | |
493 { sc->protection = protection; | |
494 sc->explicitProtection = 1; | |
495 } | |
496 } | |
497 | |
498 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
|
499 { const char *p; |
159 | 500 |
501 switch (protection) | |
502 { | |
503 case PROTprivate: p = "private"; break; | |
504 case PROTpackage: p = "package"; break; | |
505 case PROTprotected: p = "protected"; break; | |
506 case PROTpublic: p = "public"; break; | |
507 case PROTexport: p = "export"; break; | |
508 default: | |
509 assert(0); | |
510 break; | |
511 } | |
512 buf->writestring(p); | |
513 AttribDeclaration::toCBuffer(buf, hgs); | |
514 } | |
515 | |
516 /********************************* AlignDeclaration ****************************/ | |
517 | |
710
20a5180f2e80
Make align(n), n != 1 an error.
Christian Kamm <kamm incasoftware de>
parents:
663
diff
changeset
|
518 AlignDeclaration::AlignDeclaration(Loc loc, unsigned sa, Array *decl) |
159 | 519 : AttribDeclaration(decl) |
520 { | |
710
20a5180f2e80
Make align(n), n != 1 an error.
Christian Kamm <kamm incasoftware de>
parents:
663
diff
changeset
|
521 this->loc = loc; |
159 | 522 salign = sa; |
523 } | |
524 | |
525 Dsymbol *AlignDeclaration::syntaxCopy(Dsymbol *s) | |
526 { | |
527 AlignDeclaration *ad; | |
528 | |
529 assert(!s); | |
710
20a5180f2e80
Make align(n), n != 1 an error.
Christian Kamm <kamm incasoftware de>
parents:
663
diff
changeset
|
530 ad = new AlignDeclaration(loc, salign, Dsymbol::arraySyntaxCopy(decl)); |
159 | 531 return ad; |
532 } | |
533 | |
534 void AlignDeclaration::semantic(Scope *sc) | |
535 { | |
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
|
536 // 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
|
537 // 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
|
538 // 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
|
539 |
159 | 540 //printf("\tAlignDeclaration::semantic '%s'\n",toChars()); |
541 if (decl) | |
542 { unsigned salign_save = sc->structalign; | |
543 | |
544 for (unsigned i = 0; i < decl->dim; i++) | |
545 { | |
546 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
547 | |
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
|
548 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
|
549 { |
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 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
|
551 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
|
552 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
|
553 } |
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 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
|
555 { |
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 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
|
557 } |
159 | 558 } |
559 sc->structalign = salign_save; | |
560 } | |
561 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
|
562 assert(0 && "what kind of align use triggers this?"); |
159 | 563 } |
564 | |
565 | |
566 void AlignDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
567 { | |
568 buf->printf("align (%d)", salign); | |
569 AttribDeclaration::toCBuffer(buf, hgs); | |
570 } | |
571 | |
572 /********************************* AnonDeclaration ****************************/ | |
573 | |
574 AnonDeclaration::AnonDeclaration(Loc loc, int isunion, Array *decl) | |
575 : AttribDeclaration(decl) | |
576 { | |
577 this->loc = loc; | |
578 this->isunion = isunion; | |
579 this->scope = NULL; | |
580 this->sem = 0; | |
581 } | |
582 | |
583 Dsymbol *AnonDeclaration::syntaxCopy(Dsymbol *s) | |
584 { | |
585 AnonDeclaration *ad; | |
586 | |
587 assert(!s); | |
588 ad = new AnonDeclaration(loc, isunion, Dsymbol::arraySyntaxCopy(decl)); | |
589 return ad; | |
590 } | |
591 | |
592 void AnonDeclaration::semantic(Scope *sc) | |
593 { | |
594 //printf("\tAnonDeclaration::semantic %s %p\n", isunion ? "union" : "struct", this); | |
595 | |
596 Scope *scx = NULL; | |
597 if (scope) | |
598 { sc = scope; | |
599 scx = scope; | |
600 scope = NULL; | |
601 } | |
602 | |
603 assert(sc->parent); | |
604 | |
605 Dsymbol *parent = sc->parent->pastMixin(); | |
606 AggregateDeclaration *ad = parent->isAggregateDeclaration(); | |
607 | |
608 if (!ad || (!ad->isStructDeclaration() && !ad->isClassDeclaration())) | |
609 { | |
610 error("can only be a part of an aggregate"); | |
611 return; | |
612 } | |
613 | |
614 if (decl) | |
615 { | |
616 AnonymousAggregateDeclaration aad; | |
617 int adisunion; | |
618 | |
619 if (sc->anonAgg) | |
620 { ad = sc->anonAgg; | |
621 adisunion = sc->inunion; | |
622 } | |
623 else | |
624 adisunion = ad->isUnionDeclaration() != NULL; | |
625 | |
626 // printf("\tsc->anonAgg = %p\n", sc->anonAgg); | |
627 // printf("\tad = %p\n", ad); | |
628 // printf("\taad = %p\n", &aad); | |
629 | |
630 sc = sc->push(); | |
631 sc->anonAgg = &aad; | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
632 sc->stc &= ~(STCauto | STCscope | STCstatic | STCtls); |
159 | 633 sc->inunion = isunion; |
634 sc->offset = 0; | |
635 sc->flags = 0; | |
636 aad.structalign = sc->structalign; | |
637 aad.parent = ad; | |
846
bc982f1ad106
Merged DMD 1.037 frontend
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
816
diff
changeset
|
638 |
159 | 639 for (unsigned i = 0; i < decl->dim; i++) |
640 { | |
641 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
642 | |
643 s->semantic(sc); | |
644 if (isunion) | |
645 sc->offset = 0; | |
646 if (aad.sizeok == 2) | |
647 { | |
648 break; | |
649 } | |
650 } | |
651 sc = sc->pop(); | |
652 | |
653 // If failed due to forward references, unwind and try again later | |
654 if (aad.sizeok == 2) | |
655 { | |
656 ad->sizeok = 2; | |
657 //printf("\tsetting ad->sizeok %p to 2\n", ad); | |
658 if (!sc->anonAgg) | |
659 { | |
660 scope = scx ? scx : new Scope(*sc); | |
661 scope->setNoFree(); | |
662 scope->module->addDeferredSemantic(this); | |
663 } | |
664 //printf("\tforward reference %p\n", this); | |
665 return; | |
666 } | |
667 if (sem == 0) | |
668 { Module::dprogress++; | |
669 sem = 1; | |
670 //printf("\tcompleted %p\n", this); | |
671 } | |
672 else | |
673 ;//printf("\talready completed %p\n", this); | |
674 | |
675 // 0 sized structs are set to 1 byte | |
676 if (aad.structsize == 0) | |
677 { | |
678 aad.structsize = 1; | |
679 aad.alignsize = 1; | |
680 } | |
681 | |
682 // Align size of anonymous aggregate | |
683 //printf("aad.structalign = %d, aad.alignsize = %d, sc->offset = %d\n", aad.structalign, aad.alignsize, sc->offset); | |
684 ad->alignmember(aad.structalign, aad.alignsize, &sc->offset); | |
685 //ad->structsize = sc->offset; | |
686 //printf("sc->offset = %d\n", sc->offset); | |
687 | |
688 // 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
|
689 //printf("\tadding members of aad (%p) to '%s'\n", &aad, ad->toChars()); |
159 | 690 for (unsigned i = 0; i < aad.fields.dim; i++) |
691 { | |
692 VarDeclaration *v = (VarDeclaration *)aad.fields.data[i]; | |
693 | |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
694 // LDC |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
695 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
|
696 |
159 | 697 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
|
698 |
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 // 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
|
700 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
|
701 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
|
702 |
159 | 703 ad->fields.push(v); |
704 } | |
705 | |
706 // Add size of aad to ad | |
707 if (adisunion) | |
708 { | |
709 if (aad.structsize > ad->structsize) | |
710 ad->structsize = aad.structsize; | |
711 sc->offset = 0; | |
712 } | |
713 else | |
714 { | |
715 ad->structsize = sc->offset + aad.structsize; | |
716 sc->offset = ad->structsize; | |
717 } | |
718 | |
719 if (ad->alignsize < aad.alignsize) | |
720 ad->alignsize = aad.alignsize; | |
721 } | |
722 } | |
723 | |
724 | |
725 void AnonDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
726 { | |
727 buf->printf(isunion ? "union" : "struct"); | |
728 buf->writestring("\n{\n"); | |
729 if (decl) | |
730 { | |
731 for (unsigned i = 0; i < decl->dim; i++) | |
732 { | |
733 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
734 | |
735 //buf->writestring(" "); | |
736 s->toCBuffer(buf, hgs); | |
737 } | |
738 } | |
739 buf->writestring("}\n"); | |
740 } | |
741 | |
336 | 742 const char *AnonDeclaration::kind() |
159 | 743 { |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
846
diff
changeset
|
744 return (isunion ? "anonymous union" : "anonymous struct"); |
159 | 745 } |
746 | |
747 /********************************* PragmaDeclaration ****************************/ | |
748 | |
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
|
749 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
|
750 { |
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 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
|
752 |
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 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
|
754 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
|
755 { |
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 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
|
757 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
|
758 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
|
759 } |
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 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
|
761 } |
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 |
159 | 763 PragmaDeclaration::PragmaDeclaration(Loc loc, Identifier *ident, Expressions *args, Array *decl) |
764 : AttribDeclaration(decl) | |
765 { | |
766 this->loc = loc; | |
767 this->ident = ident; | |
768 this->args = args; | |
769 } | |
770 | |
771 Dsymbol *PragmaDeclaration::syntaxCopy(Dsymbol *s) | |
772 { | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
773 //printf("PragmaDeclaration::syntaxCopy(%s)\n", toChars()); |
159 | 774 PragmaDeclaration *pd; |
775 | |
776 assert(!s); | |
777 pd = new PragmaDeclaration(loc, ident, | |
778 Expression::arraySyntaxCopy(args), Dsymbol::arraySyntaxCopy(decl)); | |
779 return pd; | |
780 } | |
781 | |
782 void PragmaDeclaration::semantic(Scope *sc) | |
783 { // Should be merged with PragmaStatement | |
784 | |
785 #if IN_LLVM | |
786 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
|
787 std::string arg1str; |
159 | 788 |
789 #endif | |
790 | |
791 //printf("\tPragmaDeclaration::semantic '%s'\n",toChars()); | |
792 if (ident == Id::msg) | |
793 { | |
794 if (args) | |
795 { | |
796 for (size_t i = 0; i < args->dim; i++) | |
797 { | |
798 Expression *e = (Expression *)args->data[i]; | |
799 | |
800 e = e->semantic(sc); | |
801 e = e->optimize(WANTvalue | WANTinterpret); | |
802 if (e->op == TOKstring) | |
803 { | |
804 StringExp *se = (StringExp *)e; | |
794
661384d6a936
Fix warnings on x86-64. By fvbommel.
Christian Kamm <kamm incasoftware de>
parents:
737
diff
changeset
|
805 fprintf(stdmsg, "%.*s", (int)se->len, (char*)se->string); |
159 | 806 } |
807 else | |
808 error("string expected for message, not '%s'", e->toChars()); | |
809 } | |
810 fprintf(stdmsg, "\n"); | |
811 } | |
812 goto Lnodecl; | |
813 } | |
814 else if (ident == Id::lib) | |
815 { | |
816 if (!args || args->dim != 1) | |
817 error("string expected for library name"); | |
818 else | |
819 { | |
820 Expression *e = (Expression *)args->data[0]; | |
821 | |
822 e = e->semantic(sc); | |
823 e = e->optimize(WANTvalue | WANTinterpret); | |
824 args->data[0] = (void *)e; | |
825 if (e->op != TOKstring) | |
826 error("string expected for library name, not '%s'", e->toChars()); | |
827 else if (global.params.verbose) | |
828 { | |
829 StringExp *se = (StringExp *)e; | |
830 char *name = (char *)mem.malloc(se->len + 1); | |
831 memcpy(name, se->string, se->len); | |
832 name[se->len] = 0; | |
833 printf("library %s\n", name); | |
834 mem.free(name); | |
835 } | |
836 } | |
837 goto Lnodecl; | |
838 } | |
839 #if IN_GCC | |
840 else if (ident == Id::GNU_asm) | |
841 { | |
842 if (! args || args->dim != 2) | |
843 error("identifier and string expected for asm name"); | |
844 else | |
845 { | |
846 Expression *e; | |
847 Declaration *d = NULL; | |
848 StringExp *s = NULL; | |
849 | |
850 e = (Expression *)args->data[0]; | |
851 e = e->semantic(sc); | |
852 if (e->op == TOKvar) | |
853 { | |
854 d = ((VarExp *)e)->var; | |
855 if (! d->isFuncDeclaration() && ! d->isVarDeclaration()) | |
856 d = NULL; | |
857 } | |
858 if (!d) | |
859 error("first argument of GNU_asm must be a function or variable declaration"); | |
860 | |
861 e = (Expression *)args->data[1]; | |
862 e = e->semantic(sc); | |
863 e = e->optimize(WANTvalue); | |
864 if (e->op == TOKstring && ((StringExp *)e)->sz == 1) | |
865 s = ((StringExp *)e); | |
866 else | |
867 error("second argument of GNU_asm must be a char string"); | |
868 | |
869 if (d && s) | |
870 d->c_ident = Lexer::idPool((char*) s->string); | |
871 } | |
872 goto Lnodecl; | |
873 } | |
874 #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
|
875 |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
876 // LDC |
159 | 877 #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
|
878 |
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
|
879 // 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
|
880 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
|
881 { |
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 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
|
883 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
|
884 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
|
885 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
886 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
|
887 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
|
888 } |
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 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
|
890 } |
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 // 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
|
893 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
|
894 { |
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 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
|
896 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
897 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
|
898 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
|
899 } |
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 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
|
901 } |
159 | 902 |
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
|
903 // 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
|
904 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
|
905 { |
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 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
|
907 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
908 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
|
909 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
|
910 } |
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 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
|
912 } |
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 // 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
|
915 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
|
916 { |
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 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
|
918 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
919 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
|
920 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
|
921 } |
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 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
|
923 } |
159 | 924 |
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
|
925 // 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
|
926 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
|
927 { |
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 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
|
929 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
930 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
|
931 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
|
932 } |
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 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
|
934 } |
159 | 935 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
936 // 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
|
937 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
|
938 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
939 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
|
940 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
941 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
|
942 fatal(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
943 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
944 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
|
945 } |
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 // 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
|
948 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
|
949 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
950 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
|
951 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
952 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
|
953 fatal(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
954 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
955 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
|
956 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
957 |
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
|
958 // 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
|
959 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
|
960 { |
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 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
|
962 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
963 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
|
964 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
|
965 } |
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 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
|
967 } |
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
|
968 |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
969 // pragma(ldc, "string") { templdecl(s) } |
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
970 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
|
971 { |
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 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
|
973 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
|
974 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
|
975 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
976 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
|
977 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
|
978 } |
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 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
|
980 { |
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 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
|
982 } |
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 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
|
984 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
985 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
|
986 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
|
987 } |
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 } |
159 | 989 |
1152
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
990 // 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
|
991 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
|
992 { |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
993 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
|
994 { |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
995 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
|
996 fatal(); |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
997 } |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
998 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
|
999 } |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1000 |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
1001 #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
|
1002 |
986
a8cb25d478c4
Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
876
diff
changeset
|
1003 else if (ignoreUnsupportedPragmas) |
159 | 1004 { |
1005 if (global.params.verbose) | |
1006 { | |
1007 /* Print unrecognized pragmas | |
1008 */ | |
1009 printf("pragma %s", ident->toChars()); | |
1010 if (args) | |
1011 { | |
1012 for (size_t i = 0; i < args->dim; i++) | |
1013 { | |
1014 Expression *e = (Expression *)args->data[i]; | |
1015 e = e->semantic(sc); | |
1016 e = e->optimize(WANTvalue | WANTinterpret); | |
1017 if (i == 0) | |
1018 printf(" ("); | |
1019 else | |
1020 printf(","); | |
1021 printf("%s", e->toChars()); | |
1022 } | |
1023 if (args->dim) | |
1024 printf(")"); | |
1025 } | |
1026 printf("\n"); | |
1027 } | |
1028 goto Lnodecl; | |
1029 } | |
1030 else | |
1031 error("unrecognized pragma(%s)", ident->toChars()); | |
1032 | |
1033 if (decl) | |
1034 { | |
1035 for (unsigned i = 0; i < decl->dim; i++) | |
1036 { | |
1037 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
1038 | |
1039 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
|
1040 |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
1041 // LDC |
159 | 1042 #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
|
1043 |
159 | 1044 if (llvm_internal) |
1045 { | |
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
|
1046 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
|
1047 { |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
1048 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
|
1049 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
|
1050 } |
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 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
|
1052 { |
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 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
|
1054 if (FuncDeclaration* fd = s->isFuncDeclaration()) |
159 | 1055 { |
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
|
1056 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
|
1057 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
|
1058 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
|
1059 ((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
|
1060 } |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1061 else if (TemplateDeclaration* td = s->isTemplateDeclaration()) |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1062 { |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1063 td->llvmInternal = llvm_internal; |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1064 td->intrinsicName = arg1str; |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1065 } |
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
|
1066 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
|
1067 { |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1068 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
|
1069 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
|
1070 } |
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 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
|
1072 |
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 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
|
1074 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
|
1075 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
|
1076 { |
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 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
|
1078 { |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1079 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
|
1080 fatal(); |
159 | 1081 } |
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
|
1082 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
|
1083 { |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1084 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
|
1085 fatal(); |
159 | 1086 } |
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
|
1087 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
|
1088 { |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1089 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
|
1090 fatal(); |
159 | 1091 } |
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
|
1092 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
|
1093 } |
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 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
|
1095 { |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1096 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
|
1097 fatal(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1098 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1099 break; |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1100 |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1101 case LLVMva_copy: |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1102 case LLVMva_end: |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1103 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
|
1104 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1105 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
|
1106 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1107 else |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1108 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1109 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
|
1110 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
|
1111 } |
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 break; |
159 | 1113 |
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
|
1114 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
|
1115 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
|
1116 break; |
159 | 1117 |
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
|
1118 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
|
1119 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
|
1120 { |
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 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
|
1122 } |
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 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
|
1124 { |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
1125 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
|
1126 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
|
1127 } |
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 break; |
159 | 1129 |
1152
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1130 case LLVMinline_asm: |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1131 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
|
1132 { |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1133 if (td->parameters->dim != 0) |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1134 { |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1135 error("the '%s' pragma template must have exactly zero template parameters", ident->toChars()); |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1136 fatal(); |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1137 } |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1138 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
|
1139 { |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1140 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
|
1141 fatal(); |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1142 } |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1143 else if (td->overnext || td->overroot) |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1144 { |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1145 error("the '%s' pragma template must not be overloaded", ident->toChars()); |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1146 fatal(); |
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 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
|
1149 } |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1150 else |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1151 { |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1152 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
|
1153 fatal(); |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1154 } |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1155 break; |
521dd1626d76
Added initial support for raw LLVM inline asm.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
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 default: |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
1158 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
|
1159 } |
159 | 1160 } |
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
|
1161 |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
1162 #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
|
1163 |
159 | 1164 } |
1165 } | |
1166 return; | |
1167 | |
1168 Lnodecl: | |
1169 if (decl) | |
1170 error("pragma is missing closing ';'"); | |
1171 } | |
1172 | |
1173 int PragmaDeclaration::oneMember(Dsymbol **ps) | |
1174 { | |
1175 *ps = NULL; | |
1176 return TRUE; | |
1177 } | |
1178 | |
336 | 1179 const char *PragmaDeclaration::kind() |
159 | 1180 { |
1181 return "pragma"; | |
1182 } | |
1183 | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
1184 #if IN_DMD |
336 | 1185 void PragmaDeclaration::toObjFile(int multiobj) |
159 | 1186 { |
1187 if (ident == Id::lib) | |
1188 { | |
1189 assert(args && args->dim == 1); | |
1190 | |
1191 Expression *e = (Expression *)args->data[0]; | |
1192 | |
1193 assert(e->op == TOKstring); | |
1194 | |
1195 StringExp *se = (StringExp *)e; | |
1196 char *name = (char *)mem.malloc(se->len + 1); | |
1197 memcpy(name, se->string, se->len); | |
1198 name[se->len] = 0; | |
1199 obj_includelib(name); | |
1200 } | |
336 | 1201 AttribDeclaration::toObjFile(multiobj); |
159 | 1202 } |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
1203 #endif |
159 | 1204 |
1205 void PragmaDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
1206 { | |
1207 buf->printf("pragma(%s", ident->toChars()); | |
1208 if (args) | |
1209 { | |
1210 for (size_t i = 0; i < args->dim; i++) | |
1211 { | |
1212 Expression *e = (Expression *)args->data[i]; | |
1213 | |
1214 buf->writestring(", "); | |
1215 e->toCBuffer(buf, hgs); | |
1216 } | |
1217 } | |
1218 buf->writestring(")"); | |
1219 AttribDeclaration::toCBuffer(buf, hgs); | |
1220 } | |
1221 | |
1222 | |
1223 /********************************* ConditionalDeclaration ****************************/ | |
1224 | |
1225 ConditionalDeclaration::ConditionalDeclaration(Condition *condition, Array *decl, Array *elsedecl) | |
1226 : AttribDeclaration(decl) | |
1227 { | |
1228 //printf("ConditionalDeclaration::ConditionalDeclaration()\n"); | |
1229 this->condition = condition; | |
1230 this->elsedecl = elsedecl; | |
1231 } | |
1232 | |
1233 Dsymbol *ConditionalDeclaration::syntaxCopy(Dsymbol *s) | |
1234 { | |
1235 ConditionalDeclaration *dd; | |
1236 | |
1237 assert(!s); | |
1238 dd = new ConditionalDeclaration(condition->syntaxCopy(), | |
1239 Dsymbol::arraySyntaxCopy(decl), | |
1240 Dsymbol::arraySyntaxCopy(elsedecl)); | |
1241 return dd; | |
1242 } | |
1243 | |
1244 | |
1245 int ConditionalDeclaration::oneMember(Dsymbol **ps) | |
1246 { | |
1247 //printf("ConditionalDeclaration::oneMember(), inc = %d\n", condition->inc); | |
1248 if (condition->inc) | |
1249 { | |
1250 Array *d = condition->include(NULL, NULL) ? decl : elsedecl; | |
1251 return Dsymbol::oneMembers(d, ps); | |
1252 } | |
1253 *ps = NULL; | |
1254 return TRUE; | |
1255 } | |
1256 | |
1257 void ConditionalDeclaration::emitComment(Scope *sc) | |
1258 { | |
1259 //printf("ConditionalDeclaration::emitComment(sc = %p)\n", sc); | |
1260 if (condition->inc) | |
1261 { | |
1262 AttribDeclaration::emitComment(sc); | |
1263 } | |
876
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1264 else if (sc->docbuf) |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1265 { |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1266 /* 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
|
1267 * 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
|
1268 */ |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1269 Array *d = decl ? decl : elsedecl; |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1270 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
|
1271 { Dsymbol *s = (Dsymbol *)d->data[i]; |
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
1272 s->emitComment(sc); |
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 } |
159 | 1275 } |
1276 | |
1277 // Decide if 'then' or 'else' code should be included | |
1278 | |
1279 Array *ConditionalDeclaration::include(Scope *sc, ScopeDsymbol *sd) | |
1280 { | |
1281 //printf("ConditionalDeclaration::include()\n"); | |
1282 assert(condition); | |
1283 return condition->include(sc, sd) ? decl : elsedecl; | |
1284 } | |
1285 | |
1286 | |
1287 void ConditionalDeclaration::addComment(unsigned char *comment) | |
1288 { | |
1289 /* Because addComment is called by the parser, if we called | |
1290 * include() it would define a version before it was used. | |
1291 * But it's no problem to drill down to both decl and elsedecl, | |
1292 * so that's the workaround. | |
1293 */ | |
1294 | |
1295 if (comment) | |
1296 { | |
1297 Array *d = decl; | |
1298 | |
1299 for (int j = 0; j < 2; j++) | |
1300 { | |
1301 if (d) | |
1302 { | |
1303 for (unsigned i = 0; i < d->dim; i++) | |
1304 { Dsymbol *s; | |
1305 | |
1306 s = (Dsymbol *)d->data[i]; | |
1307 //printf("ConditionalDeclaration::addComment %s\n", s->toChars()); | |
1308 s->addComment(comment); | |
1309 } | |
1310 } | |
1311 d = elsedecl; | |
1312 } | |
1313 } | |
1314 } | |
1315 | |
1316 void ConditionalDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
1317 { | |
1318 condition->toCBuffer(buf, hgs); | |
1319 if (decl || elsedecl) | |
1320 { | |
1321 buf->writenl(); | |
1322 buf->writeByte('{'); | |
1323 buf->writenl(); | |
1324 if (decl) | |
1325 { | |
1326 for (unsigned i = 0; i < decl->dim; i++) | |
1327 { | |
1328 Dsymbol *s = (Dsymbol *)decl->data[i]; | |
1329 | |
1330 buf->writestring(" "); | |
1331 s->toCBuffer(buf, hgs); | |
1332 } | |
1333 } | |
1334 buf->writeByte('}'); | |
1335 if (elsedecl) | |
1336 { | |
1337 buf->writenl(); | |
1338 buf->writestring("else"); | |
1339 buf->writenl(); | |
1340 buf->writeByte('{'); | |
1341 buf->writenl(); | |
1342 for (unsigned i = 0; i < elsedecl->dim; i++) | |
1343 { | |
1344 Dsymbol *s = (Dsymbol *)elsedecl->data[i]; | |
1345 | |
1346 buf->writestring(" "); | |
1347 s->toCBuffer(buf, hgs); | |
1348 } | |
1349 buf->writeByte('}'); | |
1350 } | |
1351 } | |
1352 else | |
1353 buf->writeByte(':'); | |
1354 buf->writenl(); | |
1355 } | |
1356 | |
1357 /***************************** StaticIfDeclaration ****************************/ | |
1358 | |
1359 StaticIfDeclaration::StaticIfDeclaration(Condition *condition, | |
1360 Array *decl, Array *elsedecl) | |
1361 : ConditionalDeclaration(condition, decl, elsedecl) | |
1362 { | |
1363 //printf("StaticIfDeclaration::StaticIfDeclaration()\n"); | |
1364 sd = NULL; | |
1365 addisdone = 0; | |
1366 } | |
1367 | |
1368 | |
1369 Dsymbol *StaticIfDeclaration::syntaxCopy(Dsymbol *s) | |
1370 { | |
1371 StaticIfDeclaration *dd; | |
1372 | |
1373 assert(!s); | |
1374 dd = new StaticIfDeclaration(condition->syntaxCopy(), | |
1375 Dsymbol::arraySyntaxCopy(decl), | |
1376 Dsymbol::arraySyntaxCopy(elsedecl)); | |
1377 return dd; | |
1378 } | |
1379 | |
1380 | |
1381 int StaticIfDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) | |
1382 { | |
336 | 1383 //printf("StaticIfDeclaration::addMember() '%s'\n",toChars()); |
159 | 1384 /* This is deferred until semantic(), so that |
1385 * expressions in the condition can refer to declarations | |
1386 * in the same scope, such as: | |
1387 * | |
1388 * template Foo(int i) | |
1389 * { | |
1390 * const int j = i + 1; | |
1391 * static if (j == 3) | |
1392 * const int k; | |
1393 * } | |
1394 */ | |
1395 this->sd = sd; | |
1396 int m = 0; | |
1397 | |
1398 if (memnum == 0) | |
1399 { m = AttribDeclaration::addMember(sc, sd, memnum); | |
1400 addisdone = 1; | |
1401 } | |
1402 return m; | |
1403 } | |
1404 | |
1405 | |
1406 void StaticIfDeclaration::semantic(Scope *sc) | |
1407 { | |
1408 Array *d = include(sc, sd); | |
1409 | |
336 | 1410 //printf("\tStaticIfDeclaration::semantic '%s', d = %p\n",toChars(), d); |
159 | 1411 if (d) |
1412 { | |
1413 if (!addisdone) | |
1414 { AttribDeclaration::addMember(sc, sd, 1); | |
1415 addisdone = 1; | |
1416 } | |
1417 | |
1418 for (unsigned i = 0; i < d->dim; i++) | |
1419 { | |
1420 Dsymbol *s = (Dsymbol *)d->data[i]; | |
1421 | |
1422 s->semantic(sc); | |
1423 } | |
1424 } | |
1425 } | |
1426 | |
336 | 1427 const char *StaticIfDeclaration::kind() |
159 | 1428 { |
1429 return "static if"; | |
1430 } | |
1431 | |
1432 | |
1433 /***************************** CompileDeclaration *****************************/ | |
1434 | |
1435 CompileDeclaration::CompileDeclaration(Loc loc, Expression *exp) | |
1436 : AttribDeclaration(NULL) | |
1437 { | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
846
diff
changeset
|
1438 //printf("CompileDeclaration(loc = %d)\n", loc.linnum); |
336 | 1439 this->loc = loc; |
159 | 1440 this->exp = exp; |
1441 this->sd = NULL; | |
336 | 1442 this->compiled = 0; |
159 | 1443 } |
1444 | |
1445 Dsymbol *CompileDeclaration::syntaxCopy(Dsymbol *s) | |
1446 { | |
1447 //printf("CompileDeclaration::syntaxCopy('%s')\n", toChars()); | |
1448 CompileDeclaration *sc = new CompileDeclaration(loc, exp->syntaxCopy()); | |
1449 return sc; | |
1450 } | |
1451 | |
1452 int CompileDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) | |
1453 { | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
986
diff
changeset
|
1454 //printf("CompileDeclaration::addMember(sc = %p, memnum = %d)\n", sc, memnum); |
159 | 1455 this->sd = sd; |
336 | 1456 if (memnum == 0) |
1457 { /* No members yet, so parse the mixin now | |
1458 */ | |
1459 compileIt(sc); | |
1460 memnum |= AttribDeclaration::addMember(sc, sd, memnum); | |
1461 compiled = 1; | |
1462 } | |
159 | 1463 return memnum; |
1464 } | |
1465 | |
336 | 1466 void CompileDeclaration::compileIt(Scope *sc) |
1467 { | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
846
diff
changeset
|
1468 //printf("CompileDeclaration::compileIt(loc = %d)\n", loc.linnum); |
336 | 1469 exp = exp->semantic(sc); |
1470 exp = resolveProperties(sc, exp); | |
1471 exp = exp->optimize(WANTvalue | WANTinterpret); | |
1472 if (exp->op != TOKstring) | |
1473 { exp->error("argument to mixin must be a string, not (%s)", exp->toChars()); | |
1474 } | |
1475 else | |
1476 { | |
1477 StringExp *se = (StringExp *)exp; | |
1478 se = se->toUTF8(sc); | |
1479 Parser p(sc->module, (unsigned char *)se->string, se->len, 0); | |
1480 p.loc = loc; | |
1481 p.nextToken(); | |
1482 decl = p.parseDeclDefs(0); | |
1483 if (p.token.value != TOKeof) | |
1484 exp->error("incomplete mixin declaration (%s)", se->toChars()); | |
1485 } | |
1486 } | |
1487 | |
159 | 1488 void CompileDeclaration::semantic(Scope *sc) |
1489 { | |
1490 //printf("CompileDeclaration::semantic()\n"); | |
336 | 1491 |
1492 if (!compiled) | |
1493 { | |
1494 compileIt(sc); | |
1495 AttribDeclaration::addMember(sc, sd, 0); | |
1496 compiled = 1; | |
159 | 1497 } |
1498 AttribDeclaration::semantic(sc); | |
1499 } | |
1500 | |
1501 void CompileDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
1502 { | |
1503 buf->writestring("mixin("); | |
1504 exp->toCBuffer(buf, hgs); | |
1505 buf->writestring(");"); | |
1506 buf->writenl(); | |
1507 } |