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