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