Mercurial > projects > ldc
annotate dmd/declaration.h @ 920:545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Fixed align N; in asm blocks.
Fixed inreg parameter passing on x86 for ref/out params.
Removed support for lazy initialization of function local static variables, I have no idea why I ever implemented this, it's not in the D spec, and DMD doesn't support it :P
Some of the global variable related changes might cause minor regressions, but they should be easily fixable.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 03 Feb 2009 08:54:57 +0100 |
parents | 29c0d1194033 |
children | 03d7c4aac654 |
rev | line source |
---|---|
159 | 1 |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2008 by Digital Mars | |
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 #ifndef DMD_DECLARATION_H | |
12 #define DMD_DECLARATION_H | |
13 | |
14 #ifdef __DMC__ | |
15 #pragma once | |
16 #endif /* __DMC__ */ | |
17 | |
18 #include <set> | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
19 #include <map> |
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:
378
diff
changeset
|
20 #include <string> |
159 | 21 |
22 #include "dsymbol.h" | |
23 #include "lexer.h" | |
24 #include "mtype.h" | |
25 | |
26 struct Expression; | |
27 struct Statement; | |
28 struct LabelDsymbol; | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
29 struct LabelStatement; |
159 | 30 struct Initializer; |
31 struct Module; | |
32 struct InlineScanState; | |
33 struct ForeachStatement; | |
34 struct FuncDeclaration; | |
35 struct ExpInitializer; | |
36 struct StructDeclaration; | |
37 struct TupleType; | |
38 struct InterState; | |
39 struct IRState; | |
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:
732
diff
changeset
|
40 struct AnonDeclaration; |
159 | 41 |
42 enum PROT; | |
43 enum LINK; | |
44 enum TOK; | |
45 enum MATCH; | |
46 | |
47 enum STC | |
48 { | |
49 STCundefined = 0, | |
50 STCstatic = 1, | |
51 STCextern = 2, | |
52 STCconst = 4, | |
53 STCfinal = 8, | |
54 STCabstract = 0x10, | |
55 STCparameter = 0x20, | |
56 STCfield = 0x40, | |
57 STCoverride = 0x80, | |
58 STCauto = 0x100, | |
59 STCsynchronized = 0x200, | |
60 STCdeprecated = 0x400, | |
61 STCin = 0x800, // in parameter | |
62 STCout = 0x1000, // out parameter | |
63 STClazy = 0x2000, // lazy parameter | |
64 STCforeach = 0x4000, // variable for foreach loop | |
65 STCcomdat = 0x8000, // should go into COMDAT record | |
66 STCvariadic = 0x10000, // variadic function argument | |
67 STCctorinit = 0x20000, // can only be set inside constructor | |
68 STCtemplateparameter = 0x40000, // template parameter | |
69 STCscope = 0x80000, // template parameter | |
70 STCinvariant = 0x100000, | |
71 STCref = 0x200000, | |
72 STCinit = 0x400000, // has explicit initializer | |
73 STCmanifest = 0x800000, // manifest constant | |
74 STCnodtor = 0x1000000, // don't run destructor | |
75 STCnothrow = 0x2000000, // never throws exceptions | |
76 STCpure = 0x4000000, // pure function | |
77 STCtls = 0x8000000, // thread local | |
336 | 78 STCalias = 0x10000000, // alias parameter |
159 | 79 }; |
80 | |
81 struct Match | |
82 { | |
83 int count; // number of matches found | |
84 MATCH last; // match level of lastf | |
85 FuncDeclaration *lastf; // last matching function we found | |
86 FuncDeclaration *nextf; // current matching function | |
87 FuncDeclaration *anyf; // pick a func, any func, to use for error recovery | |
88 }; | |
89 | |
90 void overloadResolveX(Match *m, FuncDeclaration *f, Expressions *arguments); | |
91 int overloadApply(FuncDeclaration *fstart, | |
92 int (*fp)(void *, FuncDeclaration *), | |
93 void *param); | |
94 | |
95 /**************************************************************/ | |
96 | |
97 struct Declaration : Dsymbol | |
98 { | |
99 Type *type; | |
100 Type *originalType; // before semantic analysis | |
101 unsigned storage_class; | |
102 enum PROT protection; | |
103 enum LINK linkage; | |
104 | |
105 Declaration(Identifier *id); | |
106 void semantic(Scope *sc); | |
336 | 107 const char *kind(); |
159 | 108 unsigned size(Loc loc); |
109 void checkModify(Loc loc, Scope *sc, Type *t); | |
110 | |
111 void emitComment(Scope *sc); | |
112 void toDocBuffer(OutBuffer *buf); | |
113 | |
114 char *mangle(); | |
115 int isStatic() { return storage_class & STCstatic; } | |
116 virtual int isStaticConstructor(); | |
117 virtual int isStaticDestructor(); | |
118 virtual int isDelete(); | |
119 virtual int isDataseg(); | |
120 virtual int isCodeseg(); | |
121 int isCtorinit() { return storage_class & STCctorinit; } | |
122 int isFinal() { return storage_class & STCfinal; } | |
123 int isAbstract() { return storage_class & STCabstract; } | |
124 int isConst() { return storage_class & STCconst; } | |
125 int isInvariant() { return 0; } | |
126 int isAuto() { return storage_class & STCauto; } | |
127 int isScope() { return storage_class & (STCscope | STCauto); } | |
128 int isSynchronized() { return storage_class & STCsynchronized; } | |
129 int isParameter() { return storage_class & STCparameter; } | |
130 int isDeprecated() { return storage_class & STCdeprecated; } | |
131 int isOverride() { return storage_class & STCoverride; } | |
132 | |
133 int isIn() { return storage_class & STCin; } | |
134 int isOut() { return storage_class & STCout; } | |
135 int isRef() { return storage_class & STCref; } | |
136 | |
137 enum PROT prot(); | |
138 | |
139 Declaration *isDeclaration() { return this; } | |
140 | |
141 // llvm | |
751
dc8b8b7ea0c1
Fix compile-time warnings. Adjust include in d-asm-i386.
Christian Kamm <kamm incasoftware de>
parents:
737
diff
changeset
|
142 virtual void toObjFile(int unused = 0); // compile to .obj file |
159 | 143 }; |
144 | |
145 /**************************************************************/ | |
146 | |
147 struct TupleDeclaration : Declaration | |
148 { | |
149 Objects *objects; | |
150 int isexp; // 1: expression tuple | |
151 | |
152 TypeTuple *tupletype; // !=NULL if this is a type tuple | |
153 | |
154 TupleDeclaration(Loc loc, Identifier *ident, Objects *objects); | |
155 Dsymbol *syntaxCopy(Dsymbol *); | |
336 | 156 const char *kind(); |
159 | 157 Type *getType(); |
158 int needThis(); | |
159 | |
160 TupleDeclaration *isTupleDeclaration() { return this; } | |
732
6aeaef263289
Fixed tuple fields, thanx downs
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
703
diff
changeset
|
161 |
6aeaef263289
Fixed tuple fields, thanx downs
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
703
diff
changeset
|
162 // LDC we need this |
6aeaef263289
Fixed tuple fields, thanx downs
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
703
diff
changeset
|
163 void toObjFile(int multiobj); // compile to .obj file |
159 | 164 }; |
165 | |
166 /**************************************************************/ | |
167 | |
168 struct TypedefDeclaration : Declaration | |
169 { | |
170 Type *basetype; | |
171 Initializer *init; | |
172 int sem; // 0: semantic() has not been run | |
173 // 1: semantic() is in progress | |
174 // 2: semantic() has been run | |
175 // 3: semantic2() has been run | |
176 int inuse; // used to detect typedef cycles | |
177 | |
178 TypedefDeclaration(Loc loc, Identifier *ident, Type *basetype, Initializer *init); | |
179 Dsymbol *syntaxCopy(Dsymbol *); | |
180 void semantic(Scope *sc); | |
181 void semantic2(Scope *sc); | |
182 char *mangle(); | |
336 | 183 const char *kind(); |
159 | 184 Type *getType(); |
185 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
186 #ifdef _DH | |
187 Type *htype; | |
188 Type *hbasetype; | |
189 #endif | |
190 | |
191 void toDocBuffer(OutBuffer *buf); | |
192 | |
336 | 193 void toObjFile(int multiobj); // compile to .obj file |
159 | 194 void toDebug(); |
195 int cvMember(unsigned char *p); | |
196 | |
197 TypedefDeclaration *isTypedefDeclaration() { return this; } | |
198 | |
199 Symbol *sinit; | |
200 Symbol *toInitializer(); | |
201 }; | |
202 | |
203 /**************************************************************/ | |
204 | |
205 struct AliasDeclaration : Declaration | |
206 { | |
207 Dsymbol *aliassym; | |
208 Dsymbol *overnext; // next in overload list | |
209 int inSemantic; | |
210 | |
211 AliasDeclaration(Loc loc, Identifier *ident, Type *type); | |
212 AliasDeclaration(Loc loc, Identifier *ident, Dsymbol *s); | |
213 Dsymbol *syntaxCopy(Dsymbol *); | |
214 void semantic(Scope *sc); | |
215 int overloadInsert(Dsymbol *s); | |
336 | 216 const char *kind(); |
159 | 217 Type *getType(); |
218 Dsymbol *toAlias(); | |
219 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
220 #ifdef _DH | |
221 Type *htype; | |
222 Dsymbol *haliassym; | |
223 #endif | |
224 | |
225 void toDocBuffer(OutBuffer *buf); | |
226 | |
227 AliasDeclaration *isAliasDeclaration() { return this; } | |
228 }; | |
229 | |
230 /**************************************************************/ | |
231 | |
232 struct VarDeclaration : Declaration | |
233 { | |
234 Initializer *init; | |
235 unsigned offset; | |
236 int noauto; // no auto semantics | |
237 int nestedref; // referenced by a lexically nested function | |
238 int inuse; | |
239 int ctorinit; // it has been initialized in a ctor | |
240 int onstack; // 1: it has been allocated on the stack | |
241 // 2: on stack, run destructor anyway | |
242 int canassign; // it can be assigned to | |
243 Dsymbol *aliassym; // if redone as alias to another symbol | |
244 Expression *value; // when interpreting, this is the value | |
245 // (NULL if value not determinable) | |
246 | |
247 VarDeclaration(Loc loc, Type *t, Identifier *id, Initializer *init); | |
248 Dsymbol *syntaxCopy(Dsymbol *); | |
249 void semantic(Scope *sc); | |
250 void semantic2(Scope *sc); | |
336 | 251 const char *kind(); |
159 | 252 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
253 #ifdef _DH | |
254 Type *htype; | |
255 Initializer *hinit; | |
256 #endif | |
257 int needThis(); | |
258 int isImportedSymbol(); | |
259 int isDataseg(); | |
260 int hasPointers(); | |
261 Expression *callAutoDtor(); | |
262 ExpInitializer *getExpInitializer(); | |
263 void checkCtorConstInit(); | |
264 void checkNestedReference(Scope *sc, Loc loc); | |
265 Dsymbol *toAlias(); | |
266 | |
267 Symbol *toSymbol(); | |
336 | 268 void toObjFile(int multiobj); // compile to .obj file |
159 | 269 int cvMember(unsigned char *p); |
270 | |
271 // Eliminate need for dynamic_cast | |
272 VarDeclaration *isVarDeclaration() { return (VarDeclaration *)this; } | |
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:
732
diff
changeset
|
273 |
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:
732
diff
changeset
|
274 // 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:
732
diff
changeset
|
275 AnonDeclaration* anonDecl; |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
751
diff
changeset
|
276 unsigned offset2; |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
913
diff
changeset
|
277 bool nakedUse; |
159 | 278 }; |
279 | |
280 /**************************************************************/ | |
281 | |
913
29c0d1194033
Fix #198 and #199 by making CTFE on static struct initializers work.
Christian Kamm <kamm incasoftware de>
parents:
846
diff
changeset
|
282 // LDC uses this to denote static struct initializers |
159 | 283 |
913
29c0d1194033
Fix #198 and #199 by making CTFE on static struct initializers work.
Christian Kamm <kamm incasoftware de>
parents:
846
diff
changeset
|
284 struct StaticStructInitDeclaration : Declaration |
159 | 285 { |
286 StructDeclaration *dsym; | |
287 | |
913
29c0d1194033
Fix #198 and #199 by making CTFE on static struct initializers work.
Christian Kamm <kamm incasoftware de>
parents:
846
diff
changeset
|
288 StaticStructInitDeclaration(Loc loc, StructDeclaration *dsym); |
159 | 289 |
290 Symbol *toSymbol(); | |
291 | |
292 // Eliminate need for dynamic_cast | |
913
29c0d1194033
Fix #198 and #199 by making CTFE on static struct initializers work.
Christian Kamm <kamm incasoftware de>
parents:
846
diff
changeset
|
293 StaticStructInitDeclaration *isStaticStructInitDeclaration() { return (StaticStructInitDeclaration *)this; } |
159 | 294 }; |
295 | |
296 struct ClassInfoDeclaration : VarDeclaration | |
297 { | |
298 ClassDeclaration *cd; | |
299 | |
300 ClassInfoDeclaration(ClassDeclaration *cd); | |
301 Dsymbol *syntaxCopy(Dsymbol *); | |
302 void semantic(Scope *sc); | |
303 | |
304 void emitComment(Scope *sc); | |
305 | |
306 Symbol *toSymbol(); | |
307 | |
308 ClassInfoDeclaration* isClassInfoDeclaration() { return this; } | |
309 }; | |
310 | |
311 struct ModuleInfoDeclaration : VarDeclaration | |
312 { | |
313 Module *mod; | |
314 | |
315 ModuleInfoDeclaration(Module *mod); | |
316 Dsymbol *syntaxCopy(Dsymbol *); | |
317 void semantic(Scope *sc); | |
318 | |
319 void emitComment(Scope *sc); | |
320 | |
321 Symbol *toSymbol(); | |
322 }; | |
323 | |
324 struct TypeInfoDeclaration : VarDeclaration | |
325 { | |
326 Type *tinfo; | |
327 | |
328 TypeInfoDeclaration(Type *tinfo, int internal); | |
329 Dsymbol *syntaxCopy(Dsymbol *); | |
330 void semantic(Scope *sc); | |
331 | |
332 void emitComment(Scope *sc); | |
333 | |
334 Symbol *toSymbol(); | |
336 | 335 void toObjFile(int multiobj); // compile to .obj file |
159 | 336 virtual void toDt(dt_t **pdt); |
337 | |
338 virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return this; } | |
339 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
340 // LDC |
159 | 341 virtual void llvmDeclare(); |
342 virtual void llvmDefine(); | |
343 }; | |
344 | |
345 struct TypeInfoStructDeclaration : TypeInfoDeclaration | |
346 { | |
347 TypeInfoStructDeclaration(Type *tinfo); | |
348 | |
349 void toDt(dt_t **pdt); | |
350 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
351 // LDC |
159 | 352 void llvmDeclare(); |
353 void llvmDefine(); | |
354 }; | |
355 | |
356 struct TypeInfoClassDeclaration : TypeInfoDeclaration | |
357 { | |
358 TypeInfoClassDeclaration(Type *tinfo); | |
359 | |
360 void toDt(dt_t **pdt); | |
361 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
362 // LDC |
159 | 363 void llvmDeclare(); |
364 void llvmDefine(); | |
365 }; | |
366 | |
367 struct TypeInfoInterfaceDeclaration : TypeInfoDeclaration | |
368 { | |
369 TypeInfoInterfaceDeclaration(Type *tinfo); | |
370 | |
371 void toDt(dt_t **pdt); | |
372 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
373 // LDC |
159 | 374 void llvmDeclare(); |
375 void llvmDefine(); | |
376 }; | |
377 | |
378 struct TypeInfoTypedefDeclaration : TypeInfoDeclaration | |
379 { | |
380 TypeInfoTypedefDeclaration(Type *tinfo); | |
381 | |
382 void toDt(dt_t **pdt); | |
383 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
384 // LDC |
159 | 385 void llvmDeclare(); |
386 void llvmDefine(); | |
387 }; | |
388 | |
389 struct TypeInfoPointerDeclaration : TypeInfoDeclaration | |
390 { | |
391 TypeInfoPointerDeclaration(Type *tinfo); | |
392 | |
393 void toDt(dt_t **pdt); | |
394 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
395 // LDC |
159 | 396 void llvmDeclare(); |
397 void llvmDefine(); | |
398 }; | |
399 | |
400 struct TypeInfoArrayDeclaration : TypeInfoDeclaration | |
401 { | |
402 TypeInfoArrayDeclaration(Type *tinfo); | |
403 | |
404 void toDt(dt_t **pdt); | |
405 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
406 // LDC |
159 | 407 void llvmDeclare(); |
408 void llvmDefine(); | |
409 }; | |
410 | |
411 struct TypeInfoStaticArrayDeclaration : TypeInfoDeclaration | |
412 { | |
413 TypeInfoStaticArrayDeclaration(Type *tinfo); | |
414 | |
415 void toDt(dt_t **pdt); | |
416 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
417 // LDC |
159 | 418 void llvmDeclare(); |
419 void llvmDefine(); | |
420 }; | |
421 | |
422 struct TypeInfoAssociativeArrayDeclaration : TypeInfoDeclaration | |
423 { | |
424 TypeInfoAssociativeArrayDeclaration(Type *tinfo); | |
425 | |
426 void toDt(dt_t **pdt); | |
427 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
428 // LDC |
159 | 429 void llvmDeclare(); |
430 void llvmDefine(); | |
431 }; | |
432 | |
433 struct TypeInfoEnumDeclaration : TypeInfoDeclaration | |
434 { | |
435 TypeInfoEnumDeclaration(Type *tinfo); | |
436 | |
437 void toDt(dt_t **pdt); | |
438 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
439 // LDC |
159 | 440 void llvmDeclare(); |
441 void llvmDefine(); | |
442 }; | |
443 | |
444 struct TypeInfoFunctionDeclaration : TypeInfoDeclaration | |
445 { | |
446 TypeInfoFunctionDeclaration(Type *tinfo); | |
447 | |
448 void toDt(dt_t **pdt); | |
449 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
450 // LDC |
159 | 451 void llvmDeclare(); |
452 void llvmDefine(); | |
453 }; | |
454 | |
455 struct TypeInfoDelegateDeclaration : TypeInfoDeclaration | |
456 { | |
457 TypeInfoDelegateDeclaration(Type *tinfo); | |
458 | |
459 void toDt(dt_t **pdt); | |
460 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
461 // LDC |
159 | 462 void llvmDeclare(); |
463 void llvmDefine(); | |
464 }; | |
465 | |
466 struct TypeInfoTupleDeclaration : TypeInfoDeclaration | |
467 { | |
468 TypeInfoTupleDeclaration(Type *tinfo); | |
469 | |
470 void toDt(dt_t **pdt); | |
471 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
472 // LDC |
159 | 473 void llvmDeclare(); |
474 void llvmDefine(); | |
475 }; | |
476 | |
336 | 477 #if DMDV2 |
478 struct TypeInfoConstDeclaration : TypeInfoDeclaration | |
479 { | |
480 TypeInfoConstDeclaration(Type *tinfo); | |
481 | |
482 void toDt(dt_t **pdt); | |
483 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
484 // LDC |
336 | 485 void llvmDeclare(); |
486 void llvmDefine(); | |
487 }; | |
488 | |
489 struct TypeInfoInvariantDeclaration : TypeInfoDeclaration | |
490 { | |
491 TypeInfoInvariantDeclaration(Type *tinfo); | |
492 | |
493 void toDt(dt_t **pdt); | |
494 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
495 // LDC |
336 | 496 void llvmDeclare(); |
497 void llvmDefine(); | |
498 }; | |
499 #endif | |
500 | |
501 /**************************************************************/ | |
502 | |
159 | 503 struct ThisDeclaration : VarDeclaration |
504 { | |
505 ThisDeclaration(Type *t); | |
506 Dsymbol *syntaxCopy(Dsymbol *); | |
507 }; | |
508 | |
509 enum ILS | |
510 { | |
511 ILSuninitialized, // not computed yet | |
512 ILSno, // cannot inline | |
513 ILSyes, // can inline | |
514 }; | |
515 | |
516 /**************************************************************/ | |
336 | 517 #if DMDV2 |
159 | 518 |
519 enum BUILTIN | |
520 { | |
521 BUILTINunknown = -1, // not known if this is a builtin | |
522 BUILTINnot, // this is not a builtin | |
523 BUILTINsin, // std.math.sin | |
524 BUILTINcos, // std.math.cos | |
525 BUILTINtan, // std.math.tan | |
526 BUILTINsqrt, // std.math.sqrt | |
527 BUILTINfabs, // std.math.fabs | |
528 }; | |
529 | |
530 Expression *eval_builtin(enum BUILTIN builtin, Expressions *arguments); | |
531 | |
532 #endif | |
533 | |
534 struct FuncDeclaration : Declaration | |
535 { | |
536 Array *fthrows; // Array of Type's of exceptions (not used) | |
537 Statement *frequire; | |
538 Statement *fensure; | |
539 Statement *fbody; | |
540 | |
541 Identifier *outId; // identifier for out statement | |
542 VarDeclaration *vresult; // variable corresponding to outId | |
543 LabelDsymbol *returnLabel; // where the return goes | |
544 | |
545 DsymbolTable *localsymtab; // used to prevent symbols in different | |
546 // scopes from having the same name | |
547 VarDeclaration *vthis; // 'this' parameter (member and nested) | |
548 VarDeclaration *v_arguments; // '_arguments' parameter | |
549 #if IN_GCC | |
550 VarDeclaration *v_argptr; // '_argptr' variable | |
551 #endif | |
552 Dsymbols *parameters; // Array of VarDeclaration's for parameters | |
553 DsymbolTable *labtab; // statement label symbol table | |
554 Declaration *overnext; // next in overload list | |
555 Loc endloc; // location of closing curly bracket | |
556 int vtblIndex; // for member functions, index into vtbl[] | |
557 int naked; // !=0 if naked | |
558 int inlineAsm; // !=0 if has inline assembler | |
559 ILS inlineStatus; | |
560 int inlineNest; // !=0 if nested inline | |
561 int cantInterpret; // !=0 if cannot interpret function | |
562 int semanticRun; // !=0 if semantic3() had been run | |
563 // this function's frame ptr | |
564 ForeachStatement *fes; // if foreach body, this is the foreach | |
565 int introducing; // !=0 if 'introducing' function | |
566 Type *tintro; // if !=NULL, then this is the type | |
567 // of the 'introducing' function | |
568 // this one is overriding | |
569 int inferRetType; // !=0 if return type is to be inferred | |
570 Scope *scope; // !=NULL means context to use | |
571 | |
572 // Things that should really go into Scope | |
573 int hasReturnExp; // 1 if there's a return exp; statement | |
574 // 2 if there's a throw statement | |
575 // 4 if there's an assert(0) | |
576 // 8 if there's inline asm | |
577 | |
578 // Support for NRVO (named return value optimization) | |
579 int nrvo_can; // !=0 means we can do it | |
580 VarDeclaration *nrvo_var; // variable to replace with shidden | |
581 Symbol *shidden; // hidden pointer passed to function | |
582 | |
336 | 583 #if DMDV2 |
159 | 584 enum BUILTIN builtin; // set if this is a known, builtin |
585 // function we can evaluate at compile | |
586 // time | |
587 | |
588 int tookAddressOf; // set if someone took the address of | |
589 // this function | |
590 Dsymbols closureVars; // local variables in this function | |
591 // which are referenced by nested | |
592 // functions | |
593 #else | |
594 int nestedFrameRef; // !=0 if nested variables referenced | |
595 #endif | |
596 | |
597 FuncDeclaration(Loc loc, Loc endloc, Identifier *id, enum STC storage_class, Type *type); | |
598 Dsymbol *syntaxCopy(Dsymbol *); | |
599 void semantic(Scope *sc); | |
600 void semantic2(Scope *sc); | |
601 void semantic3(Scope *sc); | |
602 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
603 void bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
604 int overrides(FuncDeclaration *fd); | |
605 int findVtblIndex(Array *vtbl, int dim); | |
606 int overloadInsert(Dsymbol *s); | |
607 FuncDeclaration *overloadExactMatch(Type *t); | |
608 FuncDeclaration *overloadResolve(Loc loc, Expressions *arguments); | |
609 LabelDsymbol *searchLabel(Identifier *ident); | |
610 AggregateDeclaration *isThis(); | |
611 AggregateDeclaration *isMember2(); | |
612 int getLevel(Loc loc, FuncDeclaration *fd); // lexical nesting level difference | |
613 void appendExp(Expression *e); | |
614 void appendState(Statement *s); | |
615 char *mangle(); | |
616 int isMain(); | |
617 int isWinMain(); | |
618 int isDllMain(); | |
619 int isExport(); | |
620 int isImportedSymbol(); | |
621 int isAbstract(); | |
622 int isCodeseg(); | |
623 virtual int isNested(); | |
624 int needThis(); | |
625 virtual int isVirtual(); | |
846
bc982f1ad106
Merged DMD 1.037 frontend
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
797
diff
changeset
|
626 virtual int isFinal(); |
159 | 627 virtual int addPreInvariant(); |
628 virtual int addPostInvariant(); | |
629 Expression *interpret(InterState *istate, Expressions *arguments); | |
630 void inlineScan(); | |
631 int canInline(int hasthis, int hdrscan = 0); | |
632 Expression *doInline(InlineScanState *iss, Expression *ethis, Array *arguments); | |
336 | 633 const char *kind(); |
159 | 634 void toDocBuffer(OutBuffer *buf); |
635 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
636 // LDC: give argument types to runtime functions |
378
d8234836b40f
Get rid of runTimeHack and instead add proper argument info to the frontend
Christian Kamm <kamm incasoftware de>
parents:
336
diff
changeset
|
637 static FuncDeclaration *genCfunc(Arguments *args, Type *treturn, char *name); |
d8234836b40f
Get rid of runTimeHack and instead add proper argument info to the frontend
Christian Kamm <kamm incasoftware de>
parents:
336
diff
changeset
|
638 static FuncDeclaration *genCfunc(Arguments *args, Type *treturn, Identifier *id); |
159 | 639 |
640 Symbol *toSymbol(); | |
641 Symbol *toThunkSymbol(int offset); // thunk version | |
336 | 642 void toObjFile(int multiobj); // compile to .obj file |
159 | 643 int cvMember(unsigned char *p); |
644 | |
645 FuncDeclaration *isFuncDeclaration() { return this; } | |
646 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
647 // LDC stuff |
639
8aebdf56c455
Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
648 |
8aebdf56c455
Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
649 // vars declared in this function that nested funcs reference |
8aebdf56c455
Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
650 // is this is not empty, nestedFrameRef is set and these VarDecls |
8aebdf56c455
Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
651 // probably have nestedref set too, see VarDeclaration::checkNestedReference |
159 | 652 std::set<VarDeclaration*> nestedVars; |
639
8aebdf56c455
Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
653 |
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:
378
diff
changeset
|
654 std::string intrinsicName; |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
655 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
656 bool isIntrinsic(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
657 bool isVaIntrinsic(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
658 |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
659 // we keep our own table of label statements as LabelDsymbolS |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
660 // don't always carry their corresponding statement along ... |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
661 typedef std::map<const char*, LabelStatement*> LabelMap; |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
662 LabelMap labmap; |
703
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
663 |
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
664 // if this is an array operation it gets a little special attention |
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
665 bool isArrayOp; |
159 | 666 }; |
667 | |
668 struct FuncAliasDeclaration : FuncDeclaration | |
669 { | |
670 FuncDeclaration *funcalias; | |
671 | |
672 FuncAliasDeclaration(FuncDeclaration *funcalias); | |
673 | |
674 FuncAliasDeclaration *isFuncAliasDeclaration() { return this; } | |
336 | 675 const char *kind(); |
159 | 676 Symbol *toSymbol(); |
677 }; | |
678 | |
679 struct FuncLiteralDeclaration : FuncDeclaration | |
680 { | |
681 enum TOK tok; // TOKfunction or TOKdelegate | |
682 | |
683 FuncLiteralDeclaration(Loc loc, Loc endloc, Type *type, enum TOK tok, | |
684 ForeachStatement *fes); | |
685 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
686 Dsymbol *syntaxCopy(Dsymbol *); | |
687 int isNested(); | |
336 | 688 int isVirtual(); |
159 | 689 |
690 FuncLiteralDeclaration *isFuncLiteralDeclaration() { return this; } | |
336 | 691 const char *kind(); |
159 | 692 }; |
693 | |
694 struct CtorDeclaration : FuncDeclaration | |
695 { Arguments *arguments; | |
696 int varargs; | |
697 | |
698 CtorDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs); | |
699 Dsymbol *syntaxCopy(Dsymbol *); | |
700 void semantic(Scope *sc); | |
701 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
336 | 702 const char *kind(); |
159 | 703 char *toChars(); |
704 int isVirtual(); | |
705 int addPreInvariant(); | |
706 int addPostInvariant(); | |
707 void toDocBuffer(OutBuffer *buf); | |
708 | |
709 CtorDeclaration *isCtorDeclaration() { return this; } | |
710 }; | |
711 | |
336 | 712 #if DMDV2 |
713 struct PostBlitDeclaration : FuncDeclaration | |
714 { | |
715 PostBlitDeclaration(Loc loc, Loc endloc); | |
716 PostBlitDeclaration(Loc loc, Loc endloc, Identifier *id); | |
717 Dsymbol *syntaxCopy(Dsymbol *); | |
718 void semantic(Scope *sc); | |
719 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
720 int isVirtual(); | |
721 int addPreInvariant(); | |
722 int addPostInvariant(); | |
723 int overloadInsert(Dsymbol *s); | |
724 void emitComment(Scope *sc); | |
725 | |
726 PostBlitDeclaration *isPostBlitDeclaration() { return this; } | |
727 }; | |
728 #endif | |
729 | |
159 | 730 struct DtorDeclaration : FuncDeclaration |
731 { | |
732 DtorDeclaration(Loc loc, Loc endloc); | |
733 DtorDeclaration(Loc loc, Loc endloc, Identifier *id); | |
734 Dsymbol *syntaxCopy(Dsymbol *); | |
735 void semantic(Scope *sc); | |
736 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
737 int isVirtual(); | |
738 int addPreInvariant(); | |
739 int addPostInvariant(); | |
740 int overloadInsert(Dsymbol *s); | |
741 void emitComment(Scope *sc); | |
742 | |
743 DtorDeclaration *isDtorDeclaration() { return this; } | |
744 }; | |
745 | |
746 struct StaticCtorDeclaration : FuncDeclaration | |
747 { | |
748 StaticCtorDeclaration(Loc loc, Loc endloc); | |
749 Dsymbol *syntaxCopy(Dsymbol *); | |
750 void semantic(Scope *sc); | |
751 AggregateDeclaration *isThis(); | |
752 int isStaticConstructor(); | |
753 int isVirtual(); | |
754 int addPreInvariant(); | |
755 int addPostInvariant(); | |
756 void emitComment(Scope *sc); | |
757 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
758 | |
759 StaticCtorDeclaration *isStaticCtorDeclaration() { return this; } | |
760 }; | |
761 | |
762 struct StaticDtorDeclaration : FuncDeclaration | |
336 | 763 { VarDeclaration *vgate; // 'gate' variable |
764 | |
159 | 765 StaticDtorDeclaration(Loc loc, Loc endloc); |
766 Dsymbol *syntaxCopy(Dsymbol *); | |
767 void semantic(Scope *sc); | |
768 AggregateDeclaration *isThis(); | |
769 int isStaticDestructor(); | |
770 int isVirtual(); | |
771 int addPreInvariant(); | |
772 int addPostInvariant(); | |
773 void emitComment(Scope *sc); | |
774 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
775 | |
776 StaticDtorDeclaration *isStaticDtorDeclaration() { return this; } | |
777 }; | |
778 | |
779 struct InvariantDeclaration : FuncDeclaration | |
780 { | |
781 InvariantDeclaration(Loc loc, Loc endloc); | |
782 Dsymbol *syntaxCopy(Dsymbol *); | |
783 void semantic(Scope *sc); | |
784 int isVirtual(); | |
785 int addPreInvariant(); | |
786 int addPostInvariant(); | |
787 void emitComment(Scope *sc); | |
788 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
789 | |
790 InvariantDeclaration *isInvariantDeclaration() { return this; } | |
791 }; | |
792 | |
793 | |
794 struct UnitTestDeclaration : FuncDeclaration | |
795 { | |
796 UnitTestDeclaration(Loc loc, Loc endloc); | |
797 Dsymbol *syntaxCopy(Dsymbol *); | |
798 void semantic(Scope *sc); | |
799 AggregateDeclaration *isThis(); | |
800 int isVirtual(); | |
801 int addPreInvariant(); | |
802 int addPostInvariant(); | |
803 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
804 | |
805 UnitTestDeclaration *isUnitTestDeclaration() { return this; } | |
806 }; | |
807 | |
808 struct NewDeclaration : FuncDeclaration | |
809 { Arguments *arguments; | |
810 int varargs; | |
811 | |
812 NewDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs); | |
813 Dsymbol *syntaxCopy(Dsymbol *); | |
814 void semantic(Scope *sc); | |
815 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
336 | 816 const char *kind(); |
159 | 817 int isVirtual(); |
818 int addPreInvariant(); | |
819 int addPostInvariant(); | |
820 | |
821 NewDeclaration *isNewDeclaration() { return this; } | |
822 }; | |
823 | |
824 | |
825 struct DeleteDeclaration : FuncDeclaration | |
826 { Arguments *arguments; | |
827 | |
828 DeleteDeclaration(Loc loc, Loc endloc, Arguments *arguments); | |
829 Dsymbol *syntaxCopy(Dsymbol *); | |
830 void semantic(Scope *sc); | |
831 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
336 | 832 const char *kind(); |
159 | 833 int isDelete(); |
834 int isVirtual(); | |
835 int addPreInvariant(); | |
836 int addPostInvariant(); | |
837 #ifdef _DH | |
838 DeleteDeclaration *isDeleteDeclaration() { return this; } | |
839 #endif | |
840 }; | |
841 | |
842 #endif /* DMD_DECLARATION_H */ |