TypeTraits

This is a shell containing a TraitsExp that can be either resolved to a type or to a symbol.

The point is to allow AliasDeclarationY to use __traits(), see https://issues.dlang.org/show_bug.cgi?id=7804.

extern (C++) final
class TypeTraits : Type {
Loc loc;
}

Members

Variables

exp
TraitsExp exp;

The expression to resolve as type or symbol.

obj
RootObject obj;

Cached type/symbol after semantic analysis.

Inherited Members

From Type

getUniqueID
size_t getUniqueID()

Returns a non-zero unique ID for this Type, or returns 0 if the Type does not (yet) have a unique ID. If semantic() has not been run, 0 is returned.

covariant
Covariant covariant(Type t, StorageClass* pstc, bool cppCovariant)

Covariant means that 'this' can substitute for 't', i.e. a pure function is a match for an impure type.

toChars
const(char)* toChars()
toPrettyChars
char* toPrettyChars(bool QualifyTypes)

For pretty-printing a type.

deinitialize
void deinitialize()

Deinitializes the global state of the compiler.

merge2
Type merge2()

This version does a merge even if the deco is already computed. Necessary for types that have a deco, but are not merged.

modToBuffer
void modToBuffer(OutBuffer buf)

Store this type's modifier name into buf.

modToChars
char* modToChars()

Return this type's modifier name.

isAssignable
bool isAssignable()

When T is mutable, Given: T a, b; Can we bitwise assign: a = b; ?

isBoolean
bool isBoolean()

Returns true if T can be converted to boolean value.

checkDeprecated
void checkDeprecated(Loc loc, Scope* sc)

Check type to see if it is based on a deprecated symbol.

nullAttributes
Type nullAttributes()

Return a copy of this type with all attributes null-initialized. Useful for creating a type with different modifiers.

constOf
Type constOf()

Convert to 'const'.

immutableOf
Type immutableOf()

Convert to 'immutable'.

mutableOf
Type mutableOf()

Make type mutable.

unSharedOf
Type unSharedOf()

Make type unshared. 0 => 0 const => const immutable => immutable shared => 0 shared const => const wild => wild wild const => wild const shared wild => wild shared wild const => wild const

wildOf
Type wildOf()

Convert to 'wild'.

fixTo
void fixTo(Type t)

For our new type 'this', which is type-constructed from t, fill in the cto, ito, sto, scto, wto shortcuts.

check
void check()

Look for bugs in constructing types.

addSTC
Type addSTC(StorageClass stc)

Apply STCxxxx bits to existing type. Use *before* semantic analysis is run.

castMod
Type castMod(MOD mod)

Apply MODxxxx bits to existing type.

addMod
Type addMod(MOD mod)

Add MODxxxx bits to existing type. We're adding, not replacing, so adding const to a shared type => "shared const"

addStorageClass
Type addStorageClass(StorageClass stc)

Add storage class modifiers to type.

checkAliasThisRec
bool checkAliasThisRec()

Check whether this type has endless alias this recursion.

toBasetype
Type toBasetype()

If this is a shell around another type, get that other type.

implicitConvTo
MATCH implicitConvTo(Type to)

Determine if 'this' can be implicitly converted to type 'to'.

constConv
MATCH constConv(Type to)

Determine if converting 'this' to 'to' is an identity operation, a conversion to const operation, or the types aren't the same.

deduceWild
MOD deduceWild(Type t, bool isRef)

Compute MOD bits matching this argument type to wild parameter type.

toHeadMutable
inout(Type) toHeadMutable()

Return type with the top level of it being mutable.

alignment
structalign_t alignment()

Return alignment to use for this type.

defaultInitLiteral
Expression defaultInitLiteral(Loc loc)

Use when we prefer the default initializer to be a literal, rather than a global immutable variable.

hasWild
int hasWild()

Return !=0 if the type or any of its subtypes is wild.

hasPointers
bool hasPointers()

Return !=0 if type has pointers that need to be scanned by the GC during a collection cycle.

hasVoidInitPointers
bool hasVoidInitPointers()

Detect if type has pointer fields that are initialized to void. Local stack variables with such void fields can remain uninitialized, leading to pointer bugs.

hasSystemFields
bool hasSystemFields()

Detect if this is an unsafe type because of the presence of @system members

hasInvariant
bool hasInvariant()
nextOf
Type nextOf()

If this is a type of something, return that something.

baseElemOf
Type baseElemOf()

If this is a type of static array, return its base element type.

numberOfElems
uint numberOfElems(Loc loc)

Compute number of elements for a (possibly multidimensional) static array, or 1 for other types.

sizemask
uinteger_t sizemask()

Return the mask that an integral type will fit into.

needsDestruction
bool needsDestruction()

true if when type goes out of scope, it needs a destructor applied. Only applies to value types, not ref types.

needsCopyOrPostblit
bool needsCopyOrPostblit()

true if when type is copied, it needs a copy constructor or postblit applied. Only applies to value types, not ref types.

needsNested
bool needsNested()
checkComplexTransition
bool checkComplexTransition(Loc loc, Scope* sc)

https://issues.dlang.org/show_bug.cgi?id=14488

Check if the inner most base type is complex or imaginary. Should only give alerts when set to emit transitional messages.

isPtrToFunction
inout(TypeFunction) isPtrToFunction()

Is this type a pointer to a function?

isFunction_Delegate_PtrToFunction
inout(TypeFunction) isFunction_Delegate_PtrToFunction()

Is this type a function, delegate, or pointer to a function?

Meta