d: Merge upstream dmd ff57fec515, druntime ff57fec515, phobos 17bafda79.
[official-gcc.git] / gcc / d / dmd / declaration.h
bloba65fb4467e556d4a572a082f7ea88acee48daa5d
2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2023 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
9 */
11 #pragma once
13 #include "dsymbol.h"
14 #include "mtype.h"
15 #include "objc.h"
16 #include "tokens.h"
18 class Expression;
19 class Statement;
20 class LabelDsymbol;
21 class Initializer;
22 class ForeachStatement;
23 struct Ensure
25 Identifier *id;
26 Statement *ensure;
28 class FuncDeclaration;
29 class StructDeclaration;
30 struct IntRange;
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 // 0x10000ULL
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`
68 // 0x4000000ULL
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
113 public:
114 Type *type;
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
120 uint8_t adFlags;
121 Symbol* isym; // import version of csym
122 DString mangleOverride; // overridden symbol with pragma(mangle, "...")
124 const char *kind() const override;
125 uinteger_t size(const Loc &loc) override final;
128 bool isStatic() const { return (storage_class & STCstatic) != 0; }
129 LINK resolvedLinkage() const; // returns the linkage, resolving the target-specific `System` one
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 isReturn() const { return (storage_class & STCreturn) != 0; }
142 bool isSynchronized() const { return (storage_class & STCsynchronized) != 0; }
143 bool isParameter() const { return (storage_class & STCparameter) != 0; }
144 bool isDeprecated() const override final { return (storage_class & STCdeprecated) != 0; }
145 bool isOverride() const { return (storage_class & STCoverride) != 0; }
146 bool isResult() const { return (storage_class & STCresult) != 0; }
147 bool isField() const { return (storage_class & STCfield) != 0; }
149 bool isIn() const { return (storage_class & STCin) != 0; }
150 bool isOut() const { return (storage_class & STCout) != 0; }
151 bool isRef() const { return (storage_class & STCref) != 0; }
152 bool isReference() const { return (storage_class & (STCref | STCout)) != 0; }
154 bool isFuture() const { return (storage_class & STCfuture) != 0; }
156 Visibility visible() override final;
158 Declaration *isDeclaration() override final { return this; }
159 void accept(Visitor *v) override { v->visit(this); }
162 /**************************************************************/
164 class TupleDeclaration final : public Declaration
166 public:
167 Objects *objects;
168 TypeTuple *tupletype; // !=NULL if this is a type tuple
169 d_bool isexp; // true: expression tuple
170 d_bool building; // it's growing in AliasAssign semantic
172 TupleDeclaration *syntaxCopy(Dsymbol *) override;
173 const char *kind() const override;
174 Type *getType() override;
175 Dsymbol *toAlias2() override;
176 bool needThis() override;
178 TupleDeclaration *isTupleDeclaration() override { return this; }
179 void accept(Visitor *v) override { v->visit(this); }
182 /**************************************************************/
184 class AliasDeclaration final : public Declaration
186 public:
187 Dsymbol *aliassym;
188 Dsymbol *overnext; // next in overload list
189 Dsymbol *_import; // !=NULL if unresolved internal alias for selective import
191 static AliasDeclaration *create(const Loc &loc, Identifier *id, Type *type);
192 AliasDeclaration *syntaxCopy(Dsymbol *) override;
193 bool overloadInsert(Dsymbol *s) override;
194 const char *kind() const override;
195 Type *getType() override;
196 Dsymbol *toAlias() override;
197 Dsymbol *toAlias2() override;
198 bool isOverloadable() const override;
200 AliasDeclaration *isAliasDeclaration() override { return this; }
201 void accept(Visitor *v) override { v->visit(this); }
204 /**************************************************************/
206 class OverDeclaration final : public Declaration
208 public:
209 Dsymbol *overnext; // next in overload list
210 Dsymbol *aliassym;
212 const char *kind() const override;
213 bool equals(const RootObject * const o) const override;
214 bool overloadInsert(Dsymbol *s) override;
216 Dsymbol *toAlias() override;
217 Dsymbol *isUnique();
218 bool isOverloadable() const override;
220 OverDeclaration *isOverDeclaration() override { return this; }
221 void accept(Visitor *v) override { v->visit(this); }
224 /**************************************************************/
226 class VarDeclaration : public Declaration
228 public:
229 Initializer *_init;
230 FuncDeclarations nestedrefs; // referenced by these lexically nested functions
231 TupleDeclaration *aliasTuple; // if `this` is really a tuple of declarations
232 VarDeclaration *lastVar; // Linked list of variables for goto-skips-init detection
233 Expression *edtor; // if !=NULL, does the destruction of the variable
234 IntRange *range; // if !NULL, the variable is known to be within the range
235 VarDeclarations *maybes; // STCmaybescope variables that are assigned to this STCmaybescope variable
237 unsigned endlinnum; // line number of end of scope that this var lives in
238 unsigned offset;
239 unsigned sequenceNumber; // order the variables are declared
240 structalign_t alignment;
242 // When interpreting, these point to the value (NULL if value not determinable)
243 // The index of this variable on the CTFE stack, ~0u if not allocated
244 unsigned ctfeAdrOnStack;
245 private:
246 uint32_t bitFields;
247 public:
248 int8_t canassign; // // it can be assigned to
249 uint8_t isdataseg; // private data for isDataseg
250 bool isargptr() const; // if parameter that _argptr points to
251 bool isargptr(bool v);
252 bool ctorinit() const; // it has been initialized in a ctor
253 bool ctorinit(bool v);
254 bool iscatchvar() const; // this is the exception object variable in catch() clause
255 bool iscatchvar(bool v);
256 bool isowner() const; // this is an Owner, despite it being `scope`
257 bool isowner(bool v);
258 bool setInCtorOnly() const; // field can only be set in a constructor, as it is const or immutable
259 bool setInCtorOnly(bool v);
260 bool onstack() const; // it is a class that was allocated on the stack
261 bool onstack(bool v);
262 bool overlapped() const; // if it is a field and has overlapping
263 bool overlapped(bool v);
264 bool overlapUnsafe() const; // if it is an overlapping field and the overlaps are unsafe
265 bool overlapUnsafe(bool v);
266 bool maybeScope() const; // allow inferring 'scope' for this variable
267 bool maybeScope(bool v);
268 bool doNotInferReturn() const; // do not infer 'return' for this variable
269 bool doNotInferReturn(bool v);
270 bool isArgDtorVar() const; // temporary created to handle scope destruction of a function argument
271 bool isArgDtorVar(bool v);
272 bool isCmacro() const; // if a C macro turned into a C variable
273 bool isCmacro(bool v);
274 #if MARS
275 bool inClosure() const; // is inserted into a GC allocated closure
276 bool inClosure(bool v);
277 bool inAlignSection() const; // is inserted into aligned section on stack
278 bool inAlignSection(bool v);
279 #endif
280 bool systemInferred() const;
281 bool systemInferred(bool v);
282 static VarDeclaration *create(const Loc &loc, Type *t, Identifier *id, Initializer *init, StorageClass storage_class = STCundefined);
283 VarDeclaration *syntaxCopy(Dsymbol *) override;
284 void setFieldOffset(AggregateDeclaration *ad, FieldState& fieldState, bool isunion) override final;
285 const char *kind() const override;
286 AggregateDeclaration *isThis() override final;
287 bool needThis() override final;
288 bool isExport() const override final;
289 bool isImportedSymbol() const override final;
290 bool isCtorinit() const;
291 bool isDataseg() override final;
292 bool isThreadlocal() override final;
293 bool isCTFE();
294 bool isOverlappedWith(VarDeclaration *v);
295 bool hasPointers() override final;
296 bool canTakeAddressOf();
297 bool needsScopeDtor();
298 void checkCtorConstInit() override final;
299 Dsymbol *toAlias() override final;
300 // Eliminate need for dynamic_cast
301 VarDeclaration *isVarDeclaration() override final { return (VarDeclaration *)this; }
302 void accept(Visitor *v) override { v->visit(this); }
305 /**************************************************************/
307 class BitFieldDeclaration : public VarDeclaration
309 public:
310 Expression *width;
312 unsigned fieldWidth;
313 unsigned bitOffset;
315 BitFieldDeclaration *syntaxCopy(Dsymbol *) override;
316 BitFieldDeclaration *isBitFieldDeclaration() override final { return this; }
317 void accept(Visitor *v) override { v->visit(this); }
320 /**************************************************************/
322 // This is a shell around a back end symbol
324 class SymbolDeclaration final : public Declaration
326 public:
327 AggregateDeclaration *dsym;
329 // Eliminate need for dynamic_cast
330 SymbolDeclaration *isSymbolDeclaration() override { return (SymbolDeclaration *)this; }
331 void accept(Visitor *v) override { v->visit(this); }
334 class TypeInfoDeclaration : public VarDeclaration
336 public:
337 Type *tinfo;
339 static TypeInfoDeclaration *create(Type *tinfo);
340 TypeInfoDeclaration *syntaxCopy(Dsymbol *) override final;
341 const char *toChars() const override final;
343 TypeInfoDeclaration *isTypeInfoDeclaration() override final { return this; }
344 void accept(Visitor *v) override { v->visit(this); }
347 class TypeInfoStructDeclaration final : public TypeInfoDeclaration
349 public:
350 static TypeInfoStructDeclaration *create(Type *tinfo);
352 void accept(Visitor *v) override { v->visit(this); }
355 class TypeInfoClassDeclaration final : public TypeInfoDeclaration
357 public:
358 static TypeInfoClassDeclaration *create(Type *tinfo);
360 void accept(Visitor *v) override { v->visit(this); }
363 class TypeInfoInterfaceDeclaration final : public TypeInfoDeclaration
365 public:
366 static TypeInfoInterfaceDeclaration *create(Type *tinfo);
368 void accept(Visitor *v) override { v->visit(this); }
371 class TypeInfoPointerDeclaration final : public TypeInfoDeclaration
373 public:
374 static TypeInfoPointerDeclaration *create(Type *tinfo);
376 void accept(Visitor *v) override { v->visit(this); }
379 class TypeInfoArrayDeclaration final : public TypeInfoDeclaration
381 public:
382 static TypeInfoArrayDeclaration *create(Type *tinfo);
384 void accept(Visitor *v) override { v->visit(this); }
387 class TypeInfoStaticArrayDeclaration final : public TypeInfoDeclaration
389 public:
390 static TypeInfoStaticArrayDeclaration *create(Type *tinfo);
392 void accept(Visitor *v) override { v->visit(this); }
395 class TypeInfoAssociativeArrayDeclaration final : public TypeInfoDeclaration
397 public:
398 static TypeInfoAssociativeArrayDeclaration *create(Type *tinfo);
400 void accept(Visitor *v) override { v->visit(this); }
403 class TypeInfoEnumDeclaration final : public TypeInfoDeclaration
405 public:
406 static TypeInfoEnumDeclaration *create(Type *tinfo);
408 void accept(Visitor *v) override { v->visit(this); }
411 class TypeInfoFunctionDeclaration final : public TypeInfoDeclaration
413 public:
414 static TypeInfoFunctionDeclaration *create(Type *tinfo);
416 void accept(Visitor *v) override { v->visit(this); }
419 class TypeInfoDelegateDeclaration final : public TypeInfoDeclaration
421 public:
422 static TypeInfoDelegateDeclaration *create(Type *tinfo);
424 void accept(Visitor *v) override { v->visit(this); }
427 class TypeInfoTupleDeclaration final : public TypeInfoDeclaration
429 public:
430 static TypeInfoTupleDeclaration *create(Type *tinfo);
432 void accept(Visitor *v) override { v->visit(this); }
435 class TypeInfoConstDeclaration final : public TypeInfoDeclaration
437 public:
438 static TypeInfoConstDeclaration *create(Type *tinfo);
440 void accept(Visitor *v) override { v->visit(this); }
443 class TypeInfoInvariantDeclaration final : public TypeInfoDeclaration
445 public:
446 static TypeInfoInvariantDeclaration *create(Type *tinfo);
448 void accept(Visitor *v) override { v->visit(this); }
451 class TypeInfoSharedDeclaration final : public TypeInfoDeclaration
453 public:
454 static TypeInfoSharedDeclaration *create(Type *tinfo);
456 void accept(Visitor *v) override { v->visit(this); }
459 class TypeInfoWildDeclaration final : public TypeInfoDeclaration
461 public:
462 static TypeInfoWildDeclaration *create(Type *tinfo);
464 void accept(Visitor *v) override { v->visit(this); }
467 class TypeInfoVectorDeclaration final : public TypeInfoDeclaration
469 public:
470 static TypeInfoVectorDeclaration *create(Type *tinfo);
472 void accept(Visitor *v) override { v->visit(this); }
475 /**************************************************************/
477 class ThisDeclaration final : public VarDeclaration
479 public:
480 ThisDeclaration *syntaxCopy(Dsymbol *) override;
481 ThisDeclaration *isThisDeclaration() override { return this; }
482 void accept(Visitor *v) override { v->visit(this); }
485 enum class ILS : unsigned char
487 ILSuninitialized, // not computed yet
488 ILSno, // cannot inline
489 ILSyes // can 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
500 sin,
501 cos,
502 tan,
503 sqrt,
504 fabs,
505 ldexp,
506 log,
507 log2,
508 log10,
509 exp,
510 expm1,
511 exp2,
512 round,
513 floor,
514 ceil,
515 trunc,
516 copysign,
517 pow,
518 fmin,
519 fmax,
520 fma,
521 isnan,
522 isinfinity,
523 isfinite,
524 bsf,
525 bsr,
526 bswap,
527 popcnt,
528 yl2x,
529 yl2xp1,
530 toPrecFloat,
531 toPrecDouble,
532 toPrecReal
535 Expression *eval_builtin(const Loc &loc, FuncDeclaration *fd, Expressions *arguments);
536 BUILTIN isBuiltin(FuncDeclaration *fd);
538 struct ContractInfo;
540 class FuncDeclaration : public Declaration
542 public:
543 Statement *fbody;
545 FuncDeclarations foverrides; // functions this function overrides
547 private:
548 ContractInfo *contracts; // contract information
550 public:
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;
573 ILS inlineStatusExp;
574 PINLINE inlining;
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
584 Type *tintro;
585 StorageClass storage_class2; // storage class for template onemember's
587 // Things that should really go into Scope
589 // 1 if there's a return exp; statement
590 // 2 if there's a throw statement
591 // 4 if there's an assert(0)
592 // 8 if there's inline asm
593 // 16 if there are multiple return statements
594 int hasReturnExp;
596 VarDeclaration *nrvo_var; // variable to replace with shidden
597 Symbol *shidden; // hidden pointer passed to function
599 ReturnStatements *returns;
601 GotoStatements *gotos; // Gotos with forward references
603 // set if this is a known, builtin function we can evaluate at compile time
604 BUILTIN builtin;
606 // set if someone took the address of this function
607 int tookAddressOf;
608 d_bool requiresClosure; // this function needs a closure
610 // local variables in this function which are referenced by nested functions
611 VarDeclarations closureVars;
613 /** Outer variables which are referenced by this nested function
614 * (the inverse of closureVars)
616 VarDeclarations outerVars;
618 // Sibling nested functions which called this one
619 FuncDeclarations siblingCallers;
621 FuncDeclarations *inlinedNestedCallees;
623 AttributeViolation* safetyViolation;
624 AttributeViolation* nogcViolation;
625 AttributeViolation* pureViolation;
626 AttributeViolation* nothrowViolation;
628 // Formerly FUNCFLAGS
629 uint32_t flags;
630 bool purityInprocess() const;
631 bool purityInprocess(bool v);
632 bool safetyInprocess() const;
633 bool safetyInprocess(bool v);
634 bool nothrowInprocess() const;
635 bool nothrowInprocess(bool v);
636 bool nogcInprocess() const;
637 bool nogcInprocess(bool v);
638 bool returnInprocess() const;
639 bool returnInprocess(bool v);
640 bool inlineScanned() const;
641 bool inlineScanned(bool v);
642 bool inferScope() const;
643 bool inferScope(bool v);
644 bool hasCatches() const;
645 bool hasCatches(bool v);
646 bool skipCodegen() const;
647 bool skipCodegen(bool v);
648 bool printf() const;
649 bool printf(bool v);
650 bool scanf() const;
651 bool scanf(bool v);
652 bool noreturn() const;
653 bool noreturn(bool v);
654 bool isNRVO() const;
655 bool isNRVO(bool v);
656 bool isNaked() const;
657 bool isNaked(bool v);
658 bool isGenerated() const;
659 bool isGenerated(bool v);
660 bool isIntroducing() const;
661 bool isIntroducing(bool v);
662 bool hasSemantic3Errors() const;
663 bool hasSemantic3Errors(bool v);
664 bool hasNoEH() const;
665 bool hasNoEH(bool v);
666 bool inferRetType() const;
667 bool inferRetType(bool v);
668 bool hasDualContext() const;
669 bool hasDualContext(bool v);
670 bool hasAlwaysInlines() const;
671 bool hasAlwaysInlines(bool v);
672 bool isCrtCtor() const;
673 bool isCrtCtor(bool v);
674 bool isCrtDtor() const;
675 bool isCrtDtor(bool v);
676 bool dllImport() const;
677 bool dllImport(bool v);
678 bool dllExport() const;
679 bool dllExport(bool v);
681 // Data for a function declaration that is needed for the Objective-C
682 // integration.
683 ObjcFuncDeclaration objc;
685 static FuncDeclaration *create(const Loc &loc, const Loc &endloc, Identifier *id, StorageClass storage_class, Type *type, bool noreturn = false);
686 FuncDeclaration *syntaxCopy(Dsymbol *) override;
687 Statements *frequires();
688 Ensures *fensures();
689 Statement *frequire();
690 Statement *fensure();
691 FuncDeclaration *fdrequire();
692 FuncDeclaration *fdensure();
693 Expressions *fdrequireParams();
694 Expressions *fdensureParams();
695 Statements *frequires(Statements *frs);
696 Ensures *fensures(Statements *fes);
697 Statement *frequire(Statement *fr);
698 Statement *fensure(Statement *fe);
699 FuncDeclaration *fdrequire(FuncDeclaration *fdr);
700 FuncDeclaration *fdensure(FuncDeclaration *fde);
701 Expressions *fdrequireParams(Expressions *fdrp);
702 Expressions *fdensureParams(Expressions *fdep);
703 bool functionSemantic();
704 bool functionSemantic3();
705 bool equals(const RootObject * const o) const override final;
707 int findVtblIndex(Dsymbols *vtbl, int dim);
708 bool overloadInsert(Dsymbol *s) override;
709 bool inUnittest();
710 MATCH leastAsSpecialized(FuncDeclaration *g, Identifiers *names);
711 LabelDsymbol *searchLabel(Identifier *ident, const Loc &loc);
712 const char *toPrettyChars(bool QualifyTypes = false) override;
713 const char *toFullSignature(); // for diagnostics, e.g. 'int foo(int x, int y) pure'
714 bool isMain() const;
715 bool isCMain() const;
716 bool isWinMain() const;
717 bool isDllMain() const;
718 bool isExport() const override final;
719 bool isImportedSymbol() const override final;
720 bool isCodeseg() const override final;
721 bool isOverloadable() const override final;
722 bool isAbstract() override final;
723 PURE isPure();
724 bool isSafe();
725 bool isTrusted();
726 bool isNogc();
728 virtual bool isNested() const;
729 AggregateDeclaration *isThis() override;
730 bool needThis() override final;
731 bool isVirtualMethod();
732 virtual bool isVirtual() const;
733 bool isFinalFunc() const;
734 virtual bool addPreInvariant();
735 virtual bool addPostInvariant();
736 const char *kind() const override;
737 bool isUnique();
738 bool needsClosure();
739 bool checkClosure();
740 bool hasNestedFrameRefs();
741 ParameterList getParameterList();
743 static FuncDeclaration *genCfunc(Parameters *args, Type *treturn, const char *name, StorageClass stc=0);
744 static FuncDeclaration *genCfunc(Parameters *args, Type *treturn, Identifier *id, StorageClass stc=0);
746 FuncDeclaration *isFuncDeclaration() override final { return this; }
748 virtual FuncDeclaration *toAliasFunc() { return this; }
749 void accept(Visitor *v) override { v->visit(this); }
752 class FuncAliasDeclaration final : public FuncDeclaration
754 public:
755 FuncDeclaration *funcalias;
756 d_bool hasOverloads;
758 FuncAliasDeclaration *isFuncAliasDeclaration() override { return this; }
759 const char *kind() const override;
761 FuncDeclaration *toAliasFunc() override;
762 void accept(Visitor *v) override { v->visit(this); }
765 class FuncLiteralDeclaration final : public FuncDeclaration
767 public:
768 TOK tok; // TOKfunction or TOKdelegate
769 Type *treq; // target of return type inference
771 // backend
772 d_bool deferToObj;
774 FuncLiteralDeclaration *syntaxCopy(Dsymbol *) override;
775 bool isNested() const override;
776 AggregateDeclaration *isThis() override;
777 bool isVirtual() const override;
778 bool addPreInvariant() override;
779 bool addPostInvariant() override;
781 FuncLiteralDeclaration *isFuncLiteralDeclaration() override { return this; }
782 const char *kind() const override;
783 const char *toPrettyChars(bool QualifyTypes = false) override;
784 void accept(Visitor *v) override { v->visit(this); }
787 class CtorDeclaration final : public FuncDeclaration
789 public:
790 d_bool isCpCtor;
791 CtorDeclaration *syntaxCopy(Dsymbol *) override;
792 const char *kind() const override;
793 const char *toChars() const override;
794 bool isVirtual() const override;
795 bool addPreInvariant() override;
796 bool addPostInvariant() override;
798 CtorDeclaration *isCtorDeclaration() override { return this; }
799 void accept(Visitor *v) override { v->visit(this); }
802 class PostBlitDeclaration final : public FuncDeclaration
804 public:
805 PostBlitDeclaration *syntaxCopy(Dsymbol *) override;
806 bool isVirtual() const override;
807 bool addPreInvariant() override;
808 bool addPostInvariant() override;
809 bool overloadInsert(Dsymbol *s) override;
811 PostBlitDeclaration *isPostBlitDeclaration() override { return this; }
812 void accept(Visitor *v) override { v->visit(this); }
815 class DtorDeclaration final : public FuncDeclaration
817 public:
818 DtorDeclaration *syntaxCopy(Dsymbol *) override;
819 const char *kind() const override;
820 const char *toChars() const override;
821 bool isVirtual() const override;
822 bool addPreInvariant() override;
823 bool addPostInvariant() override;
824 bool overloadInsert(Dsymbol *s) override;
826 DtorDeclaration *isDtorDeclaration() override { return this; }
827 void accept(Visitor *v) override { v->visit(this); }
830 class StaticCtorDeclaration : public FuncDeclaration
832 public:
833 StaticCtorDeclaration *syntaxCopy(Dsymbol *) override;
834 AggregateDeclaration *isThis() override final;
835 bool isVirtual() const override final;
836 bool addPreInvariant() override final;
837 bool addPostInvariant() override final;
838 bool hasStaticCtorOrDtor() override final;
840 StaticCtorDeclaration *isStaticCtorDeclaration() override final { return this; }
841 void accept(Visitor *v) override { v->visit(this); }
844 class SharedStaticCtorDeclaration final : public StaticCtorDeclaration
846 public:
847 SharedStaticCtorDeclaration *syntaxCopy(Dsymbol *) override;
849 SharedStaticCtorDeclaration *isSharedStaticCtorDeclaration() override { return this; }
850 void accept(Visitor *v) override { v->visit(this); }
853 class StaticDtorDeclaration : public FuncDeclaration
855 public:
856 VarDeclaration *vgate; // 'gate' variable
858 StaticDtorDeclaration *syntaxCopy(Dsymbol *) override;
859 AggregateDeclaration *isThis() override final;
860 bool isVirtual() const override final;
861 bool hasStaticCtorOrDtor() override final;
862 bool addPreInvariant() override final;
863 bool addPostInvariant() override final;
865 StaticDtorDeclaration *isStaticDtorDeclaration() override final { return this; }
866 void accept(Visitor *v) override { v->visit(this); }
869 class SharedStaticDtorDeclaration final : public StaticDtorDeclaration
871 public:
872 SharedStaticDtorDeclaration *syntaxCopy(Dsymbol *) override;
874 SharedStaticDtorDeclaration *isSharedStaticDtorDeclaration() override { return this; }
875 void accept(Visitor *v) override { v->visit(this); }
878 class InvariantDeclaration final : public FuncDeclaration
880 public:
881 InvariantDeclaration *syntaxCopy(Dsymbol *) override;
882 bool isVirtual() const override;
883 bool addPreInvariant() override;
884 bool addPostInvariant() override;
886 InvariantDeclaration *isInvariantDeclaration() override { return this; }
887 void accept(Visitor *v) override { v->visit(this); }
890 class UnitTestDeclaration final : public FuncDeclaration
892 public:
893 char *codedoc; /** For documented unittest. */
895 // toObjFile() these nested functions after this one
896 FuncDeclarations deferredNested;
898 UnitTestDeclaration *syntaxCopy(Dsymbol *) override;
899 AggregateDeclaration *isThis() override;
900 bool isVirtual() const override;
901 bool addPreInvariant() override;
902 bool addPostInvariant() override;
904 UnitTestDeclaration *isUnitTestDeclaration() override { return this; }
905 void accept(Visitor *v) override { v->visit(this); }
908 class NewDeclaration final : public FuncDeclaration
910 public:
911 NewDeclaration *syntaxCopy(Dsymbol *) override;
912 const char *kind() const override;
913 bool isVirtual() const override;
914 bool addPreInvariant() override;
915 bool addPostInvariant() override;
917 NewDeclaration *isNewDeclaration() override { return this; }
918 void accept(Visitor *v) override { v->visit(this); }