comparison dmd2/declaration.h @ 758:f04dde6e882c

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