2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2021 by The D Language Foundation, All Rights Reserved
4 * written by Walter Bright
5 * http://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * http://www.boost.org/LICENSE_1_0.txt
8 * https://github.com/dlang/dmd/blob/master/src/dmd/declaration.h
22 class ForeachStatement
;
28 class FuncDeclaration
;
29 class StructDeclaration
;
32 //enum STC : ulong from astenums.d:
34 #define STCundefined 0ULL
36 #define STCstatic 1ULL /// `static`
37 #define STCextern 2ULL /// `extern`
38 #define STCconst 4ULL /// `const`
39 #define STCfinal 8ULL /// `final`
41 #define STCabstract 0x10ULL /// `abstract`
42 #define STCparameter 0x20ULL /// is function parameter
43 #define STCfield 0x40ULL /// is field of struct, union or class
44 #define STCoverride 0x80ULL /// `override`
46 #define STCauto 0x100ULL /// `auto`
47 #define STCsynchronized 0x200ULL /// `synchronized`
48 #define STCdeprecated 0x400ULL /// `deprecated`
49 #define STCin 0x800ULL /// `in` parameter
51 #define STCout 0x1000ULL /// `out` parameter
52 #define STClazy 0x2000ULL /// `lazy` parameter
53 #define STCforeach 0x4000ULL /// variable for foreach loop
54 #define STCvariadic 0x8000ULL /// the `variadic` parameter in: T foo(T a, U b, V variadic...)
57 #define STCtemplateparameter 0x20000ULL /// template parameter
58 #define STCref 0x40000ULL /// `ref`
59 #define STCscope 0x80000ULL /// `scope`
61 #define STCmaybescope 0x100000ULL /// parameter might be `scope`
62 #define STCscopeinferred 0x200000ULL /// `scope` has been inferred and should not be part of mangling, `scope` must also be set
63 #define STCreturn 0x400000ULL /// 'return ref' or 'return scope' for function parameters
64 #define STCreturnScope 0x800000ULL /// if `ref return scope` then resolve to `ref` and `return scope`
66 #define STCreturninferred 0x1000000ULL /// `return` has been inferred and should not be part of mangling, `return` must also be set
67 #define STCimmutable 0x2000000ULL /// `immutable`
69 #define STCmanifest 0x8000000ULL /// manifest constant
71 #define STCnodtor 0x10000000ULL /// do not run destructor
72 #define STCnothrow 0x20000000ULL /// `nothrow` meaning never throws exceptions
73 #define STCpure 0x40000000ULL /// `pure` function
74 #define STCtls 0x80000000ULL /// thread local
76 #define STCalias 0x100000000ULL /// `alias` parameter
77 #define STCshared 0x200000000ULL /// accessible from multiple threads
78 #define STCgshared 0x400000000ULL /// accessible from multiple threads, but not typed as `shared`
79 #define STCwild 0x800000000ULL /// for wild type constructor
81 #define STCproperty 0x1000000000ULL /// `@property`
82 #define STCsafe 0x2000000000ULL /// `@safe`
83 #define STCtrusted 0x4000000000ULL /// `@trusted`
84 #define STCsystem 0x8000000000ULL /// `@system`
86 #define STCctfe 0x10000000000ULL /// can be used in CTFE, even if it is static
87 #define STCdisable 0x20000000000ULL /// for functions that are not callable
88 #define STCresult 0x40000000000ULL /// for result variables passed to out contracts
89 #define STCnodefaultctor 0x80000000000ULL /// must be set inside constructor
91 #define STCtemp 0x100000000000ULL /// temporary variable
92 #define STCrvalue 0x200000000000ULL /// force rvalue for variables
93 #define STCnogc 0x400000000000ULL /// `@nogc`
94 #define STCautoref 0x800000000000ULL /// Mark for the already deduced `auto ref` parameter
96 #define STCinference 0x1000000000000ULL /// do attribute inference
97 #define STCexptemp 0x2000000000000ULL /// temporary variable that has lifetime restricted to an expression
98 #define STCfuture 0x4000000000000ULL /// introducing new base class function
99 #define STClocal 0x8000000000000ULL /// do not forward (see dmd.dsymbol.ForwardingScopeDsymbol).
101 #define STClive 0x10000000000000ULL /// function `@live` attribute
102 #define STCregister 0x20000000000000ULL /// `register` storage class (ImportC)
103 #define STCvolatile 0x40000000000000ULL /// destined for volatile in the back end
105 #define STC_TYPECTOR (STCconst | STCimmutable | STCshared | STCwild)
106 #define STC_FUNCATTR (STCref | STCnothrow | STCnogc | STCpure | STCproperty | STCsafe | STCtrusted | STCsystem)
108 void ObjectNotFound(Identifier
*id
);
110 /**************************************************************/
112 class Declaration
: public Dsymbol
116 Type
*originalType
; // before semantic analysis
117 StorageClass storage_class
;
118 Visibility visibility
;
120 short inuse
; // used to detect cycles
122 DString mangleOverride
; // overridden symbol with pragma(mangle, "...")
124 const char *kind() const;
125 d_uns64
size(const Loc
&loc
);
127 Dsymbol
*search(const Loc
&loc
, Identifier
*ident
, int flags
= SearchLocalsOnly
);
129 bool isStatic() const { return (storage_class
& STCstatic
) != 0; }
130 virtual bool isDelete();
131 virtual bool isDataseg();
132 virtual bool isThreadlocal();
133 virtual bool isCodeseg() const;
134 bool isFinal() const { return (storage_class
& STCfinal
) != 0; }
135 virtual bool isAbstract() { return (storage_class
& STCabstract
) != 0; }
136 bool isConst() const { return (storage_class
& STCconst
) != 0; }
137 bool isImmutable() const { return (storage_class
& STCimmutable
) != 0; }
138 bool isWild() const { return (storage_class
& STCwild
) != 0; }
139 bool isAuto() const { return (storage_class
& STCauto
) != 0; }
140 bool isScope() const { return (storage_class
& STCscope
) != 0; }
141 bool isSynchronized() const { return (storage_class
& STCsynchronized
) != 0; }
142 bool isParameter() const { return (storage_class
& STCparameter
) != 0; }
143 bool isDeprecated() const { return (storage_class
& STCdeprecated
) != 0; }
144 bool isOverride() const { return (storage_class
& STCoverride
) != 0; }
145 bool isResult() const { return (storage_class
& STCresult
) != 0; }
146 bool isField() const { return (storage_class
& STCfield
) != 0; }
148 bool isIn() const { return (storage_class
& STCin
) != 0; }
149 bool isOut() const { return (storage_class
& STCout
) != 0; }
150 bool isRef() const { return (storage_class
& STCref
) != 0; }
151 bool isReference() const { return (storage_class
& (STCref
| STCout
)) != 0; }
153 bool isFuture() const { return (storage_class
& STCfuture
) != 0; }
155 Visibility
visible();
157 Declaration
*isDeclaration() { return this; }
158 void accept(Visitor
*v
) { v
->visit(this); }
161 /**************************************************************/
163 class TupleDeclaration
: public Declaration
167 bool isexp
; // true: expression tuple
169 TypeTuple
*tupletype
; // !=NULL if this is a type tuple
171 TupleDeclaration
*syntaxCopy(Dsymbol
*);
172 const char *kind() const;
177 TupleDeclaration
*isTupleDeclaration() { return this; }
178 void accept(Visitor
*v
) { v
->visit(this); }
181 /**************************************************************/
183 class AliasDeclaration
: public Declaration
187 Dsymbol
*overnext
; // next in overload list
188 Dsymbol
*_import
; // !=NULL if unresolved internal alias for selective import
190 static AliasDeclaration
*create(const Loc
&loc
, Identifier
*id
, Type
*type
);
191 AliasDeclaration
*syntaxCopy(Dsymbol
*);
192 bool overloadInsert(Dsymbol
*s
);
193 const char *kind() const;
197 bool isOverloadable() const;
199 AliasDeclaration
*isAliasDeclaration() { return this; }
200 void accept(Visitor
*v
) { v
->visit(this); }
203 /**************************************************************/
205 class OverDeclaration
: public Declaration
208 Dsymbol
*overnext
; // next in overload list
211 const char *kind() const;
212 bool equals(const RootObject
*o
) const;
213 bool overloadInsert(Dsymbol
*s
);
217 bool isOverloadable() const;
219 OverDeclaration
*isOverDeclaration() { return this; }
220 void accept(Visitor
*v
) { v
->visit(this); }
223 /**************************************************************/
225 class VarDeclaration
: public Declaration
229 FuncDeclarations nestedrefs
; // referenced by these lexically nested functions
230 Dsymbol
*aliassym
; // if redone as alias to another symbol
231 VarDeclaration
*lastVar
; // Linked list of variables for goto-skips-init detection
232 Expression
*edtor
; // if !=NULL, does the destruction of the variable
233 IntRange
*range
; // if !NULL, the variable is known to be within the range
234 VarDeclarations
*maybes
; // STCmaybescope variables that are assigned to this STCmaybescope variable
236 unsigned endlinnum
; // line number of end of scope that this var lives in
238 unsigned sequenceNumber
; // order the variables are declared
239 structalign_t alignment
;
241 // When interpreting, these point to the value (NULL if value not determinable)
242 // The index of this variable on the CTFE stack, ~0u if not allocated
243 unsigned ctfeAdrOnStack
;
245 bool isargptr
; // if parameter that _argptr points to
246 bool ctorinit
; // it has been initialized in a ctor
247 bool iscatchvar
; // this is the exception object variable in catch() clause
248 bool isowner
; // this is an Owner, despite it being `scope`
249 bool setInCtorOnly
; // field can only be set in a constructor, as it is const or immutable
250 bool onstack
; // it is a class that was allocated on the stack
251 bool mynew
; // it is a class new'd with custom operator new
252 char canassign
; // it can be assigned to
253 bool overlapped
; // if it is a field and has overlapping
254 bool overlapUnsafe
; // if it is an overlapping field and the overlaps are unsafe
255 bool doNotInferScope
; // do not infer 'scope' for this variable
256 bool doNotInferReturn
; // do not infer 'return' for this variable
257 unsigned char isdataseg
; // private data for isDataseg
258 bool isArgDtorVar
; // temporary created to handle scope destruction of a function argument
261 static VarDeclaration
*create(const Loc
&loc
, Type
*t
, Identifier
*id
, Initializer
*init
, StorageClass storage_class
= STCundefined
);
262 VarDeclaration
*syntaxCopy(Dsymbol
*);
263 void setFieldOffset(AggregateDeclaration
*ad
, FieldState
& fieldState
, bool isunion
);
264 const char *kind() const;
265 AggregateDeclaration
*isThis();
267 bool isExport() const;
268 bool isImportedSymbol() const;
269 bool isCtorinit() const;
271 bool isThreadlocal();
273 bool isOverlappedWith(VarDeclaration
*v
);
275 bool canTakeAddressOf();
276 bool needsScopeDtor();
277 bool enclosesLifetimeOf(VarDeclaration
*v
) const;
278 void checkCtorConstInit();
280 // Eliminate need for dynamic_cast
281 VarDeclaration
*isVarDeclaration() { return (VarDeclaration
*)this; }
282 void accept(Visitor
*v
) { v
->visit(this); }
285 /**************************************************************/
287 class BitFieldDeclaration
: public VarDeclaration
295 BitFieldDeclaration
*syntaxCopy(Dsymbol
*);
296 BitFieldDeclaration
*isBitFieldDeclaration() { return this; }
297 void accept(Visitor
*v
) { v
->visit(this); }
300 /**************************************************************/
302 // This is a shell around a back end symbol
304 class SymbolDeclaration
: public Declaration
307 AggregateDeclaration
*dsym
;
309 // Eliminate need for dynamic_cast
310 SymbolDeclaration
*isSymbolDeclaration() { return (SymbolDeclaration
*)this; }
311 void accept(Visitor
*v
) { v
->visit(this); }
314 class TypeInfoDeclaration
: public VarDeclaration
319 static TypeInfoDeclaration
*create(Type
*tinfo
);
320 TypeInfoDeclaration
*syntaxCopy(Dsymbol
*);
321 const char *toChars() const;
323 TypeInfoDeclaration
*isTypeInfoDeclaration() { return this; }
324 void accept(Visitor
*v
) { v
->visit(this); }
327 class TypeInfoStructDeclaration
: public TypeInfoDeclaration
330 static TypeInfoStructDeclaration
*create(Type
*tinfo
);
332 void accept(Visitor
*v
) { v
->visit(this); }
335 class TypeInfoClassDeclaration
: public TypeInfoDeclaration
338 static TypeInfoClassDeclaration
*create(Type
*tinfo
);
340 void accept(Visitor
*v
) { v
->visit(this); }
343 class TypeInfoInterfaceDeclaration
: public TypeInfoDeclaration
346 static TypeInfoInterfaceDeclaration
*create(Type
*tinfo
);
348 void accept(Visitor
*v
) { v
->visit(this); }
351 class TypeInfoPointerDeclaration
: public TypeInfoDeclaration
354 static TypeInfoPointerDeclaration
*create(Type
*tinfo
);
356 void accept(Visitor
*v
) { v
->visit(this); }
359 class TypeInfoArrayDeclaration
: public TypeInfoDeclaration
362 static TypeInfoArrayDeclaration
*create(Type
*tinfo
);
364 void accept(Visitor
*v
) { v
->visit(this); }
367 class TypeInfoStaticArrayDeclaration
: public TypeInfoDeclaration
370 static TypeInfoStaticArrayDeclaration
*create(Type
*tinfo
);
372 void accept(Visitor
*v
) { v
->visit(this); }
375 class TypeInfoAssociativeArrayDeclaration
: public TypeInfoDeclaration
378 static TypeInfoAssociativeArrayDeclaration
*create(Type
*tinfo
);
380 void accept(Visitor
*v
) { v
->visit(this); }
383 class TypeInfoEnumDeclaration
: public TypeInfoDeclaration
386 static TypeInfoEnumDeclaration
*create(Type
*tinfo
);
388 void accept(Visitor
*v
) { v
->visit(this); }
391 class TypeInfoFunctionDeclaration
: public TypeInfoDeclaration
394 static TypeInfoFunctionDeclaration
*create(Type
*tinfo
);
396 void accept(Visitor
*v
) { v
->visit(this); }
399 class TypeInfoDelegateDeclaration
: public TypeInfoDeclaration
402 static TypeInfoDelegateDeclaration
*create(Type
*tinfo
);
404 void accept(Visitor
*v
) { v
->visit(this); }
407 class TypeInfoTupleDeclaration
: public TypeInfoDeclaration
410 static TypeInfoTupleDeclaration
*create(Type
*tinfo
);
412 void accept(Visitor
*v
) { v
->visit(this); }
415 class TypeInfoConstDeclaration
: public TypeInfoDeclaration
418 static TypeInfoConstDeclaration
*create(Type
*tinfo
);
420 void accept(Visitor
*v
) { v
->visit(this); }
423 class TypeInfoInvariantDeclaration
: public TypeInfoDeclaration
426 static TypeInfoInvariantDeclaration
*create(Type
*tinfo
);
428 void accept(Visitor
*v
) { v
->visit(this); }
431 class TypeInfoSharedDeclaration
: public TypeInfoDeclaration
434 static TypeInfoSharedDeclaration
*create(Type
*tinfo
);
436 void accept(Visitor
*v
) { v
->visit(this); }
439 class TypeInfoWildDeclaration
: public TypeInfoDeclaration
442 static TypeInfoWildDeclaration
*create(Type
*tinfo
);
444 void accept(Visitor
*v
) { v
->visit(this); }
447 class TypeInfoVectorDeclaration
: public TypeInfoDeclaration
450 static TypeInfoVectorDeclaration
*create(Type
*tinfo
);
452 void accept(Visitor
*v
) { v
->visit(this); }
455 /**************************************************************/
457 class ThisDeclaration
: public VarDeclaration
460 ThisDeclaration
*syntaxCopy(Dsymbol
*);
461 ThisDeclaration
*isThisDeclaration() { return this; }
462 void accept(Visitor
*v
) { v
->visit(this); }
465 enum class ILS
: unsigned char
467 ILSuninitialized
, // not computed yet
468 ILSno
, // cannot inline
472 /**************************************************************/
474 enum class BUILTIN
: unsigned char
476 unknown
= 255, /// not known if this is a builtin
477 unimp
= 0, /// this is not a builtin
478 gcc
, /// this is a GCC builtin
479 llvm
, /// this is an LLVM builtin
515 Expression
*eval_builtin(const Loc
&loc
, FuncDeclaration
*fd
, Expressions
*arguments
);
516 BUILTIN
isBuiltin(FuncDeclaration
*fd
);
518 class FuncDeclaration
: public Declaration
521 Statements
*frequires
; // in contracts
522 Ensures
*fensures
; // out contracts
523 Statement
*frequire
; // lowered in contract
524 Statement
*fensure
; // lowered out contract
527 FuncDeclarations foverrides
; // functions this function overrides
528 FuncDeclaration
*fdrequire
; // function that does the in contract
529 FuncDeclaration
*fdensure
; // function that does the out contract
531 Expressions
*fdrequireParams
; // argument list for __require
532 Expressions
*fdensureParams
; // argument list for __ensure
534 const char *mangleString
; // mangled symbol created from mangleExact()
536 VarDeclaration
*vresult
; // result variable for out contracts
537 LabelDsymbol
*returnLabel
; // where the return goes
539 void *isTypeIsolatedCache
; // An AA on the D side to cache an expensive check result
541 // used to prevent symbols in different
542 // scopes from having the same name
543 DsymbolTable
*localsymtab
;
544 VarDeclaration
*vthis
; // 'this' parameter (member and nested)
545 bool isThis2
; // has a dual-context 'this' parameter
546 VarDeclaration
*v_arguments
; // '_arguments' parameter
548 VarDeclaration
*v_argptr
; // '_argptr' variable
549 VarDeclarations
*parameters
; // Array of VarDeclaration's for parameters
550 DsymbolTable
*labtab
; // statement label symbol table
551 Dsymbol
*overnext
; // next in overload list
552 FuncDeclaration
*overnext0
; // next in overload list (only used during IFTI)
553 Loc endloc
; // location of closing curly bracket
554 int vtblIndex
; // for member functions, index into vtbl[]
555 bool naked
; // true if naked
556 bool generated
; // true if function was generated by the compiler rather than
557 // supplied by the user
558 bool hasAlwaysInlines
; // contains references to functions that must be inlined
559 unsigned char isCrtCtorDtor
; // has attribute pragma(crt_constructor(1)/crt_destructor(2))
560 // not set before the glue layer
561 ILS inlineStatusStmt
;
565 int inlineNest
; // !=0 if nested inline
566 bool eh_none
; /// true if no exception unwinding is needed
568 // true if errors in semantic3 this function's frame ptr
569 bool semantic3Errors
;
570 ForeachStatement
*fes
; // if foreach body, this is the foreach
571 BaseClass
* interfaceVirtual
; // if virtual, but only appears in interface vtbl[]
572 bool introducing
; // true if 'introducing' function
573 // if !=NULL, then this is the type
574 // of the 'introducing' function
575 // this one is overriding
577 bool inferRetType
; // true if return type is to be inferred
578 StorageClass storage_class2
; // storage class for template onemember's
580 // Things that should really go into Scope
582 // 1 if there's a return exp; statement
583 // 2 if there's a throw statement
584 // 4 if there's an assert(0)
585 // 8 if there's inline asm
586 // 16 if there are multiple return statements
589 // Support for NRVO (named return value optimization)
590 bool nrvo_can
; // true means we can do it
591 VarDeclaration
*nrvo_var
; // variable to replace with shidden
592 Symbol
*shidden
; // hidden pointer passed to function
594 ReturnStatements
*returns
;
596 GotoStatements
*gotos
; // Gotos with forward references
598 // set if this is a known, builtin function we can evaluate at compile time
601 // set if someone took the address of this function
603 bool requiresClosure
; // this function needs a closure
605 // local variables in this function which are referenced by nested functions
606 VarDeclarations closureVars
;
608 /** Outer variables which are referenced by this nested function
609 * (the inverse of closureVars)
611 VarDeclarations outerVars
;
613 // Sibling nested functions which called this one
614 FuncDeclarations siblingCallers
;
616 FuncDeclarations
*inlinedNestedCallees
;
618 unsigned flags
; // FUNCFLAGxxxxx
620 // Data for a function declaration that is needed for the Objective-C
622 ObjcFuncDeclaration objc
;
624 static FuncDeclaration
*create(const Loc
&loc
, const Loc
&endloc
, Identifier
*id
, StorageClass storage_class
, Type
*type
, bool noreturn
= false);
625 FuncDeclaration
*syntaxCopy(Dsymbol
*);
626 bool functionSemantic();
627 bool functionSemantic3();
628 bool equals(const RootObject
*o
) const;
630 int overrides(FuncDeclaration
*fd
);
631 int findVtblIndex(Dsymbols
*vtbl
, int dim
);
632 BaseClass
*overrideInterface();
633 bool overloadInsert(Dsymbol
*s
);
635 MATCH
leastAsSpecialized(FuncDeclaration
*g
);
636 LabelDsymbol
*searchLabel(Identifier
*ident
, const Loc
&loc
);
637 int getLevel(FuncDeclaration
*fd
, int intypeof
); // lexical nesting level difference
638 int getLevelAndCheck(const Loc
&loc
, Scope
*sc
, FuncDeclaration
*fd
);
639 const char *toPrettyChars(bool QualifyTypes
= false);
640 const char *toFullSignature(); // for diagnostics, e.g. 'int foo(int x, int y) pure'
642 bool isCMain() const;
643 bool isWinMain() const;
644 bool isDllMain() const;
645 bool isExport() const;
646 bool isImportedSymbol() const;
647 bool isCodeseg() const;
648 bool isOverloadable() const;
651 PURE
isPureBypassingInference();
653 bool isSafeBypassingInference();
657 bool isNogcBypassingInference();
659 virtual bool isNested() const;
660 AggregateDeclaration
*isThis();
662 bool isVirtualMethod();
663 virtual bool isVirtual() const;
664 bool isFinalFunc() const;
665 virtual bool addPreInvariant();
666 virtual bool addPostInvariant();
667 const char *kind() const;
670 bool hasNestedFrameRefs();
671 ParameterList
getParameterList();
673 static FuncDeclaration
*genCfunc(Parameters
*args
, Type
*treturn
, const char *name
, StorageClass stc
=0);
674 static FuncDeclaration
*genCfunc(Parameters
*args
, Type
*treturn
, Identifier
*id
, StorageClass stc
=0);
678 FuncDeclaration
*isFuncDeclaration() { return this; }
680 virtual FuncDeclaration
*toAliasFunc() { return this; }
681 void accept(Visitor
*v
) { v
->visit(this); }
684 class FuncAliasDeclaration
: public FuncDeclaration
687 FuncDeclaration
*funcalias
;
690 FuncAliasDeclaration
*isFuncAliasDeclaration() { return this; }
691 const char *kind() const;
693 FuncDeclaration
*toAliasFunc();
694 void accept(Visitor
*v
) { v
->visit(this); }
697 class FuncLiteralDeclaration
: public FuncDeclaration
700 TOK tok
; // TOKfunction or TOKdelegate
701 Type
*treq
; // target of return type inference
706 FuncLiteralDeclaration
*syntaxCopy(Dsymbol
*);
707 bool isNested() const;
708 AggregateDeclaration
*isThis();
709 bool isVirtual() const;
710 bool addPreInvariant();
711 bool addPostInvariant();
713 void modifyReturns(Scope
*sc
, Type
*tret
);
715 FuncLiteralDeclaration
*isFuncLiteralDeclaration() { return this; }
716 const char *kind() const;
717 const char *toPrettyChars(bool QualifyTypes
= false);
718 void accept(Visitor
*v
) { v
->visit(this); }
721 class CtorDeclaration
: public FuncDeclaration
725 CtorDeclaration
*syntaxCopy(Dsymbol
*);
726 const char *kind() const;
727 const char *toChars() const;
728 bool isVirtual() const;
729 bool addPreInvariant();
730 bool addPostInvariant();
732 CtorDeclaration
*isCtorDeclaration() { return this; }
733 void accept(Visitor
*v
) { v
->visit(this); }
736 class PostBlitDeclaration
: public FuncDeclaration
739 PostBlitDeclaration
*syntaxCopy(Dsymbol
*);
740 bool isVirtual() const;
741 bool addPreInvariant();
742 bool addPostInvariant();
743 bool overloadInsert(Dsymbol
*s
);
745 PostBlitDeclaration
*isPostBlitDeclaration() { return this; }
746 void accept(Visitor
*v
) { v
->visit(this); }
749 class DtorDeclaration
: public FuncDeclaration
752 DtorDeclaration
*syntaxCopy(Dsymbol
*);
753 const char *kind() const;
754 const char *toChars() const;
755 bool isVirtual() const;
756 bool addPreInvariant();
757 bool addPostInvariant();
758 bool overloadInsert(Dsymbol
*s
);
760 DtorDeclaration
*isDtorDeclaration() { return this; }
761 void accept(Visitor
*v
) { v
->visit(this); }
764 class StaticCtorDeclaration
: public FuncDeclaration
767 StaticCtorDeclaration
*syntaxCopy(Dsymbol
*);
768 AggregateDeclaration
*isThis();
769 bool isVirtual() const;
770 bool addPreInvariant();
771 bool addPostInvariant();
772 bool hasStaticCtorOrDtor();
774 StaticCtorDeclaration
*isStaticCtorDeclaration() { return this; }
775 void accept(Visitor
*v
) { v
->visit(this); }
778 class SharedStaticCtorDeclaration
: public StaticCtorDeclaration
781 SharedStaticCtorDeclaration
*syntaxCopy(Dsymbol
*);
783 SharedStaticCtorDeclaration
*isSharedStaticCtorDeclaration() { return this; }
784 void accept(Visitor
*v
) { v
->visit(this); }
787 class StaticDtorDeclaration
: public FuncDeclaration
790 VarDeclaration
*vgate
; // 'gate' variable
792 StaticDtorDeclaration
*syntaxCopy(Dsymbol
*);
793 AggregateDeclaration
*isThis();
794 bool isVirtual() const;
795 bool hasStaticCtorOrDtor();
796 bool addPreInvariant();
797 bool addPostInvariant();
799 StaticDtorDeclaration
*isStaticDtorDeclaration() { return this; }
800 void accept(Visitor
*v
) { v
->visit(this); }
803 class SharedStaticDtorDeclaration
: public StaticDtorDeclaration
806 SharedStaticDtorDeclaration
*syntaxCopy(Dsymbol
*);
808 SharedStaticDtorDeclaration
*isSharedStaticDtorDeclaration() { return this; }
809 void accept(Visitor
*v
) { v
->visit(this); }
812 class InvariantDeclaration
: public FuncDeclaration
815 InvariantDeclaration
*syntaxCopy(Dsymbol
*);
816 bool isVirtual() const;
817 bool addPreInvariant();
818 bool addPostInvariant();
820 InvariantDeclaration
*isInvariantDeclaration() { return this; }
821 void accept(Visitor
*v
) { v
->visit(this); }
824 class UnitTestDeclaration
: public FuncDeclaration
827 char *codedoc
; /** For documented unittest. */
829 // toObjFile() these nested functions after this one
830 FuncDeclarations deferredNested
;
832 UnitTestDeclaration
*syntaxCopy(Dsymbol
*);
833 AggregateDeclaration
*isThis();
834 bool isVirtual() const;
835 bool addPreInvariant();
836 bool addPostInvariant();
838 UnitTestDeclaration
*isUnitTestDeclaration() { return this; }
839 void accept(Visitor
*v
) { v
->visit(this); }
842 class NewDeclaration
: public FuncDeclaration
845 NewDeclaration
*syntaxCopy(Dsymbol
*);
846 const char *kind() const;
847 bool isVirtual() const;
848 bool addPreInvariant();
849 bool addPostInvariant();
851 NewDeclaration
*isNewDeclaration() { return this; }
852 void accept(Visitor
*v
) { v
->visit(this); }