Mercurial > projects > ldc
annotate dmd/declaration.h @ 913:29c0d1194033
Fix #198 and #199 by making CTFE on static struct initializers work.
Renamed SymbolDeclaration to StaticStructInitDeclaration to make its usage clearer.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 01 Feb 2009 20:20:56 +0100 |
parents | bc982f1ad106 |
children | 545f54041d91 |
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; |
159 | 277 }; |
278 | |
279 /**************************************************************/ | |
280 | |
913
29c0d1194033
Fix #198 and #199 by making CTFE on static struct initializers work.
Christian Kamm <kamm incasoftware de>
parents:
846
diff
changeset
|
281 // LDC uses this to denote static struct initializers |
159 | 282 |
913
29c0d1194033
Fix #198 and #199 by making CTFE on static struct initializers work.
Christian Kamm <kamm incasoftware de>
parents:
846
diff
changeset
|
283 struct StaticStructInitDeclaration : Declaration |
159 | 284 { |
285 StructDeclaration *dsym; | |
286 | |
913
29c0d1194033
Fix #198 and #199 by making CTFE on static struct initializers work.
Christian Kamm <kamm incasoftware de>
parents:
846
diff
changeset
|
287 StaticStructInitDeclaration(Loc loc, StructDeclaration *dsym); |
159 | 288 |
289 Symbol *toSymbol(); | |
290 | |
291 // 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
|
292 StaticStructInitDeclaration *isStaticStructInitDeclaration() { return (StaticStructInitDeclaration *)this; } |
159 | 293 }; |
294 | |
295 struct ClassInfoDeclaration : VarDeclaration | |
296 { | |
297 ClassDeclaration *cd; | |
298 | |
299 ClassInfoDeclaration(ClassDeclaration *cd); | |
300 Dsymbol *syntaxCopy(Dsymbol *); | |
301 void semantic(Scope *sc); | |
302 | |
303 void emitComment(Scope *sc); | |
304 | |
305 Symbol *toSymbol(); | |
306 | |
307 ClassInfoDeclaration* isClassInfoDeclaration() { return this; } | |
308 }; | |
309 | |
310 struct ModuleInfoDeclaration : VarDeclaration | |
311 { | |
312 Module *mod; | |
313 | |
314 ModuleInfoDeclaration(Module *mod); | |
315 Dsymbol *syntaxCopy(Dsymbol *); | |
316 void semantic(Scope *sc); | |
317 | |
318 void emitComment(Scope *sc); | |
319 | |
320 Symbol *toSymbol(); | |
321 }; | |
322 | |
323 struct TypeInfoDeclaration : VarDeclaration | |
324 { | |
325 Type *tinfo; | |
326 | |
327 TypeInfoDeclaration(Type *tinfo, int internal); | |
328 Dsymbol *syntaxCopy(Dsymbol *); | |
329 void semantic(Scope *sc); | |
330 | |
331 void emitComment(Scope *sc); | |
332 | |
333 Symbol *toSymbol(); | |
336 | 334 void toObjFile(int multiobj); // compile to .obj file |
159 | 335 virtual void toDt(dt_t **pdt); |
336 | |
337 virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return this; } | |
338 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
339 // LDC |
159 | 340 virtual void llvmDeclare(); |
341 virtual void llvmDefine(); | |
342 }; | |
343 | |
344 struct TypeInfoStructDeclaration : TypeInfoDeclaration | |
345 { | |
346 TypeInfoStructDeclaration(Type *tinfo); | |
347 | |
348 void toDt(dt_t **pdt); | |
349 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
350 // LDC |
159 | 351 void llvmDeclare(); |
352 void llvmDefine(); | |
353 }; | |
354 | |
355 struct TypeInfoClassDeclaration : TypeInfoDeclaration | |
356 { | |
357 TypeInfoClassDeclaration(Type *tinfo); | |
358 | |
359 void toDt(dt_t **pdt); | |
360 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
361 // LDC |
159 | 362 void llvmDeclare(); |
363 void llvmDefine(); | |
364 }; | |
365 | |
366 struct TypeInfoInterfaceDeclaration : TypeInfoDeclaration | |
367 { | |
368 TypeInfoInterfaceDeclaration(Type *tinfo); | |
369 | |
370 void toDt(dt_t **pdt); | |
371 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
372 // LDC |
159 | 373 void llvmDeclare(); |
374 void llvmDefine(); | |
375 }; | |
376 | |
377 struct TypeInfoTypedefDeclaration : TypeInfoDeclaration | |
378 { | |
379 TypeInfoTypedefDeclaration(Type *tinfo); | |
380 | |
381 void toDt(dt_t **pdt); | |
382 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
383 // LDC |
159 | 384 void llvmDeclare(); |
385 void llvmDefine(); | |
386 }; | |
387 | |
388 struct TypeInfoPointerDeclaration : TypeInfoDeclaration | |
389 { | |
390 TypeInfoPointerDeclaration(Type *tinfo); | |
391 | |
392 void toDt(dt_t **pdt); | |
393 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
394 // LDC |
159 | 395 void llvmDeclare(); |
396 void llvmDefine(); | |
397 }; | |
398 | |
399 struct TypeInfoArrayDeclaration : TypeInfoDeclaration | |
400 { | |
401 TypeInfoArrayDeclaration(Type *tinfo); | |
402 | |
403 void toDt(dt_t **pdt); | |
404 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
405 // LDC |
159 | 406 void llvmDeclare(); |
407 void llvmDefine(); | |
408 }; | |
409 | |
410 struct TypeInfoStaticArrayDeclaration : TypeInfoDeclaration | |
411 { | |
412 TypeInfoStaticArrayDeclaration(Type *tinfo); | |
413 | |
414 void toDt(dt_t **pdt); | |
415 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
416 // LDC |
159 | 417 void llvmDeclare(); |
418 void llvmDefine(); | |
419 }; | |
420 | |
421 struct TypeInfoAssociativeArrayDeclaration : TypeInfoDeclaration | |
422 { | |
423 TypeInfoAssociativeArrayDeclaration(Type *tinfo); | |
424 | |
425 void toDt(dt_t **pdt); | |
426 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
427 // LDC |
159 | 428 void llvmDeclare(); |
429 void llvmDefine(); | |
430 }; | |
431 | |
432 struct TypeInfoEnumDeclaration : TypeInfoDeclaration | |
433 { | |
434 TypeInfoEnumDeclaration(Type *tinfo); | |
435 | |
436 void toDt(dt_t **pdt); | |
437 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
438 // LDC |
159 | 439 void llvmDeclare(); |
440 void llvmDefine(); | |
441 }; | |
442 | |
443 struct TypeInfoFunctionDeclaration : TypeInfoDeclaration | |
444 { | |
445 TypeInfoFunctionDeclaration(Type *tinfo); | |
446 | |
447 void toDt(dt_t **pdt); | |
448 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
449 // LDC |
159 | 450 void llvmDeclare(); |
451 void llvmDefine(); | |
452 }; | |
453 | |
454 struct TypeInfoDelegateDeclaration : TypeInfoDeclaration | |
455 { | |
456 TypeInfoDelegateDeclaration(Type *tinfo); | |
457 | |
458 void toDt(dt_t **pdt); | |
459 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
460 // LDC |
159 | 461 void llvmDeclare(); |
462 void llvmDefine(); | |
463 }; | |
464 | |
465 struct TypeInfoTupleDeclaration : TypeInfoDeclaration | |
466 { | |
467 TypeInfoTupleDeclaration(Type *tinfo); | |
468 | |
469 void toDt(dt_t **pdt); | |
470 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
471 // LDC |
159 | 472 void llvmDeclare(); |
473 void llvmDefine(); | |
474 }; | |
475 | |
336 | 476 #if DMDV2 |
477 struct TypeInfoConstDeclaration : TypeInfoDeclaration | |
478 { | |
479 TypeInfoConstDeclaration(Type *tinfo); | |
480 | |
481 void toDt(dt_t **pdt); | |
482 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
483 // LDC |
336 | 484 void llvmDeclare(); |
485 void llvmDefine(); | |
486 }; | |
487 | |
488 struct TypeInfoInvariantDeclaration : TypeInfoDeclaration | |
489 { | |
490 TypeInfoInvariantDeclaration(Type *tinfo); | |
491 | |
492 void toDt(dt_t **pdt); | |
493 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
494 // LDC |
336 | 495 void llvmDeclare(); |
496 void llvmDefine(); | |
497 }; | |
498 #endif | |
499 | |
500 /**************************************************************/ | |
501 | |
159 | 502 struct ThisDeclaration : VarDeclaration |
503 { | |
504 ThisDeclaration(Type *t); | |
505 Dsymbol *syntaxCopy(Dsymbol *); | |
506 }; | |
507 | |
508 enum ILS | |
509 { | |
510 ILSuninitialized, // not computed yet | |
511 ILSno, // cannot inline | |
512 ILSyes, // can inline | |
513 }; | |
514 | |
515 /**************************************************************/ | |
336 | 516 #if DMDV2 |
159 | 517 |
518 enum BUILTIN | |
519 { | |
520 BUILTINunknown = -1, // not known if this is a builtin | |
521 BUILTINnot, // this is not a builtin | |
522 BUILTINsin, // std.math.sin | |
523 BUILTINcos, // std.math.cos | |
524 BUILTINtan, // std.math.tan | |
525 BUILTINsqrt, // std.math.sqrt | |
526 BUILTINfabs, // std.math.fabs | |
527 }; | |
528 | |
529 Expression *eval_builtin(enum BUILTIN builtin, Expressions *arguments); | |
530 | |
531 #endif | |
532 | |
533 struct FuncDeclaration : Declaration | |
534 { | |
535 Array *fthrows; // Array of Type's of exceptions (not used) | |
536 Statement *frequire; | |
537 Statement *fensure; | |
538 Statement *fbody; | |
539 | |
540 Identifier *outId; // identifier for out statement | |
541 VarDeclaration *vresult; // variable corresponding to outId | |
542 LabelDsymbol *returnLabel; // where the return goes | |
543 | |
544 DsymbolTable *localsymtab; // used to prevent symbols in different | |
545 // scopes from having the same name | |
546 VarDeclaration *vthis; // 'this' parameter (member and nested) | |
547 VarDeclaration *v_arguments; // '_arguments' parameter | |
548 #if IN_GCC | |
549 VarDeclaration *v_argptr; // '_argptr' variable | |
550 #endif | |
551 Dsymbols *parameters; // Array of VarDeclaration's for parameters | |
552 DsymbolTable *labtab; // statement label symbol table | |
553 Declaration *overnext; // next in overload list | |
554 Loc endloc; // location of closing curly bracket | |
555 int vtblIndex; // for member functions, index into vtbl[] | |
556 int naked; // !=0 if naked | |
557 int inlineAsm; // !=0 if has inline assembler | |
558 ILS inlineStatus; | |
559 int inlineNest; // !=0 if nested inline | |
560 int cantInterpret; // !=0 if cannot interpret function | |
561 int semanticRun; // !=0 if semantic3() had been run | |
562 // this function's frame ptr | |
563 ForeachStatement *fes; // if foreach body, this is the foreach | |
564 int introducing; // !=0 if 'introducing' function | |
565 Type *tintro; // if !=NULL, then this is the type | |
566 // of the 'introducing' function | |
567 // this one is overriding | |
568 int inferRetType; // !=0 if return type is to be inferred | |
569 Scope *scope; // !=NULL means context to use | |
570 | |
571 // Things that should really go into Scope | |
572 int hasReturnExp; // 1 if there's a return exp; statement | |
573 // 2 if there's a throw statement | |
574 // 4 if there's an assert(0) | |
575 // 8 if there's inline asm | |
576 | |
577 // Support for NRVO (named return value optimization) | |
578 int nrvo_can; // !=0 means we can do it | |
579 VarDeclaration *nrvo_var; // variable to replace with shidden | |
580 Symbol *shidden; // hidden pointer passed to function | |
581 | |
336 | 582 #if DMDV2 |
159 | 583 enum BUILTIN builtin; // set if this is a known, builtin |
584 // function we can evaluate at compile | |
585 // time | |
586 | |
587 int tookAddressOf; // set if someone took the address of | |
588 // this function | |
589 Dsymbols closureVars; // local variables in this function | |
590 // which are referenced by nested | |
591 // functions | |
592 #else | |
593 int nestedFrameRef; // !=0 if nested variables referenced | |
594 #endif | |
595 | |
596 FuncDeclaration(Loc loc, Loc endloc, Identifier *id, enum STC storage_class, Type *type); | |
597 Dsymbol *syntaxCopy(Dsymbol *); | |
598 void semantic(Scope *sc); | |
599 void semantic2(Scope *sc); | |
600 void semantic3(Scope *sc); | |
601 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
602 void bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
603 int overrides(FuncDeclaration *fd); | |
604 int findVtblIndex(Array *vtbl, int dim); | |
605 int overloadInsert(Dsymbol *s); | |
606 FuncDeclaration *overloadExactMatch(Type *t); | |
607 FuncDeclaration *overloadResolve(Loc loc, Expressions *arguments); | |
608 LabelDsymbol *searchLabel(Identifier *ident); | |
609 AggregateDeclaration *isThis(); | |
610 AggregateDeclaration *isMember2(); | |
611 int getLevel(Loc loc, FuncDeclaration *fd); // lexical nesting level difference | |
612 void appendExp(Expression *e); | |
613 void appendState(Statement *s); | |
614 char *mangle(); | |
615 int isMain(); | |
616 int isWinMain(); | |
617 int isDllMain(); | |
618 int isExport(); | |
619 int isImportedSymbol(); | |
620 int isAbstract(); | |
621 int isCodeseg(); | |
622 virtual int isNested(); | |
623 int needThis(); | |
624 virtual int isVirtual(); | |
846
bc982f1ad106
Merged DMD 1.037 frontend
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
797
diff
changeset
|
625 virtual int isFinal(); |
159 | 626 virtual int addPreInvariant(); |
627 virtual int addPostInvariant(); | |
628 Expression *interpret(InterState *istate, Expressions *arguments); | |
629 void inlineScan(); | |
630 int canInline(int hasthis, int hdrscan = 0); | |
631 Expression *doInline(InlineScanState *iss, Expression *ethis, Array *arguments); | |
336 | 632 const char *kind(); |
159 | 633 void toDocBuffer(OutBuffer *buf); |
634 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
635 // 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
|
636 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
|
637 static FuncDeclaration *genCfunc(Arguments *args, Type *treturn, Identifier *id); |
159 | 638 |
639 Symbol *toSymbol(); | |
640 Symbol *toThunkSymbol(int offset); // thunk version | |
336 | 641 void toObjFile(int multiobj); // compile to .obj file |
159 | 642 int cvMember(unsigned char *p); |
643 | |
644 FuncDeclaration *isFuncDeclaration() { return this; } | |
645 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
646 // 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
|
647 |
8aebdf56c455
Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
648 // 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
|
649 // 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
|
650 // probably have nestedref set too, see VarDeclaration::checkNestedReference |
159 | 651 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
|
652 |
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
|
653 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
|
654 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
655 bool isIntrinsic(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
656 bool isVaIntrinsic(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
657 |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
658 // 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
|
659 // 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
|
660 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
|
661 LabelMap labmap; |
703
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
662 |
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
663 // 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
|
664 bool isArrayOp; |
159 | 665 }; |
666 | |
667 struct FuncAliasDeclaration : FuncDeclaration | |
668 { | |
669 FuncDeclaration *funcalias; | |
670 | |
671 FuncAliasDeclaration(FuncDeclaration *funcalias); | |
672 | |
673 FuncAliasDeclaration *isFuncAliasDeclaration() { return this; } | |
336 | 674 const char *kind(); |
159 | 675 Symbol *toSymbol(); |
676 }; | |
677 | |
678 struct FuncLiteralDeclaration : FuncDeclaration | |
679 { | |
680 enum TOK tok; // TOKfunction or TOKdelegate | |
681 | |
682 FuncLiteralDeclaration(Loc loc, Loc endloc, Type *type, enum TOK tok, | |
683 ForeachStatement *fes); | |
684 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
685 Dsymbol *syntaxCopy(Dsymbol *); | |
686 int isNested(); | |
336 | 687 int isVirtual(); |
159 | 688 |
689 FuncLiteralDeclaration *isFuncLiteralDeclaration() { return this; } | |
336 | 690 const char *kind(); |
159 | 691 }; |
692 | |
693 struct CtorDeclaration : FuncDeclaration | |
694 { Arguments *arguments; | |
695 int varargs; | |
696 | |
697 CtorDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs); | |
698 Dsymbol *syntaxCopy(Dsymbol *); | |
699 void semantic(Scope *sc); | |
700 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
336 | 701 const char *kind(); |
159 | 702 char *toChars(); |
703 int isVirtual(); | |
704 int addPreInvariant(); | |
705 int addPostInvariant(); | |
706 void toDocBuffer(OutBuffer *buf); | |
707 | |
708 CtorDeclaration *isCtorDeclaration() { return this; } | |
709 }; | |
710 | |
336 | 711 #if DMDV2 |
712 struct PostBlitDeclaration : FuncDeclaration | |
713 { | |
714 PostBlitDeclaration(Loc loc, Loc endloc); | |
715 PostBlitDeclaration(Loc loc, Loc endloc, Identifier *id); | |
716 Dsymbol *syntaxCopy(Dsymbol *); | |
717 void semantic(Scope *sc); | |
718 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
719 int isVirtual(); | |
720 int addPreInvariant(); | |
721 int addPostInvariant(); | |
722 int overloadInsert(Dsymbol *s); | |
723 void emitComment(Scope *sc); | |
724 | |
725 PostBlitDeclaration *isPostBlitDeclaration() { return this; } | |
726 }; | |
727 #endif | |
728 | |
159 | 729 struct DtorDeclaration : FuncDeclaration |
730 { | |
731 DtorDeclaration(Loc loc, Loc endloc); | |
732 DtorDeclaration(Loc loc, Loc endloc, Identifier *id); | |
733 Dsymbol *syntaxCopy(Dsymbol *); | |
734 void semantic(Scope *sc); | |
735 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
736 int isVirtual(); | |
737 int addPreInvariant(); | |
738 int addPostInvariant(); | |
739 int overloadInsert(Dsymbol *s); | |
740 void emitComment(Scope *sc); | |
741 | |
742 DtorDeclaration *isDtorDeclaration() { return this; } | |
743 }; | |
744 | |
745 struct StaticCtorDeclaration : FuncDeclaration | |
746 { | |
747 StaticCtorDeclaration(Loc loc, Loc endloc); | |
748 Dsymbol *syntaxCopy(Dsymbol *); | |
749 void semantic(Scope *sc); | |
750 AggregateDeclaration *isThis(); | |
751 int isStaticConstructor(); | |
752 int isVirtual(); | |
753 int addPreInvariant(); | |
754 int addPostInvariant(); | |
755 void emitComment(Scope *sc); | |
756 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
757 | |
758 StaticCtorDeclaration *isStaticCtorDeclaration() { return this; } | |
759 }; | |
760 | |
761 struct StaticDtorDeclaration : FuncDeclaration | |
336 | 762 { VarDeclaration *vgate; // 'gate' variable |
763 | |
159 | 764 StaticDtorDeclaration(Loc loc, Loc endloc); |
765 Dsymbol *syntaxCopy(Dsymbol *); | |
766 void semantic(Scope *sc); | |
767 AggregateDeclaration *isThis(); | |
768 int isStaticDestructor(); | |
769 int isVirtual(); | |
770 int addPreInvariant(); | |
771 int addPostInvariant(); | |
772 void emitComment(Scope *sc); | |
773 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
774 | |
775 StaticDtorDeclaration *isStaticDtorDeclaration() { return this; } | |
776 }; | |
777 | |
778 struct InvariantDeclaration : FuncDeclaration | |
779 { | |
780 InvariantDeclaration(Loc loc, Loc endloc); | |
781 Dsymbol *syntaxCopy(Dsymbol *); | |
782 void semantic(Scope *sc); | |
783 int isVirtual(); | |
784 int addPreInvariant(); | |
785 int addPostInvariant(); | |
786 void emitComment(Scope *sc); | |
787 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
788 | |
789 InvariantDeclaration *isInvariantDeclaration() { return this; } | |
790 }; | |
791 | |
792 | |
793 struct UnitTestDeclaration : FuncDeclaration | |
794 { | |
795 UnitTestDeclaration(Loc loc, Loc endloc); | |
796 Dsymbol *syntaxCopy(Dsymbol *); | |
797 void semantic(Scope *sc); | |
798 AggregateDeclaration *isThis(); | |
799 int isVirtual(); | |
800 int addPreInvariant(); | |
801 int addPostInvariant(); | |
802 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
803 | |
804 UnitTestDeclaration *isUnitTestDeclaration() { return this; } | |
805 }; | |
806 | |
807 struct NewDeclaration : FuncDeclaration | |
808 { Arguments *arguments; | |
809 int varargs; | |
810 | |
811 NewDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs); | |
812 Dsymbol *syntaxCopy(Dsymbol *); | |
813 void semantic(Scope *sc); | |
814 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
336 | 815 const char *kind(); |
159 | 816 int isVirtual(); |
817 int addPreInvariant(); | |
818 int addPostInvariant(); | |
819 | |
820 NewDeclaration *isNewDeclaration() { return this; } | |
821 }; | |
822 | |
823 | |
824 struct DeleteDeclaration : FuncDeclaration | |
825 { Arguments *arguments; | |
826 | |
827 DeleteDeclaration(Loc loc, Loc endloc, Arguments *arguments); | |
828 Dsymbol *syntaxCopy(Dsymbol *); | |
829 void semantic(Scope *sc); | |
830 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
336 | 831 const char *kind(); |
159 | 832 int isDelete(); |
833 int isVirtual(); | |
834 int addPreInvariant(); | |
835 int addPostInvariant(); | |
836 #ifdef _DH | |
837 DeleteDeclaration *isDeleteDeclaration() { return this; } | |
838 #endif | |
839 }; | |
840 | |
841 #endif /* DMD_DECLARATION_H */ |