Mercurial > projects > ldc
annotate dmd/declaration.h @ 837:331a176c1f4f
Removed error on naked, not fully complete, but I'll be doing more work on it during this Christmas, and some things do work.
Fixed taking delegate of final class method. see mini/delegate3.d.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 09 Dec 2008 14:07:30 +0100 |
parents | 340acf1535d0 |
children | bc982f1ad106 |
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 | |
281 // This is a shell around a back end symbol | |
282 | |
283 struct SymbolDeclaration : Declaration | |
284 { | |
285 Symbol *sym; | |
286 StructDeclaration *dsym; | |
287 | |
288 SymbolDeclaration(Loc loc, Symbol *s, StructDeclaration *dsym); | |
289 | |
290 Symbol *toSymbol(); | |
291 | |
292 // Eliminate need for dynamic_cast | |
293 SymbolDeclaration *isSymbolDeclaration() { return (SymbolDeclaration *)this; } | |
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(); | |
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 */ |