]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/d/dmd/scope.h
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/scope.h
18 class SwitchStatement
;
19 class TryFinallyStatement
;
21 class ForeachStatement
;
22 class ClassDeclaration
;
23 class AggregateDeclaration
;
24 class FuncDeclaration
;
25 class UserAttributeDeclaration
;
28 class TemplateInstance
;
33 // Requires a full definition for LINK
40 #define CSXthis_ctor 1 // called this()
41 #define CSXsuper_ctor 2 // called super()
42 #define CSXthis 4 // referenced this
43 #define CSXsuper 8 // referenced super
44 #define CSXlabel 0x10 // seen a label
45 #define CSXreturn 0x20 // seen a return statement
46 #define CSXany_ctor 0x40 // either this() or super() was called
47 #define CSXhalt 0x80 // assert(0)
49 // Flags that would not be inherited beyond scope nesting
50 #define SCOPEctor 0x0001 // constructor type
51 #define SCOPEcondition 0x0004 // inside static if/assert condition
52 #define SCOPEdebug 0x0008 // inside debug conditional
54 // Flags that would be inherited beyond scope nesting
55 #define SCOPEnoaccesscheck 0x0002 // don't do access checks
56 #define SCOPEconstraint 0x0010 // inside template constraint
57 #define SCOPEinvariant 0x0020 // inside invariant code
58 #define SCOPErequire 0x0040 // inside in contract code
59 #define SCOPEensure 0x0060 // inside out contract code
60 #define SCOPEcontract 0x0060 // [mask] we're inside contract code
61 #define SCOPEctfe 0x0080 // inside a ctfe-only expression
62 #define SCOPEcompile 0x0100 // inside __traits(compile)
63 #define SCOPEignoresymbolvisibility 0x0200 // ignore symbol visibility (Bugzilla 15907)
65 #define SCOPEfree 0x8000 // is on free list
66 #define SCOPEfullinst 0x10000 // fully instantiate templates
67 #define SCOPEalias 0x20000 // inside alias declaration
71 Scope
*enclosing
; // enclosing Scope
73 Module
*_module
; // Root module
74 ScopeDsymbol
*scopesym
; // current symbol
75 FuncDeclaration
*func
; // function we are in
76 Dsymbol
*parent
; // parent to use
77 LabelStatement
*slabel
; // enclosing labelled statement
78 SwitchStatement
*sw
; // enclosing switch statement
79 TryFinallyStatement
*tf
; // enclosing try finally statement
80 ScopeGuardStatement
*os
; // enclosing scope(xxx) statement
81 Statement
*sbreak
; // enclosing statement that supports "break"
82 Statement
*scontinue
; // enclosing statement that supports "continue"
83 ForeachStatement
*fes
; // if nested function for ForeachStatement, this is it
84 Scope
*callsc
; // used for __FUNCTION__, __PRETTY_FUNCTION__ and __MODULE__
85 int inunion
; // we're processing members of a union
86 int nofree
; // set if shouldn't free it
87 int noctor
; // set if constructor calls aren't allowed
88 int intypeof
; // in typeof(exp)
89 VarDeclaration
*lastVar
; // Previous symbol used to prevent goto-skips-init
91 /* If minst && !tinst, it's in definitely non-speculative scope (eg. module member scope).
92 * If !minst && !tinst, it's in definitely speculative scope (eg. template constraint).
93 * If minst && tinst, it's in instantiated code scope without speculation.
94 * If !minst && tinst, it's in instantiated code scope with speculation.
96 Module
*minst
; // root module where the instantiated templates should belong to
97 TemplateInstance
*tinst
; // enclosing template instance
99 unsigned callSuper
; // primitive flow analysis for constructors
101 size_t fieldinit_dim
;
103 AlignDeclaration
*aligndecl
; // alignment for struct members
105 LINK linkage
; // linkage for external functions
106 CPPMANGLE cppmangle
; // C++ mangle type
107 PINLINE inlining
; // inlining strategy for functions
109 Prot protection
; // protection for class members
110 int explicitProtection
; // set if in an explicit protection attribute
112 StorageClass stc
; // storage class
114 DeprecatedDeclaration
*depdecl
; // customized deprecation message
118 UserAttributeDeclaration
*userAttribDecl
; // user defined attributes
120 DocComment
*lastdc
; // documentation comment for last symbol at this scope
121 AA
*anchorCounts
; // lookup duplicate anchor name count
122 Identifier
*prevAnchor
; // qualified symbol name of last doc anchor
124 static Scope
*freelist
;
125 static Scope
*alloc();
126 static Scope
*createGlobal(Module
*module
);
133 Scope
*push(ScopeDsymbol
*ss
);
139 void mergeCallSuper(Loc loc
, unsigned cs
);
141 unsigned *saveFieldInit();
142 void mergeFieldInit(Loc loc
, unsigned *cses
);
144 Module
*instantiatingModule();
146 Dsymbol
*search(Loc loc
, Identifier
*ident
, Dsymbol
**pscopesym
, int flags
= IgnoreNone
);
147 Dsymbol
*search_correct(Identifier
*ident
);
148 static const char *search_correct_C(Identifier
*ident
);
149 Dsymbol
*insert(Dsymbol
*s
);
151 ClassDeclaration
*getClassScope();
152 AggregateDeclaration
*getStructClassScope();
155 structalign_t
alignment();