2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved
4 * written by Walter Bright
5 * https://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * https://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
;
31 struct AttributeViolation
;
35 bool functionSemantic(FuncDeclaration
* fd
);
36 bool functionSemantic3(FuncDeclaration
* fd
);
37 bool checkClosure(FuncDeclaration
* fd
);
38 MATCH
leastAsSpecialized(FuncDeclaration
*f
, FuncDeclaration
*g
, Identifiers
*names
);
39 PURE
isPure(FuncDeclaration
*f
);
40 FuncDeclaration
*genCfunc(Parameters
*args
, Type
*treturn
, const char *name
, StorageClass stc
=0);
41 FuncDeclaration
*genCfunc(Parameters
*args
, Type
*treturn
, Identifier
*id
, StorageClass stc
=0);
44 //enum STC : ulong from astenums.d:
46 #define STCundefined 0ULL
48 #define STCstatic 1ULL /// `static`
49 #define STCextern 2ULL /// `extern`
50 #define STCconst 4ULL /// `const`
51 #define STCfinal 8ULL /// `final`
53 #define STCabstract 0x10ULL /// `abstract`
54 #define STCparameter 0x20ULL /// is function parameter
55 #define STCfield 0x40ULL /// is field of struct, union or class
56 #define STCoverride 0x80ULL /// `override`
58 #define STCauto 0x100ULL /// `auto`
59 #define STCsynchronized 0x200ULL /// `synchronized`
60 #define STCdeprecated 0x400ULL /// `deprecated`
61 #define STCin 0x800ULL /// `in` parameter
63 #define STCout 0x1000ULL /// `out` parameter
64 #define STClazy 0x2000ULL /// `lazy` parameter
65 #define STCforeach 0x4000ULL /// variable for foreach loop
66 #define STCvariadic 0x8000ULL /// the `variadic` parameter in: T foo(T a, U b, V variadic...)
68 #define STCconstscoperef 0x10000ULL /// when `in` means const|scope|ref
69 #define STCtemplateparameter 0x20000ULL /// template parameter
70 #define STCref 0x40000ULL /// `ref`
71 #define STCscope 0x80000ULL /// `scope`
73 #define STCscopeinferred 0x200000ULL /// `scope` has been inferred and should not be part of mangling, `scope` must also be set
74 #define STCreturn 0x400000ULL /// 'return ref' or 'return scope' for function parameters
75 #define STCreturnScope 0x800000ULL /// if `ref return scope` then resolve to `ref` and `return scope`
77 #define STCreturninferred 0x1000000ULL /// `return` has been inferred and should not be part of mangling, `return` must also be set
78 #define STCimmutable 0x2000000ULL /// `immutable`
80 #define STCmanifest 0x8000000ULL /// manifest constant
82 #define STCnodtor 0x10000000ULL /// do not run destructor
83 #define STCnothrow 0x20000000ULL /// `nothrow` meaning never throws exceptions
84 #define STCpure 0x40000000ULL /// `pure` function
86 #define STCalias 0x100000000ULL /// `alias` parameter
87 #define STCshared 0x200000000ULL /// accessible from multiple threads
88 #define STCgshared 0x400000000ULL /// accessible from multiple threads, but not typed as `shared`
89 #define STCwild 0x800000000ULL /// for wild type constructor
91 #define STCproperty 0x1000000000ULL /// `@property`
92 #define STCsafe 0x2000000000ULL /// `@safe`
93 #define STCtrusted 0x4000000000ULL /// `@trusted`
94 #define STCsystem 0x8000000000ULL /// `@system`
96 #define STCctfe 0x10000000000ULL /// can be used in CTFE, even if it is static
97 #define STCdisable 0x20000000000ULL /// for functions that are not callable
98 #define STCresult 0x40000000000ULL /// for result variables passed to out contracts
99 #define STCnodefaultctor 0x80000000000ULL /// must be set inside constructor
101 #define STCtemp 0x100000000000ULL /// temporary variable
102 #define STCrvalue 0x200000000000ULL /// force rvalue for variables
103 #define STCnogc 0x400000000000ULL /// `@nogc`
104 #define STCautoref 0x800000000000ULL /// Mark for the already deduced `auto ref` parameter
106 #define STCinference 0x1000000000000ULL /// do attribute inference
107 #define STCexptemp 0x2000000000000ULL /// temporary variable that has lifetime restricted to an expression
108 #define STCfuture 0x4000000000000ULL /// introducing new base class function
109 #define STClocal 0x8000000000000ULL /// do not forward (see dmd.dsymbol.ForwardingScopeDsymbol).
111 #define STClive 0x10000000000000ULL /// function `@live` attribute
112 #define STCregister 0x20000000000000ULL /// `register` storage class (ImportC)
113 #define STCvolatile 0x40000000000000ULL /// destined for volatile in the back end
115 #define STC_TYPECTOR (STCconst | STCimmutable | STCshared | STCwild)
116 #define STC_FUNCATTR (STCref | STCnothrow | STCnogc | STCpure | STCproperty | STCsafe | STCtrusted | STCsystem)
118 /**************************************************************/
120 class Declaration
: public Dsymbol
124 Type
*originalType
; // before semantic analysis
125 StorageClass storage_class
;
126 DString mangleOverride
; // overridden symbol with pragma(mangle, "...")
127 Visibility visibility
;
128 short inuse
; // used to detect cycles
131 LINK
_linkage() const;
132 LINK
_linkage(LINK v
);
133 bool noUnderscore() const;
135 const char *kind() const override
;
136 uinteger_t
size(Loc loc
) override final
;
139 bool isStatic() const { return (storage_class
& STCstatic
) != 0; }
140 LINK
resolvedLinkage() const; // returns the linkage, resolving the target-specific `System` one
141 virtual bool isDelete();
142 virtual bool isDataseg();
143 virtual bool isThreadlocal();
144 virtual bool isCodeseg() const;
145 bool isFinal() const { return (storage_class
& STCfinal
) != 0; }
146 virtual bool isAbstract() { return (storage_class
& STCabstract
) != 0; }
147 bool isConst() const { return (storage_class
& STCconst
) != 0; }
148 bool isImmutable() const { return (storage_class
& STCimmutable
) != 0; }
149 bool isWild() const { return (storage_class
& STCwild
) != 0; }
150 bool isAuto() const { return (storage_class
& STCauto
) != 0; }
151 bool isScope() const { return (storage_class
& STCscope
) != 0; }
152 bool isReturn() const { return (storage_class
& STCreturn
) != 0; }
153 bool isSynchronized() const { return (storage_class
& STCsynchronized
) != 0; }
154 bool isParameter() const { return (storage_class
& STCparameter
) != 0; }
155 bool isDeprecated() const override final
{ return (storage_class
& STCdeprecated
) != 0; }
156 bool isOverride() const { return (storage_class
& STCoverride
) != 0; }
157 bool isResult() const { return (storage_class
& STCresult
) != 0; }
158 bool isField() const { return (storage_class
& STCfield
) != 0; }
160 bool isIn() const { return (storage_class
& STCin
) != 0; }
161 bool isOut() const { return (storage_class
& STCout
) != 0; }
162 bool isRef() const { return (storage_class
& STCref
) != 0; }
163 bool isReference() const { return (storage_class
& (STCref
| STCout
)) != 0; }
165 bool isFuture() const { return (storage_class
& STCfuture
) != 0; }
167 Visibility
visible() override final
;
169 void accept(Visitor
*v
) override
{ v
->visit(this); }
172 /**************************************************************/
174 class TupleDeclaration final
: public Declaration
178 TypeTuple
*tupletype
; // !=NULL if this is a type tuple
179 d_bool isexp
; // true: expression tuple
180 d_bool building
; // it's growing in AliasAssign semantic
182 TupleDeclaration
*syntaxCopy(Dsymbol
*) override
;
183 const char *kind() const override
;
184 Type
*getType() override
;
185 Dsymbol
*toAlias2() override
;
186 bool needThis() override
;
188 void accept(Visitor
*v
) override
{ v
->visit(this); }
191 /**************************************************************/
193 class AliasDeclaration final
: public Declaration
197 Dsymbol
*overnext
; // next in overload list
198 Dsymbol
*_import
; // !=NULL if unresolved internal alias for selective import
200 static AliasDeclaration
*create(Loc loc
, Identifier
*id
, Type
*type
);
201 AliasDeclaration
*syntaxCopy(Dsymbol
*) override
;
202 bool overloadInsert(Dsymbol
*s
) override
;
203 const char *kind() const override
;
204 Type
*getType() override
;
205 Dsymbol
*toAlias() override
;
206 Dsymbol
*toAlias2() override
;
207 bool isOverloadable() const override
;
209 void accept(Visitor
*v
) override
{ v
->visit(this); }
212 /**************************************************************/
214 class OverDeclaration final
: public Declaration
217 Dsymbol
*overnext
; // next in overload list
220 const char *kind() const override
;
221 bool equals(const RootObject
* const o
) const override
;
222 bool overloadInsert(Dsymbol
*s
) override
;
224 Dsymbol
*toAlias() override
;
226 bool isOverloadable() const override
;
228 void accept(Visitor
*v
) override
{ v
->visit(this); }
231 /**************************************************************/
233 class VarDeclaration
: public Declaration
237 FuncDeclarations nestedrefs
; // referenced by these lexically nested functions
238 TupleDeclaration
*aliasTuple
; // if `this` is really a tuple of declarations
239 VarDeclaration
*lastVar
; // Linked list of variables for goto-skips-init detection
240 Expression
*edtor
; // if !=NULL, does the destruction of the variable
241 IntRange
*range
; // if !NULL, the variable is known to be within the range
243 unsigned endlinnum
; // line number of end of scope that this var lives in
245 unsigned sequenceNumber
; // order the variables are declared
246 structalign_t alignment
;
248 // When interpreting, these point to the value (NULL if value not determinable)
249 // The index of this variable on the CTFE stack, ~0u if not allocated
250 unsigned ctfeAdrOnStack
;
254 int8_t canassign
; // // it can be assigned to
255 uint8_t isdataseg
; // private data for isDataseg
256 bool isargptr() const; // if parameter that _argptr points to
257 bool isargptr(bool v
);
258 bool ctorinit() const; // it has been initialized in a ctor
259 bool ctorinit(bool v
);
260 bool iscatchvar() const; // this is the exception object variable in catch() clause
261 bool iscatchvar(bool v
);
262 bool isowner() const; // this is an Owner, despite it being `scope`
263 bool isowner(bool v
);
264 bool setInCtorOnly() const; // field can only be set in a constructor, as it is const or immutable
265 bool setInCtorOnly(bool v
);
266 bool onstack() const; // it is a class that was allocated on the stack
267 bool onstack(bool v
);
268 bool overlapped() const; // if it is a field and has overlapping
269 bool overlapped(bool v
);
270 bool overlapUnsafe() const; // if it is an overlapping field and the overlaps are unsafe
271 bool overlapUnsafe(bool v
);
272 bool maybeScope() const; // allow inferring 'scope' for this variable
273 bool maybeScope(bool v
);
274 bool doNotInferReturn() const; // do not infer 'return' for this variable
275 bool doNotInferReturn(bool v
);
276 bool isArgDtorVar() const; // temporary created to handle scope destruction of a function argument
277 bool isArgDtorVar(bool v
);
278 bool isCmacro() const; // if a C macro turned into a C variable
279 bool isCmacro(bool v
);
281 bool inClosure() const; // is inserted into a GC allocated closure
282 bool inClosure(bool v
);
283 bool inAlignSection() const; // is inserted into aligned section on stack
284 bool inAlignSection(bool v
);
286 bool systemInferred() const;
287 bool systemInferred(bool v
);
288 static VarDeclaration
*create(Loc loc
, Type
*t
, Identifier
*id
, Initializer
*init
, StorageClass storage_class
= STCundefined
);
289 VarDeclaration
*syntaxCopy(Dsymbol
*) override
;
290 const char *kind() const override
;
291 AggregateDeclaration
*isThis() override final
;
292 bool needThis() override final
;
293 bool isExport() const override final
;
294 bool isImportedSymbol() const override final
;
295 bool isCtorinit() const;
296 bool isDataseg() override final
;
297 bool isThreadlocal() override final
;
299 bool isOverlappedWith(VarDeclaration
*v
);
300 bool hasPointers() override final
;
301 bool canTakeAddressOf();
302 bool needsScopeDtor();
303 Dsymbol
*toAlias() override final
;
304 // Eliminate need for dynamic_cast
305 void accept(Visitor
*v
) override
{ v
->visit(this); }
308 /**************************************************************/
310 class BitFieldDeclaration
: public VarDeclaration
318 BitFieldDeclaration
*syntaxCopy(Dsymbol
*) override
;
319 void accept(Visitor
*v
) override
{ v
->visit(this); }
322 /**************************************************************/
324 // This is a shell around a back end symbol
326 class SymbolDeclaration final
: public Declaration
329 AggregateDeclaration
*dsym
;
331 // Eliminate need for dynamic_cast
332 void accept(Visitor
*v
) override
{ v
->visit(this); }
335 class TypeInfoDeclaration
: public VarDeclaration
340 static TypeInfoDeclaration
*create(Type
*tinfo
);
341 TypeInfoDeclaration
*syntaxCopy(Dsymbol
*) override final
;
343 void accept(Visitor
*v
) override
{ v
->visit(this); }
346 class TypeInfoStructDeclaration final
: public TypeInfoDeclaration
349 static TypeInfoStructDeclaration
*create(Type
*tinfo
);
351 void accept(Visitor
*v
) override
{ v
->visit(this); }
354 class TypeInfoClassDeclaration final
: public TypeInfoDeclaration
357 static TypeInfoClassDeclaration
*create(Type
*tinfo
);
359 void accept(Visitor
*v
) override
{ v
->visit(this); }
362 class TypeInfoInterfaceDeclaration final
: public TypeInfoDeclaration
365 static TypeInfoInterfaceDeclaration
*create(Type
*tinfo
);
367 void accept(Visitor
*v
) override
{ v
->visit(this); }
370 class TypeInfoPointerDeclaration final
: public TypeInfoDeclaration
373 static TypeInfoPointerDeclaration
*create(Type
*tinfo
);
375 void accept(Visitor
*v
) override
{ v
->visit(this); }
378 class TypeInfoArrayDeclaration final
: public TypeInfoDeclaration
381 static TypeInfoArrayDeclaration
*create(Type
*tinfo
);
383 void accept(Visitor
*v
) override
{ v
->visit(this); }
386 class TypeInfoStaticArrayDeclaration final
: public TypeInfoDeclaration
389 static TypeInfoStaticArrayDeclaration
*create(Type
*tinfo
);
391 void accept(Visitor
*v
) override
{ v
->visit(this); }
394 class TypeInfoAssociativeArrayDeclaration final
: public TypeInfoDeclaration
399 static TypeInfoAssociativeArrayDeclaration
*create(Type
*tinfo
);
401 void accept(Visitor
*v
) override
{ v
->visit(this); }
404 class TypeInfoEnumDeclaration final
: public TypeInfoDeclaration
407 static TypeInfoEnumDeclaration
*create(Type
*tinfo
);
409 void accept(Visitor
*v
) override
{ v
->visit(this); }
412 class TypeInfoFunctionDeclaration final
: public TypeInfoDeclaration
415 static TypeInfoFunctionDeclaration
*create(Type
*tinfo
);
417 void accept(Visitor
*v
) override
{ v
->visit(this); }
420 class TypeInfoDelegateDeclaration final
: public TypeInfoDeclaration
423 static TypeInfoDelegateDeclaration
*create(Type
*tinfo
);
425 void accept(Visitor
*v
) override
{ v
->visit(this); }
428 class TypeInfoTupleDeclaration final
: public TypeInfoDeclaration
431 static TypeInfoTupleDeclaration
*create(Type
*tinfo
);
433 void accept(Visitor
*v
) override
{ v
->visit(this); }
436 class TypeInfoConstDeclaration final
: public TypeInfoDeclaration
439 static TypeInfoConstDeclaration
*create(Type
*tinfo
);
441 void accept(Visitor
*v
) override
{ v
->visit(this); }
444 class TypeInfoInvariantDeclaration final
: public TypeInfoDeclaration
447 static TypeInfoInvariantDeclaration
*create(Type
*tinfo
);
449 void accept(Visitor
*v
) override
{ v
->visit(this); }
452 class TypeInfoSharedDeclaration final
: public TypeInfoDeclaration
455 static TypeInfoSharedDeclaration
*create(Type
*tinfo
);
457 void accept(Visitor
*v
) override
{ v
->visit(this); }
460 class TypeInfoWildDeclaration final
: public TypeInfoDeclaration
463 static TypeInfoWildDeclaration
*create(Type
*tinfo
);
465 void accept(Visitor
*v
) override
{ v
->visit(this); }
468 class TypeInfoVectorDeclaration final
: public TypeInfoDeclaration
471 static TypeInfoVectorDeclaration
*create(Type
*tinfo
);
473 void accept(Visitor
*v
) override
{ v
->visit(this); }
476 /**************************************************************/
478 class ThisDeclaration final
: public VarDeclaration
481 ThisDeclaration
*syntaxCopy(Dsymbol
*) override
;
482 void accept(Visitor
*v
) override
{ v
->visit(this); }
485 enum class ILS
: unsigned char
487 ILSuninitialized
, // not computed yet
488 ILSno
, // cannot inline
492 /**************************************************************/
494 enum class BUILTIN
: unsigned char
496 unknown
= 255, /// not known if this is a builtin
497 unimp
= 0, /// this is not a builtin
498 gcc
, /// this is a GCC builtin
499 llvm
, /// this is an LLVM builtin
535 Expression
*eval_builtin(Loc loc
, FuncDeclaration
*fd
, Expressions
*arguments
);
536 BUILTIN
isBuiltin(FuncDeclaration
*fd
);
540 class FuncDeclaration
: public Declaration
545 FuncDeclarations foverrides
; // functions this function overrides
548 ContractInfo
*contracts
; // contract information
551 const char *mangleString
; // mangled symbol created from mangleExact()
553 VarDeclaration
*vresult
; // result variable for out contracts
554 LabelDsymbol
*returnLabel
; // where the return goes
556 void *isTypeIsolatedCache
; // An AA on the D side to cache an expensive check result
558 // used to prevent symbols in different
559 // scopes from having the same name
560 DsymbolTable
*localsymtab
;
561 VarDeclaration
*vthis
; // 'this' parameter (member and nested)
562 VarDeclaration
*v_arguments
; // '_arguments' parameter
564 VarDeclaration
*v_argptr
; // '_argptr' variable
565 VarDeclarations
*parameters
; // Array of VarDeclaration's for parameters
566 DsymbolTable
*labtab
; // statement label symbol table
567 Dsymbol
*overnext
; // next in overload list
568 FuncDeclaration
*overnext0
; // next in overload list (only used during IFTI)
569 Loc endloc
; // location of closing curly bracket
570 int vtblIndex
; // for member functions, index into vtbl[]
572 ILS inlineStatusStmt
;
576 int inlineNest
; // !=0 if nested inline
578 // true if errors in semantic3 this function's frame ptr
579 ForeachStatement
*fes
; // if foreach body, this is the foreach
580 BaseClass
* interfaceVirtual
; // if virtual, but only appears in interface vtbl[]
581 // if !=NULL, then this is the type
582 // of the 'introducing' function
583 // this one is overriding
585 StorageClass storage_class2
; // storage class for template onemember's
587 // Things that should really go into Scope
589 VarDeclaration
*nrvo_var
; // variable to replace with shidden
590 Symbol
*shidden
; // hidden pointer passed to function
592 ReturnStatements
*returns
;
594 GotoStatements
*gotos
; // Gotos with forward references
596 // set if this is a known, builtin function we can evaluate at compile time
599 // set if someone took the address of this function
601 d_bool requiresClosure
; // this function needs a closure
603 // local variables in this function which are referenced by nested functions
604 VarDeclarations closureVars
;
606 /** Outer variables which are referenced by this nested function
607 * (the inverse of closureVars)
609 VarDeclarations outerVars
;
611 // Sibling nested functions which called this one
612 FuncDeclarations siblingCallers
;
614 FuncDeclarations
*inlinedNestedCallees
;
616 AttributeViolation
* safetyViolation
;
617 AttributeViolation
* nogcViolation
;
618 AttributeViolation
* pureViolation
;
619 AttributeViolation
* nothrowViolation
;
621 // Formerly FUNCFLAGS
623 bool purityInprocess() const;
624 bool purityInprocess(bool v
);
625 bool safetyInprocess() const;
626 bool safetyInprocess(bool v
);
627 bool nothrowInprocess() const;
628 bool nothrowInprocess(bool v
);
629 bool nogcInprocess() const;
630 bool nogcInprocess(bool v
);
633 bool scopeInprocess() const;
634 bool scopeInprocess(bool v
);
635 bool inlineScanned() const;
636 bool inlineScanned(bool v
);
637 bool hasCatches() const;
638 bool hasCatches(bool v
);
639 bool skipCodegen() const;
640 bool skipCodegen(bool v
);
645 bool noreturn() const;
646 bool noreturn(bool v
);
649 bool isNaked() const;
650 bool isNaked(bool v
);
651 bool isGenerated() const;
652 bool isGenerated(bool v
);
653 bool isIntroducing() const;
654 bool isIntroducing(bool v
);
655 bool hasSemantic3Errors() const;
656 bool hasSemantic3Errors(bool v
);
657 bool hasNoEH() const;
658 bool hasNoEH(bool v
);
659 bool inferRetType() const;
660 bool inferRetType(bool v
);
661 bool hasDualContext() const;
662 bool hasDualContext(bool v
);
663 bool hasAlwaysInlines() const;
664 bool hasAlwaysInlines(bool v
);
665 bool isCrtCtor() const;
666 bool isCrtCtor(bool v
);
667 bool isCrtDtor() const;
668 bool isCrtDtor(bool v
);
669 bool dllImport() const;
670 bool dllImport(bool v
);
671 bool dllExport() const;
672 bool dllExport(bool v
);
673 bool hasReturnExp() const;
674 bool hasReturnExp(bool v
);
675 bool hasInlineAsm() const;
676 bool hasInlineAsm(bool v
);
677 bool hasMultipleReturnExp() const;
678 bool hasMultipleReturnExp(bool v
);
680 // Data for a function declaration that is needed for the Objective-C
682 ObjcFuncDeclaration objc
;
684 static FuncDeclaration
*create(Loc loc
, Loc endloc
, Identifier
*id
, StorageClass storage_class
, Type
*type
, bool noreturn
= false);
685 FuncDeclaration
*syntaxCopy(Dsymbol
*) override
;
686 Statements
*frequires();
688 Statement
*frequire();
689 Statement
*fensure();
690 FuncDeclaration
*fdrequire();
691 FuncDeclaration
*fdensure();
692 Expressions
*fdrequireParams();
693 Expressions
*fdensureParams();
694 Statements
*frequires(Statements
*frs
);
695 Ensures
*fensures(Statements
*fes
);
696 Statement
*frequire(Statement
*fr
);
697 Statement
*fensure(Statement
*fe
);
698 FuncDeclaration
*fdrequire(FuncDeclaration
*fdr
);
699 FuncDeclaration
*fdensure(FuncDeclaration
*fde
);
700 Expressions
*fdrequireParams(Expressions
*fdrp
);
701 Expressions
*fdensureParams(Expressions
*fdep
);
702 bool equals(const RootObject
* const o
) const override final
;
704 bool overloadInsert(Dsymbol
*s
) override
;
706 LabelDsymbol
*searchLabel(Identifier
*ident
, Loc loc
);
707 const char *toPrettyChars(bool QualifyTypes
= false) override
;
708 const char *toFullSignature(); // for diagnostics, e.g. 'int foo(int x, int y) pure'
710 bool isCMain() const;
711 bool isWinMain() const;
712 bool isDllMain() const;
713 bool isExport() const override final
;
714 bool isImportedSymbol() const override final
;
715 bool isCodeseg() const override final
;
716 bool isOverloadable() const override final
;
717 bool isAbstract() override final
;
721 virtual bool isNested() const;
722 AggregateDeclaration
*isThis() override
;
723 bool needThis() override final
;
724 bool isVirtualMethod();
725 virtual bool isVirtual() const;
726 bool isFinalFunc() const;
727 virtual bool addPreInvariant();
728 virtual bool addPostInvariant();
729 const char *kind() const override
;
732 bool hasNestedFrameRefs();
733 ParameterList
getParameterList();
735 virtual FuncDeclaration
*toAliasFunc() { return this; }
736 void accept(Visitor
*v
) override
{ v
->visit(this); }
739 class FuncAliasDeclaration final
: public FuncDeclaration
742 FuncDeclaration
*funcalias
;
745 const char *kind() const override
;
747 FuncDeclaration
*toAliasFunc() override
;
748 void accept(Visitor
*v
) override
{ v
->visit(this); }
751 class FuncLiteralDeclaration final
: public FuncDeclaration
754 TOK tok
; // TOKfunction or TOKdelegate
755 Type
*treq
; // target of return type inference
760 FuncLiteralDeclaration
*syntaxCopy(Dsymbol
*) override
;
761 bool isNested() const override
;
762 AggregateDeclaration
*isThis() override
;
763 bool isVirtual() const override
;
764 bool addPreInvariant() override
;
765 bool addPostInvariant() override
;
767 const char *kind() const override
;
768 const char *toPrettyChars(bool QualifyTypes
= false) override
;
769 void accept(Visitor
*v
) override
{ v
->visit(this); }
772 class CtorDeclaration final
: public FuncDeclaration
777 CtorDeclaration
*syntaxCopy(Dsymbol
*) override
;
778 const char *kind() const override
;
779 bool isVirtual() const override
;
780 bool addPreInvariant() override
;
781 bool addPostInvariant() override
;
783 void accept(Visitor
*v
) override
{ v
->visit(this); }
786 class PostBlitDeclaration final
: public FuncDeclaration
789 PostBlitDeclaration
*syntaxCopy(Dsymbol
*) override
;
790 bool isVirtual() const override
;
791 bool addPreInvariant() override
;
792 bool addPostInvariant() override
;
793 bool overloadInsert(Dsymbol
*s
) override
;
795 void accept(Visitor
*v
) override
{ v
->visit(this); }
798 class DtorDeclaration final
: public FuncDeclaration
801 DtorDeclaration
*syntaxCopy(Dsymbol
*) override
;
802 const char *kind() const override
;
803 bool isVirtual() const override
;
804 bool addPreInvariant() override
;
805 bool addPostInvariant() override
;
806 bool overloadInsert(Dsymbol
*s
) override
;
808 void accept(Visitor
*v
) override
{ v
->visit(this); }
811 class StaticCtorDeclaration
: public FuncDeclaration
814 StaticCtorDeclaration
*syntaxCopy(Dsymbol
*) override
;
815 AggregateDeclaration
*isThis() override final
;
816 bool isVirtual() const override final
;
817 bool addPreInvariant() override final
;
818 bool addPostInvariant() override final
;
820 void accept(Visitor
*v
) override
{ v
->visit(this); }
823 class SharedStaticCtorDeclaration final
: public StaticCtorDeclaration
827 SharedStaticCtorDeclaration
*syntaxCopy(Dsymbol
*) override
;
829 void accept(Visitor
*v
) override
{ v
->visit(this); }
832 class StaticDtorDeclaration
: public FuncDeclaration
835 VarDeclaration
*vgate
; // 'gate' variable
837 StaticDtorDeclaration
*syntaxCopy(Dsymbol
*) override
;
838 AggregateDeclaration
*isThis() override final
;
839 bool isVirtual() const override final
;
840 bool addPreInvariant() override final
;
841 bool addPostInvariant() override final
;
843 void accept(Visitor
*v
) override
{ v
->visit(this); }
846 class SharedStaticDtorDeclaration final
: public StaticDtorDeclaration
849 SharedStaticDtorDeclaration
*syntaxCopy(Dsymbol
*) override
;
851 void accept(Visitor
*v
) override
{ v
->visit(this); }
854 class InvariantDeclaration final
: public FuncDeclaration
857 InvariantDeclaration
*syntaxCopy(Dsymbol
*) override
;
858 bool isVirtual() const override
;
859 bool addPreInvariant() override
;
860 bool addPostInvariant() override
;
862 void accept(Visitor
*v
) override
{ v
->visit(this); }
865 class UnitTestDeclaration final
: public FuncDeclaration
868 char *codedoc
; /** For documented unittest. */
870 // toObjFile() these nested functions after this one
871 FuncDeclarations deferredNested
;
873 UnitTestDeclaration
*syntaxCopy(Dsymbol
*) override
;
874 AggregateDeclaration
*isThis() override
;
875 bool isVirtual() const override
;
876 bool addPreInvariant() override
;
877 bool addPostInvariant() override
;
879 void accept(Visitor
*v
) override
{ v
->visit(this); }
882 class NewDeclaration final
: public FuncDeclaration
885 NewDeclaration
*syntaxCopy(Dsymbol
*) override
;
886 const char *kind() const override
;
887 bool isVirtual() const override
;
888 bool addPreInvariant() override
;
889 bool addPostInvariant() override
;
891 void accept(Visitor
*v
) override
{ v
->visit(this); }