2 * Defines enums common to dmd and dmd as parse library.
4 * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
5 * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
6 * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/astenums.d, _astenums.d)
7 * Documentation: https://dlang.org/phobos/dmd_astenums.html
8 * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/astenums.d
15 none
, /// size of aggregate is not yet able to compute
16 fwd
, /// size of aggregate is ready to compute
17 inProcess
, /// in the midst of computing the size
18 done
, /// size of aggregate is set correctly
23 none
, /// base classes not computed yet
24 start
, /// in process of resolving base classes
25 done
, /// all base classes are resolved
26 semanticdone
, /// all base classes semantic done
31 none
= 0, // default (mutable)
32 const_
= 1, // type is const
33 immutable_
= 4, // type is immutable
34 shared_
= 2, // type is shared
35 wild
= 8, // type is wild
36 wildconst
= (MODFlags
.wild | MODFlags
.const_
), // type is wild const
37 mutable
= 0x10, // type is mutable (only used in wildcard matching)
42 enum STC
: ulong // transfer changes to declaration.h
46 static_
= 1, /// `static`
47 extern_
= 2, /// `extern`
48 const_
= 4, /// `const`
49 final_
= 8, /// `final`
51 abstract_
= 0x10, /// `abstract`
52 parameter
= 0x20, /// is function parameter
53 field
= 0x40, /// is field of struct, union or class
54 override_
= 0x80, /// `override`
56 auto_
= 0x100, /// `auto`
57 synchronized_
= 0x200, /// `synchronized`
58 deprecated_
= 0x400, /// `deprecated`
59 in_
= 0x800, /// `in` parameter
61 out_
= 0x1000, /// `out` parameter
62 lazy_
= 0x2000, /// `lazy` parameter
63 foreach_
= 0x4000, /// variable for foreach loop
64 variadic
= 0x8000, /// the `variadic` parameter in: T foo(T a, U b, V variadic...)
67 templateparameter
= 0x2_0000, /// template parameter
68 ref_
= 0x4_0000, /// `ref`
69 scope_
= 0x8_0000, /// `scope`
71 scopeinferred
= 0x20_0000, /// `scope` has been inferred and should not be part of mangling, `scope_` must also be set
72 return_
= 0x40_0000, /// 'return ref' or 'return scope' for function parameters
73 returnScope
= 0x80_0000, /// if `ref return scope` then resolve to `ref` and `return scope`
75 returninferred
= 0x100_0000, /// `return` has been inferred and should not be part of mangling, `return_` must also be set
76 immutable_
= 0x200_0000, /// `immutable`
78 manifest
= 0x800_0000, /// manifest constant
80 nodtor
= 0x1000_0000, /// do not run destructor
81 nothrow_
= 0x2000_0000, /// `nothrow` meaning never throws exceptions
82 pure_
= 0x4000_0000, /// `pure` function
83 tls
= 0x8000_0000, /// thread local
85 alias_
= 0x1_0000_0000, /// `alias` parameter
86 shared_
= 0x2_0000_0000, /// accessible from multiple threads
87 gshared
= 0x4_0000_0000, /// accessible from multiple threads, but not typed as `shared`
88 wild
= 0x8_0000_0000, /// for wild type constructor
90 property
= 0x10_0000_0000, /// `@property`
91 safe
= 0x20_0000_0000, /// `@safe`
92 trusted
= 0x40_0000_0000, /// `@trusted`
93 system
= 0x80_0000_0000, /// `@system`
95 ctfe
= 0x100_0000_0000, /// can be used in CTFE, even if it is static
96 disable
= 0x200_0000_0000, /// for functions that are not callable
97 result
= 0x400_0000_0000, /// for result variables passed to out contracts
98 nodefaultctor
= 0x800_0000_0000, /// must be set inside constructor
100 temp
= 0x1000_0000_0000, /// temporary variable
101 rvalue
= 0x2000_0000_0000, /// force rvalue for variables
102 nogc
= 0x4000_0000_0000, /// `@nogc`
103 autoref
= 0x8000_0000_0000, /// Mark for the already deduced `auto ref` parameter
105 inference
= 0x1_0000_0000_0000, /// do attribute inference
106 exptemp
= 0x2_0000_0000_0000, /// temporary variable that has lifetime restricted to an expression
107 future
= 0x4_0000_0000_0000, /// introducing new base class function
108 local
= 0x8_0000_0000_0000, /// do not forward (see dmd.dsymbol.ForwardingScopeDsymbol).
110 live
= 0x10_0000_0000_0000, /// function `@live` attribute
111 register
= 0x20_0000_0000_0000, /// `register` storage class (ImportC)
112 volatile_
= 0x40_0000_0000_0000, /// destined for volatile in the back end
114 safeGroup
= STC
.safe | STC
.trusted | STC
.system
,
115 IOR
= STC
.in_ | STC
.ref_ | STC
.out_
,
116 TYPECTOR
= (STC
.const_ | STC
.immutable_ | STC
.shared_ | STC
.wild
),
117 FUNCATTR
= (STC
.ref_ | STC
.nothrow_ | STC
.nogc | STC
.pure_ | STC
.property | STC
.live |
120 /* These are visible to the user, i.e. are expressed by the user
122 visibleStorageClasses
=
123 (STC
.auto_ | STC
.scope_ | STC
.static_ | STC
.extern_ | STC
.const_ | STC
.final_ | STC
.abstract_ | STC
.synchronized_ |
124 STC
.deprecated_ | STC
.future | STC
.override_ | STC
.lazy_ | STC
.alias_ | STC
.out_ | STC
.in_ | STC
.manifest |
125 STC
.immutable_ | STC
.shared_ | STC
.wild | STC
.nothrow_ | STC
.nogc | STC
.pure_ | STC
.ref_ | STC
.return_ | STC
.tls | STC
.gshared |
126 STC
.property | STC
.safeGroup | STC
.disable | STC
.local | STC
.live
),
128 /* These storage classes "flow through" to the inner scope of a Dsymbol
130 flowThruAggregate
= STC
.safeGroup
, /// for an AggregateDeclaration
131 flowThruFunction
= ~(STC
.auto_ | STC
.scope_ | STC
.static_ | STC
.extern_ | STC
.abstract_ | STC
.deprecated_ | STC
.override_ |
132 STC
.TYPECTOR | STC
.final_ | STC
.tls | STC
.gshared | STC
.ref_ | STC
.return_ | STC
.property |
133 STC
.nothrow_ | STC
.pure_ | STC
.safe | STC
.trusted | STC
.system
), /// for a FuncDeclaration
137 alias StorageClass
= ulong;
140 * Determine if it's the ambigous case of where `return` attaches to.
144 * true if (`ref` | `out`) and `scope` and `return`
146 @safe pure @nogc nothrow
147 bool isRefReturnScope(const ulong stc)
149 return (stc & (STC
.scope_ | STC
.return_
)) == (STC
.scope_ | STC
.return_
) &&
150 stc & (STC
.ref_ | STC
.out_
);
153 /* This is different from the one in declaration.d, make that fix a separate PR */
155 extern (C
++) __gshared
const(StorageClass
) STCStorageClass
=
156 (STC
.auto_ | STC
.scope_ | STC
.static_ | STC
.extern_ | STC
.const_ | STC
.final_ |
157 STC
.abstract_ | STC
.synchronized_ | STC
.deprecated_ | STC
.override_ | STC
.lazy_ |
158 STC
.alias_ | STC
.out_ | STC
.in_ | STC
.manifest | STC
.immutable_ | STC
.shared_ |
159 STC
.wild | STC
.nothrow_ | STC
.nogc | STC
.pure_ | STC
.ref_ | STC
.return_ | STC
.tls |
160 STC
.gshared | STC
.property | STC
.live |
161 STC
.safeGroup | STC
.disable
);
165 Tarray
, // slice array, aka T[]
166 Tsarray
, // static array, aka T[dimension]
167 Taarray
, // associative array, aka T[type]
218 enum TMAX
= TY
.max
+ 1;
220 alias Tarray
= TY
.Tarray
;
221 alias Tsarray
= TY
.Tsarray
;
222 alias Taarray
= TY
.Taarray
;
223 alias Tpointer
= TY
.Tpointer
;
224 alias Treference
= TY
.Treference
;
225 alias Tfunction
= TY
.Tfunction
;
226 alias Tident
= TY
.Tident
;
227 alias Tclass
= TY
.Tclass
;
228 alias Tstruct
= TY
.Tstruct
;
229 alias Tenum
= TY
.Tenum
;
230 alias Tdelegate
= TY
.Tdelegate
;
231 alias Tnone
= TY
.Tnone
;
232 alias Tvoid
= TY
.Tvoid
;
233 alias Tint8
= TY
.Tint8
;
234 alias Tuns8
= TY
.Tuns8
;
235 alias Tint16
= TY
.Tint16
;
236 alias Tuns16
= TY
.Tuns16
;
237 alias Tint32
= TY
.Tint32
;
238 alias Tuns32
= TY
.Tuns32
;
239 alias Tint64
= TY
.Tint64
;
240 alias Tuns64
= TY
.Tuns64
;
241 alias Tfloat32
= TY
.Tfloat32
;
242 alias Tfloat64
= TY
.Tfloat64
;
243 alias Tfloat80
= TY
.Tfloat80
;
244 alias Timaginary32
= TY
.Timaginary32
;
245 alias Timaginary64
= TY
.Timaginary64
;
246 alias Timaginary80
= TY
.Timaginary80
;
247 alias Tcomplex32
= TY
.Tcomplex32
;
248 alias Tcomplex64
= TY
.Tcomplex64
;
249 alias Tcomplex80
= TY
.Tcomplex80
;
250 alias Tbool
= TY
.Tbool
;
251 alias Tchar
= TY
.Tchar
;
252 alias Twchar
= TY
.Twchar
;
253 alias Tdchar
= TY
.Tdchar
;
254 alias Terror
= TY
.Terror
;
255 alias Tinstance
= TY
.Tinstance
;
256 alias Ttypeof
= TY
.Ttypeof
;
257 alias Ttuple
= TY
.Ttuple
;
258 alias Tslice
= TY
.Tslice
;
259 alias Treturn
= TY
.Treturn
;
260 alias Tnull
= TY
.Tnull
;
261 alias Tvector
= TY
.Tvector
;
262 alias Tint128
= TY
.Tint128
;
263 alias Tuns128
= TY
.Tuns128
;
264 alias Ttraits
= TY
.Ttraits
;
265 alias Tmixin
= TY
.Tmixin
;
266 alias Tnoreturn
= TY
.Tnoreturn
;
267 alias Ttag
= TY
.Ttag
;
281 unknown
, /// not yet determined whether it's a package.d or not
282 module_
, /// already determined that's an actual package.d
283 package_
, /// already determined that's an actual package
286 enum ThreeState
: ubyte
288 none
, /// state is not yet computed
289 no
, /// state is false
290 yes
, /// state is true
296 system
= 1, // @system (same as TRUST.default)
297 trusted
= 2, // @trusted
303 impure
= 0, // not pure at all
304 fwdref
= 1, // it's pure, but not known which level yet
305 weak
= 2, // no mutable globals are read or written
306 const_
= 3, // parameters are values or const = strongly pure
309 // Whether alias this dependency is recursive or not
310 enum AliasThisRec
: int
312 no
= 0, // no alias this recursion
313 yes
= 1, // alias this has recursive dependency
314 fwdref
= 2, // not yet known
315 typeMask
= 3, // mask to read no/yes/fwdref
316 tracing
= 0x4, // mark in progress of implicitConvTo/deduceWild
317 tracingDT
= 0x8, // mark in progress of deduceType
321 * Variadic argument lists
322 * https://dlang.org/spec/function.html#variadic
326 none
= 0, /// fixed number of arguments
327 variadic
= 1, /// (T t, ...) can be C-style (core.stdc.stdarg) or D-style (core.vararg)
328 typesafe
= 2, /// (T t ...) typesafe https://dlang.org/spec/function.html#typesafe_variadic_functions
329 /// or https://dlang.org/spec/function.html#typesafe_variadic_functions
330 KRvariadic
= 3, /// K+R C style variadics (no function prototype)
333 /*************************
334 * Identify Statement types with this enum rather than
343 Compound
, CompoundDeclaration
, CompoundAsm
,
376 Asm
, InlineAsm
, GccAsm
,
380 /**********************
381 * Discriminant for which kind of initializer
383 enum InitKind
: ubyte
393 /// A linkage attribute as defined by `extern(XXX)`
395 /// https://dlang.org/spec/attribute.html#linkage
407 /// Whether to mangle an external aggregate as a struct or class, as set by `extern(C++, struct)`
408 enum CPPMANGLE
: ubyte
411 asStruct
, /// `extern(C++, struct)`
412 asClass
, /// `extern(C++, class)`
415 /// Function match levels
417 /// https://dlang.org/spec/function.html#function-overloading
420 nomatch
, /// no match
421 convert
, /// match with conversions
422 constant
, /// match with conversion to const
423 exact
, /// exact match
426 /// Inline setting as defined by `pragma(inline, XXX)`
429 default_
, /// as specified on the command line
430 never
, /// never inline
431 always
, /// always inline
435 enum FileType
: ubyte
437 d
, /// normal D source file
438 dhdr
, /// D header file (.di)
439 ddoc
, /// Ddoc documentation file (.dd)
443 extern (C
++) struct structalign_t
446 ushort value
= 0; // unknown
447 enum STRUCTALIGN_DEFAULT
= 1234; // default = match whatever the corresponding C compiler does
448 bool pack
; // use #pragma pack semantics
451 pure @safe @nogc nothrow:
452 bool isDefault() const { return value
== STRUCTALIGN_DEFAULT
; }
453 void setDefault() { value
= STRUCTALIGN_DEFAULT
; }
454 bool isUnknown() const { return value
== 0; } // value is not set
455 void setUnknown() { value
= 0; }
456 void set(uint value
) { this.value
= cast(ushort)value
; }
457 uint get() const { return value
; }
458 bool isPack() const { return pack
; }
459 void setPack(bool pack
) { this.pack
= pack
; }