2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2024 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
;
33 //enum STC : ulong from astenums.d:
35 #define STCundefined 0ULL
37 #define STCstatic 1ULL /// `static`
38 #define STCextern 2ULL /// `extern`
39 #define STCconst 4ULL /// `const`
40 #define STCfinal 8ULL /// `final`
42 #define STCabstract 0x10ULL /// `abstract`
43 #define STCparameter 0x20ULL /// is function parameter
44 #define STCfield 0x40ULL /// is field of struct, union or class
45 #define STCoverride 0x80ULL /// `override`
47 #define STCauto 0x100ULL /// `auto`
48 #define STCsynchronized 0x200ULL /// `synchronized`
49 #define STCdeprecated 0x400ULL /// `deprecated`
50 #define STCin 0x800ULL /// `in` parameter
52 #define STCout 0x1000ULL /// `out` parameter
53 #define STClazy 0x2000ULL /// `lazy` parameter
54 #define STCforeach 0x4000ULL /// variable for foreach loop
55 #define STCvariadic 0x8000ULL /// the `variadic` parameter in: T foo(T a, U b, V variadic...)
57 #define STCconstscoperef 0x10000ULL /// when `in` means const|scope|ref
58 #define STCtemplateparameter 0x20000ULL /// template parameter
59 #define STCref 0x40000ULL /// `ref`
60 #define STCscope 0x80000ULL /// `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
75 #define STCalias 0x100000000ULL /// `alias` parameter
76 #define STCshared 0x200000000ULL /// accessible from multiple threads
77 #define STCgshared 0x400000000ULL /// accessible from multiple threads, but not typed as `shared`
78 #define STCwild 0x800000000ULL /// for wild type constructor
80 #define STCproperty 0x1000000000ULL /// `@property`
81 #define STCsafe 0x2000000000ULL /// `@safe`
82 #define STCtrusted 0x4000000000ULL /// `@trusted`
83 #define STCsystem 0x8000000000ULL /// `@system`
85 #define STCctfe 0x10000000000ULL /// can be used in CTFE, even if it is static
86 #define STCdisable 0x20000000000ULL /// for functions that are not callable
87 #define STCresult 0x40000000000ULL /// for result variables passed to out contracts
88 #define STCnodefaultctor 0x80000000000ULL /// must be set inside constructor
90 #define STCtemp 0x100000000000ULL /// temporary variable
91 #define STCrvalue 0x200000000000ULL /// force rvalue for variables
92 #define STCnogc 0x400000000000ULL /// `@nogc`
93 #define STCautoref 0x800000000000ULL /// Mark for the already deduced `auto ref` parameter
95 #define STCinference 0x1000000000000ULL /// do attribute inference
96 #define STCexptemp 0x2000000000000ULL /// temporary variable that has lifetime restricted to an expression
97 #define STCfuture 0x4000000000000ULL /// introducing new base class function
98 #define STClocal 0x8000000000000ULL /// do not forward (see dmd.dsymbol.ForwardingScopeDsymbol).
100 #define STClive 0x10000000000000ULL /// function `@live` attribute
101 #define STCregister 0x20000000000000ULL /// `register` storage class (ImportC)
102 #define STCvolatile 0x40000000000000ULL /// destined for volatile in the back end
104 #define STC_TYPECTOR (STCconst | STCimmutable | STCshared | STCwild)
105 #define STC_FUNCATTR (STCref | STCnothrow | STCnogc | STCpure | STCproperty | STCsafe | STCtrusted | STCsystem)
107 void ObjectNotFound(Identifier
*id
);
109 /**************************************************************/
111 class Declaration
: public Dsymbol
115 Type
*originalType
; // before semantic analysis
116 StorageClass storage_class
;
117 Visibility visibility
;
118 LINK _linkage
; // may be `LINK::system`; use `resolvedLinkage()` to resolve it
119 short inuse
; // used to detect cycles
121 DString mangleOverride
; // overridden symbol with pragma(mangle, "...")
123 const char *kind() const override
;
124 uinteger_t
size(const Loc
&loc
) override final
;
127 bool isStatic() const { return (storage_class
& STCstatic
) != 0; }
128 LINK
resolvedLinkage() const; // returns the linkage, resolving the target-specific `System` one
129 virtual bool isDelete();
130 virtual bool isDataseg();
131 virtual bool isThreadlocal();
132 virtual bool isCodeseg() const;
133 bool isFinal() const { return (storage_class
& STCfinal
) != 0; }
134 virtual bool isAbstract() { return (storage_class
& STCabstract
) != 0; }
135 bool isConst() const { return (storage_class
& STCconst
) != 0; }
136 bool isImmutable() const { return (storage_class
& STCimmutable
) != 0; }
137 bool isWild() const { return (storage_class
& STCwild
) != 0; }
138 bool isAuto() const { return (storage_class
& STCauto
) != 0; }
139 bool isScope() const { return (storage_class
& STCscope
) != 0; }
140 bool isReturn() const { return (storage_class
& STCreturn
) != 0; }
141 bool isSynchronized() const { return (storage_class
& STCsynchronized
) != 0; }
142 bool isParameter() const { return (storage_class
& STCparameter
) != 0; }
143 bool isDeprecated() const override final
{ 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() override final
;
157 Declaration
*isDeclaration() override final
{ return this; }
158 void accept(Visitor
*v
) override
{ v
->visit(this); }
161 /**************************************************************/
163 class TupleDeclaration final
: public Declaration
167 TypeTuple
*tupletype
; // !=NULL if this is a type tuple
168 d_bool isexp
; // true: expression tuple
169 d_bool building
; // it's growing in AliasAssign semantic
171 TupleDeclaration
*syntaxCopy(Dsymbol
*) override
;
172 const char *kind() const override
;
173 Type
*getType() override
;
174 Dsymbol
*toAlias2() override
;
175 bool needThis() override
;
177 TupleDeclaration
*isTupleDeclaration() override
{ return this; }
178 void accept(Visitor
*v
) override
{ v
->visit(this); }
181 /**************************************************************/
183 class AliasDeclaration final
: 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
*) override
;
192 bool overloadInsert(Dsymbol
*s
) override
;
193 const char *kind() const override
;
194 Type
*getType() override
;
195 Dsymbol
*toAlias() override
;
196 Dsymbol
*toAlias2() override
;
197 bool isOverloadable() const override
;
199 AliasDeclaration
*isAliasDeclaration() override
{ return this; }
200 void accept(Visitor
*v
) override
{ v
->visit(this); }
203 /**************************************************************/
205 class OverDeclaration final
: public Declaration
208 Dsymbol
*overnext
; // next in overload list
211 const char *kind() const override
;
212 bool equals(const RootObject
* const o
) const override
;
213 bool overloadInsert(Dsymbol
*s
) override
;
215 Dsymbol
*toAlias() override
;
217 bool isOverloadable() const override
;
219 OverDeclaration
*isOverDeclaration() override
{ return this; }
220 void accept(Visitor
*v
) override
{ v
->visit(this); }
223 /**************************************************************/
225 class VarDeclaration
: public Declaration
229 FuncDeclarations nestedrefs
; // referenced by these lexically nested functions
230 TupleDeclaration
*aliasTuple
; // if `this` is really a tuple of declarations
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
;
247 int8_t canassign
; // // it can be assigned to
248 uint8_t isdataseg
; // private data for isDataseg
249 bool isargptr() const; // if parameter that _argptr points to
250 bool isargptr(bool v
);
251 bool ctorinit() const; // it has been initialized in a ctor
252 bool ctorinit(bool v
);
253 bool iscatchvar() const; // this is the exception object variable in catch() clause
254 bool iscatchvar(bool v
);
255 bool isowner() const; // this is an Owner, despite it being `scope`
256 bool isowner(bool v
);
257 bool setInCtorOnly() const; // field can only be set in a constructor, as it is const or immutable
258 bool setInCtorOnly(bool v
);
259 bool onstack() const; // it is a class that was allocated on the stack
260 bool onstack(bool v
);
261 bool overlapped() const; // if it is a field and has overlapping
262 bool overlapped(bool v
);
263 bool overlapUnsafe() const; // if it is an overlapping field and the overlaps are unsafe
264 bool overlapUnsafe(bool v
);
265 bool maybeScope() const; // allow inferring 'scope' for this variable
266 bool maybeScope(bool v
);
267 bool doNotInferReturn() const; // do not infer 'return' for this variable
268 bool doNotInferReturn(bool v
);
269 bool isArgDtorVar() const; // temporary created to handle scope destruction of a function argument
270 bool isArgDtorVar(bool v
);
271 bool isCmacro() const; // if a C macro turned into a C variable
272 bool isCmacro(bool v
);
274 bool inClosure() const; // is inserted into a GC allocated closure
275 bool inClosure(bool v
);
276 bool inAlignSection() const; // is inserted into aligned section on stack
277 bool inAlignSection(bool v
);
279 bool systemInferred() const;
280 bool systemInferred(bool v
);
281 static VarDeclaration
*create(const Loc
&loc
, Type
*t
, Identifier
*id
, Initializer
*init
, StorageClass storage_class
= STCundefined
);
282 VarDeclaration
*syntaxCopy(Dsymbol
*) override
;
283 const char *kind() const override
;
284 AggregateDeclaration
*isThis() override final
;
285 bool needThis() override final
;
286 bool isExport() const override final
;
287 bool isImportedSymbol() const override final
;
288 bool isCtorinit() const;
289 bool isDataseg() override final
;
290 bool isThreadlocal() override final
;
292 bool isOverlappedWith(VarDeclaration
*v
);
293 bool hasPointers() override final
;
294 bool canTakeAddressOf();
295 bool needsScopeDtor();
296 void checkCtorConstInit() override final
;
297 Dsymbol
*toAlias() override final
;
298 // Eliminate need for dynamic_cast
299 VarDeclaration
*isVarDeclaration() override final
{ return (VarDeclaration
*)this; }
300 void accept(Visitor
*v
) override
{ v
->visit(this); }
303 /**************************************************************/
305 class BitFieldDeclaration
: public VarDeclaration
313 BitFieldDeclaration
*syntaxCopy(Dsymbol
*) override
;
314 BitFieldDeclaration
*isBitFieldDeclaration() override final
{ return this; }
315 void accept(Visitor
*v
) override
{ v
->visit(this); }
318 /**************************************************************/
320 // This is a shell around a back end symbol
322 class SymbolDeclaration final
: public Declaration
325 AggregateDeclaration
*dsym
;
327 // Eliminate need for dynamic_cast
328 SymbolDeclaration
*isSymbolDeclaration() override
{ return (SymbolDeclaration
*)this; }
329 void accept(Visitor
*v
) override
{ v
->visit(this); }
332 class TypeInfoDeclaration
: public VarDeclaration
337 static TypeInfoDeclaration
*create(Type
*tinfo
);
338 TypeInfoDeclaration
*syntaxCopy(Dsymbol
*) override final
;
339 const char *toChars() const override final
;
341 TypeInfoDeclaration
*isTypeInfoDeclaration() override final
{ return this; }
342 void accept(Visitor
*v
) override
{ v
->visit(this); }
345 class TypeInfoStructDeclaration final
: public TypeInfoDeclaration
348 static TypeInfoStructDeclaration
*create(Type
*tinfo
);
350 void accept(Visitor
*v
) override
{ v
->visit(this); }
353 class TypeInfoClassDeclaration final
: public TypeInfoDeclaration
356 static TypeInfoClassDeclaration
*create(Type
*tinfo
);
358 void accept(Visitor
*v
) override
{ v
->visit(this); }
361 class TypeInfoInterfaceDeclaration final
: public TypeInfoDeclaration
364 static TypeInfoInterfaceDeclaration
*create(Type
*tinfo
);
366 void accept(Visitor
*v
) override
{ v
->visit(this); }
369 class TypeInfoPointerDeclaration final
: public TypeInfoDeclaration
372 static TypeInfoPointerDeclaration
*create(Type
*tinfo
);
374 void accept(Visitor
*v
) override
{ v
->visit(this); }
377 class TypeInfoArrayDeclaration final
: public TypeInfoDeclaration
380 static TypeInfoArrayDeclaration
*create(Type
*tinfo
);
382 void accept(Visitor
*v
) override
{ v
->visit(this); }
385 class TypeInfoStaticArrayDeclaration final
: public TypeInfoDeclaration
388 static TypeInfoStaticArrayDeclaration
*create(Type
*tinfo
);
390 void accept(Visitor
*v
) override
{ v
->visit(this); }
393 class TypeInfoAssociativeArrayDeclaration final
: public TypeInfoDeclaration
396 static TypeInfoAssociativeArrayDeclaration
*create(Type
*tinfo
);
398 void accept(Visitor
*v
) override
{ v
->visit(this); }
401 class TypeInfoEnumDeclaration final
: public TypeInfoDeclaration
404 static TypeInfoEnumDeclaration
*create(Type
*tinfo
);
406 void accept(Visitor
*v
) override
{ v
->visit(this); }
409 class TypeInfoFunctionDeclaration final
: public TypeInfoDeclaration
412 static TypeInfoFunctionDeclaration
*create(Type
*tinfo
);
414 void accept(Visitor
*v
) override
{ v
->visit(this); }
417 class TypeInfoDelegateDeclaration final
: public TypeInfoDeclaration
420 static TypeInfoDelegateDeclaration
*create(Type
*tinfo
);
422 void accept(Visitor
*v
) override
{ v
->visit(this); }
425 class TypeInfoTupleDeclaration final
: public TypeInfoDeclaration
428 static TypeInfoTupleDeclaration
*create(Type
*tinfo
);
430 void accept(Visitor
*v
) override
{ v
->visit(this); }
433 class TypeInfoConstDeclaration final
: public TypeInfoDeclaration
436 static TypeInfoConstDeclaration
*create(Type
*tinfo
);
438 void accept(Visitor
*v
) override
{ v
->visit(this); }
441 class TypeInfoInvariantDeclaration final
: public TypeInfoDeclaration
444 static TypeInfoInvariantDeclaration
*create(Type
*tinfo
);
446 void accept(Visitor
*v
) override
{ v
->visit(this); }
449 class TypeInfoSharedDeclaration final
: public TypeInfoDeclaration
452 static TypeInfoSharedDeclaration
*create(Type
*tinfo
);
454 void accept(Visitor
*v
) override
{ v
->visit(this); }
457 class TypeInfoWildDeclaration final
: public TypeInfoDeclaration
460 static TypeInfoWildDeclaration
*create(Type
*tinfo
);
462 void accept(Visitor
*v
) override
{ v
->visit(this); }
465 class TypeInfoVectorDeclaration final
: public TypeInfoDeclaration
468 static TypeInfoVectorDeclaration
*create(Type
*tinfo
);
470 void accept(Visitor
*v
) override
{ v
->visit(this); }
473 /**************************************************************/
475 class ThisDeclaration final
: public VarDeclaration
478 ThisDeclaration
*syntaxCopy(Dsymbol
*) override
;
479 ThisDeclaration
*isThisDeclaration() override
{ return this; }
480 void accept(Visitor
*v
) override
{ v
->visit(this); }
483 enum class ILS
: unsigned char
485 ILSuninitialized
, // not computed yet
486 ILSno
, // cannot inline
490 /**************************************************************/
492 enum class BUILTIN
: unsigned char
494 unknown
= 255, /// not known if this is a builtin
495 unimp
= 0, /// this is not a builtin
496 gcc
, /// this is a GCC builtin
497 llvm
, /// this is an LLVM builtin
533 Expression
*eval_builtin(const Loc
&loc
, FuncDeclaration
*fd
, Expressions
*arguments
);
534 BUILTIN
isBuiltin(FuncDeclaration
*fd
);
538 class FuncDeclaration
: public Declaration
543 FuncDeclarations foverrides
; // functions this function overrides
546 ContractInfo
*contracts
; // contract information
549 const char *mangleString
; // mangled symbol created from mangleExact()
551 VarDeclaration
*vresult
; // result variable for out contracts
552 LabelDsymbol
*returnLabel
; // where the return goes
554 void *isTypeIsolatedCache
; // An AA on the D side to cache an expensive check result
556 // used to prevent symbols in different
557 // scopes from having the same name
558 DsymbolTable
*localsymtab
;
559 VarDeclaration
*vthis
; // 'this' parameter (member and nested)
560 VarDeclaration
*v_arguments
; // '_arguments' parameter
562 VarDeclaration
*v_argptr
; // '_argptr' variable
563 VarDeclarations
*parameters
; // Array of VarDeclaration's for parameters
564 DsymbolTable
*labtab
; // statement label symbol table
565 Dsymbol
*overnext
; // next in overload list
566 FuncDeclaration
*overnext0
; // next in overload list (only used during IFTI)
567 Loc endloc
; // location of closing curly bracket
568 int vtblIndex
; // for member functions, index into vtbl[]
570 ILS inlineStatusStmt
;
574 int inlineNest
; // !=0 if nested inline
576 // true if errors in semantic3 this function's frame ptr
577 ForeachStatement
*fes
; // if foreach body, this is the foreach
578 BaseClass
* interfaceVirtual
; // if virtual, but only appears in interface vtbl[]
579 // if !=NULL, then this is the type
580 // of the 'introducing' function
581 // this one is overriding
583 StorageClass storage_class2
; // storage class for template onemember's
585 // Things that should really go into Scope
587 // 1 if there's a return exp; statement
588 // 2 if there's a throw statement
589 // 4 if there's an assert(0)
590 // 8 if there's inline asm
591 // 16 if there are multiple return statements
594 VarDeclaration
*nrvo_var
; // variable to replace with shidden
595 Symbol
*shidden
; // hidden pointer passed to function
597 ReturnStatements
*returns
;
599 GotoStatements
*gotos
; // Gotos with forward references
601 // set if this is a known, builtin function we can evaluate at compile time
604 // set if someone took the address of this function
606 d_bool requiresClosure
; // this function needs a closure
608 // local variables in this function which are referenced by nested functions
609 VarDeclarations closureVars
;
611 /** Outer variables which are referenced by this nested function
612 * (the inverse of closureVars)
614 VarDeclarations outerVars
;
616 // Sibling nested functions which called this one
617 FuncDeclarations siblingCallers
;
619 FuncDeclarations
*inlinedNestedCallees
;
621 AttributeViolation
* safetyViolation
;
622 AttributeViolation
* nogcViolation
;
623 AttributeViolation
* pureViolation
;
624 AttributeViolation
* nothrowViolation
;
626 // Formerly FUNCFLAGS
628 bool purityInprocess() const;
629 bool purityInprocess(bool v
);
630 bool safetyInprocess() const;
631 bool safetyInprocess(bool v
);
632 bool nothrowInprocess() const;
633 bool nothrowInprocess(bool v
);
634 bool nogcInprocess() const;
635 bool nogcInprocess(bool v
);
636 bool returnInprocess() const;
637 bool returnInprocess(bool v
);
638 bool inlineScanned() const;
639 bool inlineScanned(bool v
);
640 bool inferScope() const;
641 bool inferScope(bool v
);
642 bool hasCatches() const;
643 bool hasCatches(bool v
);
644 bool skipCodegen() const;
645 bool skipCodegen(bool v
);
650 bool noreturn() const;
651 bool noreturn(bool v
);
654 bool isNaked() const;
655 bool isNaked(bool v
);
656 bool isGenerated() const;
657 bool isGenerated(bool v
);
658 bool isIntroducing() const;
659 bool isIntroducing(bool v
);
660 bool hasSemantic3Errors() const;
661 bool hasSemantic3Errors(bool v
);
662 bool hasNoEH() const;
663 bool hasNoEH(bool v
);
664 bool inferRetType() const;
665 bool inferRetType(bool v
);
666 bool hasDualContext() const;
667 bool hasDualContext(bool v
);
668 bool hasAlwaysInlines() const;
669 bool hasAlwaysInlines(bool v
);
670 bool isCrtCtor() const;
671 bool isCrtCtor(bool v
);
672 bool isCrtDtor() const;
673 bool isCrtDtor(bool v
);
674 bool dllImport() const;
675 bool dllImport(bool v
);
676 bool dllExport() const;
677 bool dllExport(bool v
);
679 // Data for a function declaration that is needed for the Objective-C
681 ObjcFuncDeclaration objc
;
683 static FuncDeclaration
*create(const Loc
&loc
, const Loc
&endloc
, Identifier
*id
, StorageClass storage_class
, Type
*type
, bool noreturn
= false);
684 FuncDeclaration
*syntaxCopy(Dsymbol
*) override
;
685 Statements
*frequires();
687 Statement
*frequire();
688 Statement
*fensure();
689 FuncDeclaration
*fdrequire();
690 FuncDeclaration
*fdensure();
691 Expressions
*fdrequireParams();
692 Expressions
*fdensureParams();
693 Statements
*frequires(Statements
*frs
);
694 Ensures
*fensures(Statements
*fes
);
695 Statement
*frequire(Statement
*fr
);
696 Statement
*fensure(Statement
*fe
);
697 FuncDeclaration
*fdrequire(FuncDeclaration
*fdr
);
698 FuncDeclaration
*fdensure(FuncDeclaration
*fde
);
699 Expressions
*fdrequireParams(Expressions
*fdrp
);
700 Expressions
*fdensureParams(Expressions
*fdep
);
701 bool functionSemantic();
702 bool functionSemantic3();
703 bool equals(const RootObject
* const o
) const override final
;
705 int findVtblIndex(Dsymbols
*vtbl
, int dim
);
706 bool overloadInsert(Dsymbol
*s
) override
;
708 MATCH
leastAsSpecialized(FuncDeclaration
*g
, Identifiers
*names
);
709 LabelDsymbol
*searchLabel(Identifier
*ident
, const Loc
&loc
);
710 const char *toPrettyChars(bool QualifyTypes
= false) override
;
711 const char *toFullSignature(); // for diagnostics, e.g. 'int foo(int x, int y) pure'
713 bool isCMain() const;
714 bool isWinMain() const;
715 bool isDllMain() const;
716 bool isExport() const override final
;
717 bool isImportedSymbol() const override final
;
718 bool isCodeseg() const override final
;
719 bool isOverloadable() const override final
;
720 bool isAbstract() override final
;
726 virtual bool isNested() const;
727 AggregateDeclaration
*isThis() override
;
728 bool needThis() override final
;
729 bool isVirtualMethod();
730 virtual bool isVirtual() const;
731 bool isFinalFunc() const;
732 virtual bool addPreInvariant();
733 virtual bool addPostInvariant();
734 const char *kind() const override
;
738 bool hasNestedFrameRefs();
739 ParameterList
getParameterList();
741 static FuncDeclaration
*genCfunc(Parameters
*args
, Type
*treturn
, const char *name
, StorageClass stc
=0);
742 static FuncDeclaration
*genCfunc(Parameters
*args
, Type
*treturn
, Identifier
*id
, StorageClass stc
=0);
744 FuncDeclaration
*isFuncDeclaration() override final
{ return this; }
746 virtual FuncDeclaration
*toAliasFunc() { return this; }
747 void accept(Visitor
*v
) override
{ v
->visit(this); }
750 class FuncAliasDeclaration final
: public FuncDeclaration
753 FuncDeclaration
*funcalias
;
756 FuncAliasDeclaration
*isFuncAliasDeclaration() override
{ return this; }
757 const char *kind() const override
;
759 FuncDeclaration
*toAliasFunc() override
;
760 void accept(Visitor
*v
) override
{ v
->visit(this); }
763 class FuncLiteralDeclaration final
: public FuncDeclaration
766 TOK tok
; // TOKfunction or TOKdelegate
767 Type
*treq
; // target of return type inference
772 FuncLiteralDeclaration
*syntaxCopy(Dsymbol
*) override
;
773 bool isNested() const override
;
774 AggregateDeclaration
*isThis() override
;
775 bool isVirtual() const override
;
776 bool addPreInvariant() override
;
777 bool addPostInvariant() override
;
779 FuncLiteralDeclaration
*isFuncLiteralDeclaration() override
{ return this; }
780 const char *kind() const override
;
781 const char *toPrettyChars(bool QualifyTypes
= false) override
;
782 void accept(Visitor
*v
) override
{ v
->visit(this); }
785 class CtorDeclaration final
: public FuncDeclaration
789 CtorDeclaration
*syntaxCopy(Dsymbol
*) override
;
790 const char *kind() const override
;
791 const char *toChars() const override
;
792 bool isVirtual() const override
;
793 bool addPreInvariant() override
;
794 bool addPostInvariant() override
;
796 CtorDeclaration
*isCtorDeclaration() override
{ return this; }
797 void accept(Visitor
*v
) override
{ v
->visit(this); }
800 class PostBlitDeclaration final
: public FuncDeclaration
803 PostBlitDeclaration
*syntaxCopy(Dsymbol
*) override
;
804 bool isVirtual() const override
;
805 bool addPreInvariant() override
;
806 bool addPostInvariant() override
;
807 bool overloadInsert(Dsymbol
*s
) override
;
809 PostBlitDeclaration
*isPostBlitDeclaration() override
{ return this; }
810 void accept(Visitor
*v
) override
{ v
->visit(this); }
813 class DtorDeclaration final
: public FuncDeclaration
816 DtorDeclaration
*syntaxCopy(Dsymbol
*) override
;
817 const char *kind() const override
;
818 const char *toChars() const override
;
819 bool isVirtual() const override
;
820 bool addPreInvariant() override
;
821 bool addPostInvariant() override
;
822 bool overloadInsert(Dsymbol
*s
) override
;
824 DtorDeclaration
*isDtorDeclaration() override
{ return this; }
825 void accept(Visitor
*v
) override
{ v
->visit(this); }
828 class StaticCtorDeclaration
: public FuncDeclaration
831 StaticCtorDeclaration
*syntaxCopy(Dsymbol
*) override
;
832 AggregateDeclaration
*isThis() override final
;
833 bool isVirtual() const override final
;
834 bool addPreInvariant() override final
;
835 bool addPostInvariant() override final
;
836 bool hasStaticCtorOrDtor() override final
;
838 StaticCtorDeclaration
*isStaticCtorDeclaration() override final
{ return this; }
839 void accept(Visitor
*v
) override
{ v
->visit(this); }
842 class SharedStaticCtorDeclaration final
: public StaticCtorDeclaration
846 SharedStaticCtorDeclaration
*syntaxCopy(Dsymbol
*) override
;
848 SharedStaticCtorDeclaration
*isSharedStaticCtorDeclaration() override
{ return this; }
849 void accept(Visitor
*v
) override
{ v
->visit(this); }
852 class StaticDtorDeclaration
: public FuncDeclaration
855 VarDeclaration
*vgate
; // 'gate' variable
857 StaticDtorDeclaration
*syntaxCopy(Dsymbol
*) override
;
858 AggregateDeclaration
*isThis() override final
;
859 bool isVirtual() const override final
;
860 bool hasStaticCtorOrDtor() override final
;
861 bool addPreInvariant() override final
;
862 bool addPostInvariant() override final
;
864 StaticDtorDeclaration
*isStaticDtorDeclaration() override final
{ return this; }
865 void accept(Visitor
*v
) override
{ v
->visit(this); }
868 class SharedStaticDtorDeclaration final
: public StaticDtorDeclaration
871 SharedStaticDtorDeclaration
*syntaxCopy(Dsymbol
*) override
;
873 SharedStaticDtorDeclaration
*isSharedStaticDtorDeclaration() override
{ return this; }
874 void accept(Visitor
*v
) override
{ v
->visit(this); }
877 class InvariantDeclaration final
: public FuncDeclaration
880 InvariantDeclaration
*syntaxCopy(Dsymbol
*) override
;
881 bool isVirtual() const override
;
882 bool addPreInvariant() override
;
883 bool addPostInvariant() override
;
885 InvariantDeclaration
*isInvariantDeclaration() override
{ return this; }
886 void accept(Visitor
*v
) override
{ v
->visit(this); }
889 class UnitTestDeclaration final
: public FuncDeclaration
892 char *codedoc
; /** For documented unittest. */
894 // toObjFile() these nested functions after this one
895 FuncDeclarations deferredNested
;
897 UnitTestDeclaration
*syntaxCopy(Dsymbol
*) override
;
898 AggregateDeclaration
*isThis() override
;
899 bool isVirtual() const override
;
900 bool addPreInvariant() override
;
901 bool addPostInvariant() override
;
903 UnitTestDeclaration
*isUnitTestDeclaration() override
{ return this; }
904 void accept(Visitor
*v
) override
{ v
->visit(this); }
907 class NewDeclaration final
: public FuncDeclaration
910 NewDeclaration
*syntaxCopy(Dsymbol
*) override
;
911 const char *kind() const override
;
912 bool isVirtual() const override
;
913 bool addPreInvariant() override
;
914 bool addPostInvariant() override
;
916 NewDeclaration
*isNewDeclaration() override
{ return this; }
917 void accept(Visitor
*v
) override
{ v
->visit(this); }