dmd.mtype
Defines a D type.
License
Source: mtype.d
Documentation: https://dlang.org/phobos/dmd_mtype.html
-
Declaration
pure nothrow @nogc @safe boolMODimplicitConv(MODmodfrom, MODmodto);Return !=0 if
modfromcan be implicitly converted tomodto -
Declaration
pure nothrow @nogc @safe MATCHMODmethodConv(MODmodfrom, MODmodto);Return MATCH.exact or MATCH.constant if a method of type '()
modfrom' can call a method of type '()modto'. -
Declaration
pure nothrow @nogc @safe MODMODmerge(MODmod1, MODmod2);Merge mod bits to form common mod.
-
Declaration
nothrow voidMODtoBuffer(OutBuffer*buf, MODmod);Store modifier name into
buf. -
Declaration
pure nothrow const(char)*MODtoChars(MODmod);
pure nothrow stringMODtoString(MODmod);Return Value
a human readable representation of
, which is the tokenmodcorresponds tomod -
Declaration
pure nothrow @nogc @safe StorageClassModToStc(uintmod);Convert MODxxxx to STCxxx
-
Declaration
pure nothrow @nogc @safe boolisSomeChar(TYty);Returns
trueiftyis char, wchar, or dchar -
Declaration
enumDotExpFlag: int;dotExp() bit flags
-
Declaration
enumVarArg: ubyte;Variadic argument lists https://dlang.org/spec/function.html#variadic
-
Declaration
nonefixed number of arguments
-
Declaration
variadic(T t, ...) can be C-style (core.stdc.stdarg) or D-style (core.vararg)
-
Declaration
typesafe(T t ...)
typesafehttps://dlang.org/spec/function.html#typesafe_variadic_functions
-
-
Declaration
abstract classType: dmd.ast_node.ASTNode;-
Declaration
final intcovariant(Typet, StorageClass*pstc= null);Covariant means that 'this' can substitute for '
t', i.e. a pure function is a match for an impure type.Parameters
Typettype 'this' is
covariantwithStorageClass*pstcif not
null, store STCxxxx which would make itcovariantReturn Value
0 types are distinct 1 this is
covariantwitht2 arguments match as far as overloading goes, but types are notcovariant3 cannot determine covariance because of forward references *pstcSTCxxxx which would make itcovariant -
Declaration
final const const(char)*toChars();
final char*toPrettyChars(boolQualifyTypes= false);For pretty-printing a type.
-
Declaration
static voiddeinitialize();Deinitializes the global state of the compiler.
Discussion
This can be used to restore the state set by
_initto its original state. -
Declaration
final Typemerge2();This version does a merge even if the deco is already computed. Necessary for types that have a deco, but are not merged.
-
Declaration
final const nothrow voidmodToBuffer(OutBuffer*buf);Store this type's modifier name into
buf. -
Declaration
final const nothrow char*modToChars();Return this type's modifier name.
-
Declaration
boolisAssignable();When T is mutable,
Given: T a, b; Can we bitwise assign: a = b; ?
-
Declaration
boolisBoolean();Returns
trueif T can be converted to boolean value. -
Declaration
voidcheckDeprecated(ref const Locloc, Scope*sc);Check type to see if it is based on a deprecated symbol.
-
Declaration
final const nothrow TypenullAttributes();Return a copy of this type with all attributes
null-initialized. Useful for creating a type with different modifiers. -
Declaration
final TypeconstOf();Convert to 'const'.
-
Declaration
final TypeimmutableOf();Convert to 'immutable'.
-
Declaration
final TypemutableOf();Make type mutable.
-
Declaration
final TypeunSharedOf();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
-
Declaration
final TypewildOf();Convert to 'wild'.
-
Declaration
final voidfixTo(Typet);For our new type 'this', which is type-constructed from
t, fill in the cto, ito, sto, scto, wto shortcuts. -
Declaration
final voidcheck();Look for bugs in constructing types.
-
Declaration
final TypeaddSTC(StorageClassstc);Apply STCxxxx bits to existing type. Use before semantic analysis is run.
-
Declaration
final TypecastMod(MODmod);Apply MODxxxx bits to existing type.
-
Declaration
final TypeaddMod(MODmod);Add MODxxxx bits to existing type. We're adding, not replacing, so adding const to a shared type => "shared const"
-
Declaration
TypeaddStorageClass(StorageClassstc);Add storage class modifiers to type.
-
Declaration
final TypetoBasetype();If this is a shell around another type, get that other type.
-
Declaration
MATCHimplicitConvTo(Typeto);Determine if 'this' can be implicitly converted
totype 'to'.Return Value
MATCH.nomatch, MATCH.convert, MATCH.constant, MATCH.exact
-
Declaration
MATCHconstConv(Typeto);Determine if converting 'this'
to'to' is an identity operation, a conversiontoconst operation, or the types aren't the same.Return Value
MATCH.exact 'this' == '
to' MATCH.constant 'to' is const MATCH.nomatch conversiontomutable or invariant -
Declaration
MODdeduceWild(Typet, boolisRef);Compute MOD bits matching
thisargument type to wild parameter type.Parameters
Typetcorresponding parameter type
boolisRefparameter is
reforoutReturn Value
MOD bits
-
Declaration
inout inout(Type)toHeadMutable();Return type with the top level of it being mutable.
-
Declaration
structalign_talignment();Return
alignmentto use for this type. -
Declaration
ExpressiondefaultInitLiteral(ref const Locloc);Use when we prefer the default initializer to be a literal, rather than a global immutable variable.
-
Declaration
const inthasWild();Return !=0 if the type or any of its subtypes is wild.
-
Declaration
boolhasPointers();Return !=0 if type has pointers that need to be scanned by the GC during a collection cycle.
-
Declaration
boolhasVoidInitPointers();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.
Return Value
trueif so -
Declaration
boolhasInvariant();Return Value
trueif type has any invariants -
Declaration
TypenextOf();If this is a type of something, return that something.
-
Declaration
final TypebaseElemOf();If this is a type of static array, return its base element type.
-
Declaration
final uintnumberOfElems(ref const Locloc);Compute number of elements for a (possibly multidimensional) static array, or 1 for other types.
Parameters
Loclocfor error message
Return Value
number of elements, uint.max on overflow
-
Declaration
final uinteger_tsizemask();Return the mask that an integral type will fit into.
-
Declaration
boolneedsDestruction();trueif when type goes out of scope, it needs a destructor applied. Only applies to value types, not ref types. -
Declaration
boolneedsCopyOrPostblit();trueif when type is copied, it needs a copy constructor or postblit applied. Only applies to value types, not ref types. -
Declaration
boolneedsNested(); -
Declaration
final boolcheckComplexTransition(ref const Locloc, 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.
Parameters
LoclocThe source location.
Scope*scscope of the type
-
-
Declaration
classTypeError: dmd.mtype.Type; -
Declaration
abstract classTypeNext: dmd.mtype.Type;-
Declaration
final TypenextOf();For TypeFunction,
nextOf() can return NULL if the function return type is meant to be inferred, and semantic() hasn't yet ben run on the function. After semantic(), it must no longer be NULL.
-
-
Declaration
classTypeBasic: dmd.mtype.Type; -
Declaration
classTypeVector: dmd.mtype.Type;The basetype must be one of: byte[16],ubyte[16],short[8],ushort[8],int[4],uint[4],long[2],ulong[2],float[4],double[2] For AVX: byte[32],ubyte[32],short[16],ushort[16],int[8],uint[8],long[4],ulong[4],float[8],double[4]
-
Declaration
abstract classTypeArray: dmd.mtype.TypeNext; -
Declaration
classTypeSArray: dmd.mtype.TypeArray;Static array, one with a fixed dimension
-
Declaration
boolneedsNested();
-
-
Declaration
classTypeDArray: dmd.mtype.TypeArray;Dynamic array, no dimension
-
Declaration
classTypeAArray: dmd.mtype.TypeArray; -
Declaration
classTypePointer: dmd.mtype.TypeNext; -
Declaration
classTypeReference: dmd.mtype.TypeNext; -
Declaration
classTypeFunction: dmd.mtype.TypeNext;-
Declaration
voidpurityLevel();Set 'purity' field of 'this'. Do this lazily, as the parameter types might be forward referenced.
-
Declaration
boolhasLazyParameters();Return
trueif there are lazy parameters. -
Declaration
const pure nothrow boolisDstyleVariadic();Check for
extern (D) U func(T t, ...)variadic function type, which has_arguments[]added as the first argument.Return Value
trueif D-style variadic -
Declaration
boolparameterEscapes(Typetthis, Parameterp);Examine function signature for parameter
pand see if the value ofpcan 'escape' the scope of the function. This is useful to minimize the needed annotations for the parameters.Parameters
Typetthistype of
thisparameter,nullif noneParameterpparameter to this function
Return Value
trueif escapes via assignment to global or through a parameter -
Declaration
StorageClassparameterStorageClass(Typetthis, Parameterp);Take the specified storage class for
p, and use the function signature to infer whether STC.scope_ and STC.return_ should be OR'd in. (This will not affect the name mangling.)Parameters
Typetthistype of
thisparameter,nullif noneParameterpparameter to this function
Return Value
storage class with STC.scope_ or STC.return_ OR'd in
-
Declaration
MATCHcallMatch(Typetthis, Expression[]args, intflag= 0, const(char)**pMessage= null, Scope*sc= null);'
args' are being matched to function 'this' Determine match level.Parameters
Typetthistype of
thispointer,nullif not member functionExpression[]argsarray of function arguments
intflag1: performing a partial ordering match
const(char)**pMessageaddress to store error message, or
nullScope*sccontext
Return Value
MATCHxxxx
-
Declaration
MATCHconstConv(Typeto);Extends TypeNext.
constConvby also checking for matching attributes -
Declaration
const pure nothrow @nogc @safe boolisnothrow();
pure nothrow @nogc @safe voidisnothrow(boolv);set or get if the function has the
nothrowattribute -
Declaration
const pure nothrow @nogc @safe boolisnogc();
pure nothrow @nogc @safe voidisnogc(boolv);set or get if the function has the
@nogcattribute -
Declaration
const pure nothrow @nogc @safe boolisproperty();
pure nothrow @nogc @safe voidisproperty(boolv);set or get if the function has the
@propertyattribute -
Declaration
const pure nothrow @nogc @safe boolisref();
pure nothrow @nogc @safe voidisref(boolv);set or get if the function has the
refattribute -
Declaration
const pure nothrow @nogc @safe boolisreturn();
pure nothrow @nogc @safe voidisreturn(boolv);set or get if the function has the
returnattribute -
Declaration
const pure nothrow @nogc @safe boolisScopeQual();
pure nothrow @nogc @safe voidisScopeQual(boolv);set or get if the function has the
scopeattribute -
Declaration
const pure nothrow @nogc @safe boolisreturninferred();
pure nothrow @nogc @safe voidisreturninferred(boolv);set or get if the function has the
returnattribute inferred -
Declaration
const pure nothrow @nogc @safe boolisscopeinferred();set or get if the function has the
scopeattribute inferred -
Declaration
pure nothrow @nogc @safe voidisscopeinferred(boolv);ditoo
-
Declaration
const pure nothrow @nogc @safe boolislive();
pure nothrow @nogc @safe voidislive(boolv);set or get if the function has the
@liveattribute -
Declaration
const pure nothrow @nogc @safe boolincomplete();
pure nothrow @nogc @safe voidincomplete(boolv);set or get if the return type or the default arguments are removed
-
Declaration
const pure nothrow @nogc @safe boolisInOutParam();
pure nothrow @nogc @safe voidisInOutParam(boolv);set or get if the function has the
inouton the parameters -
Declaration
const pure nothrow @nogc @safe boolisInOutQual();
pure nothrow @nogc @safe voidisInOutQual(boolv);set or get if the function has the
inouton the parameters -
Declaration
const pure nothrow @nogc @safe booliswild();Return Value
truethe function isisInOutQualorisInOutParam,falseotherwise. -
Declaration
const pure nothrow @nogc @safe boolattributesEqual(scope const TypeFunctionother);Return Value
whether
thisfunction type has the same attributes (@safe,...) asother
-
-
Declaration
classTypeDelegate: dmd.mtype.TypeNext; -
Declaration
classTypeTraits: dmd.mtype.Type;This is a shell containing a TraitsExp that can be either resolved to a type or to a symbol.
Discussion
The point is to allow AliasDeclarationY to use
__traits(), see issue 7804.-
Declaration
TraitsExpexp;The expression to resolve as type or symbol.
-
Declaration
Dsymbolsym;After
typeSemanticthe symbol whenexpdoesn't represent a type.
-
-
Declaration
classTypeMixin: dmd.mtype.Type;Implements mixin types.
Discussion
Semantic analysis will convert it to a real type.
-
Declaration
abstract classTypeQualified: dmd.mtype.Type; -
Declaration
classTypeIdentifier: dmd.mtype.TypeQualified;-
Declaration
DsymboltoDsymbol(Scope*sc);See if type resolves to a symbol, if so, return that symbol.
-
-
Declaration
classTypeInstance: dmd.mtype.TypeQualified;Similar to TypeIdentifier, but with a TemplateInstance as the root
-
Declaration
classTypeTypeof: dmd.mtype.TypeQualified; -
Declaration
classTypeReturn: dmd.mtype.TypeQualified; -
Declaration
classTypeStruct: dmd.mtype.Type;-
Declaration
ExpressiondefaultInitLiteral(ref const Locloc);Use when we prefer the default initializer to be a literal, rather than a global immutable variable.
-
-
Declaration
classTypeEnum: dmd.mtype.Type; -
Declaration
classTypeClass: dmd.mtype.Type; -
Declaration
classTypeTuple: dmd.mtype.Type; -
Declaration
classTypeSlice: dmd.mtype.TypeNext;This is so we can slice a TypeTuple
-
Declaration
classTypeNull: dmd.mtype.Type; -
Declaration
classTypeNoreturn: dmd.mtype.Type; -
Declaration
structParameterList;Represents a function's formal parameters + variadics info. Length, indexing and iteration are based on a depth-first tuple expansion. https://dlang.org/spec/function.html#ParameterList
-
Declaration
Parameters*parameters;The raw (unexpanded) formal
parameters, possibly containing tuples. -
Declaration
size_tlength();Returns the number of expanded parameters. Complexity: O(N).
-
Declaration
ParameteropIndex(size_ti);Returns the expanded parameter at the given index, or
nullif out of bounds. Complexity: O(i). -
Declaration
intopApply(scope Parameter.ForeachDgdg);Iterates over the expanded parameters. Complexity: O(N). Prefer this to avoid the O(N + N^2/2) complexity of calculating length and calling N times opIndex.
-
Declaration
intopApply(scope Parameter.SemanticForeachDgdg);Iterates over the expanded parameters, matching them with the unexpanded ones, for semantic processing
-
Declaration
const boolopEquals(ref scope ParameterListother);Compares this to another ParameterList (and expands tuples if necessary)
-
-
Declaration
classParameter: dmd.ast_node.ASTNode;-
Declaration
TypeisLazyArray();Determine if parameter is a lazy array of delegates. If so, return the return type of those delegates. If not, return NULL.
Discussion
Returns T if the type is one of the following forms: T delegate()[] T delegate()
dim -
Declaration
const pure nothrow @nogc @safe boolisReference();Return Value
Whether the function parameter is a reference (out / ref)
-
Declaration
static size_tdim(Parameters*parameters);Determine number of arguments, folding in tuples.
-
Declaration
static ParametergetNth(Parameters*parameters, size_tnth);Get
nthParameter, folding in tuples.Discussion
Since
can include tuples, which would increase its length, this function allows to get theparametersparameter as if all tuples transitively contained innthwere flattened.parametersParameters
Parameters*parametersArray of
Parameterto iterate oversize_tnthIndex of the desired parameter.
Return Value
The parameter at index
(taking tuples into account), ornthnullif out of bound. -
Declaration
aliasForeachDg= int delegate(ulong paramidx, Parameter param);Type of delegate when iterating solely on the parameters
-
Declaration
aliasSemanticForeachDg= int delegate(ulong oidx, Parameter oparam, ulong eidx, Parameter eparam);Type of delegate when iterating on both the original set of parameters, and the type tuple. Useful for semantic analysis. 'o' stands for 'original' and 'e' stands for 'expanded'.
-
Declaration
static int_foreach(Parameters*parameters, scope ForeachDgdg);
static int_foreach(Parameters*parameters, scope SemanticForeachDgdg);Expands tuples in args in depth first order. Calls
dg(void *ctx, size_t argidx, Parameter *arg) for each Parameter. Ifdgreturns !=0, stops and returns that value else returns 0. Use this function to avoid the O(N + N^2/2) complexity of calculating dim and calling N times getNth. -
Declaration
const pure nothrow @nogc @safe boolisCovariant(boolreturnByRef, const Parameterp, boolpreviewIn= global.params.previewIn);Compute covariance of parameters
thisandas determined by the storage classes of both.pParameters
boolreturnByReftrueif the function returns by refParameterpParameter to compare with
boolpreviewInWhether
-preview=inis being used, and thus ifinmeansscope [ref].Return Value
true=thiscan be used in place ofpfalse= nope
-
-
Declaration
const(char*)[2]toAutoQualChars(Typet1, Typet2);For printing two types with qualification when necessary.
Parameters
Typet1The first type to receive the type name for
Typet2The second type to receive the type name for
Return Value
The fully-qualified names of both types if the two type names are not the same, or the unqualified names of both types if the two type names are the same.
-
Declaration
voidmodifiersApply(const TypeFunctiontf, void delegate(string)dg);For each active modifier (MODFlags.const_, MODFlags.immutable_, etc) call
fpwith a void* for the work param and a string representation of the attribute. -
Declaration
voidattributesApply(const TypeFunctiontf, void delegate(string)dg, TRUSTformattrustFormat= TRUSTformatDefault);For each active attribute (ref/const/nogc/etc) call
fpwith a void* for the work param and a string representation of the attribute. -
Declaration
AggregateDeclarationisAggregate(Typet);If the type is a class or struct, returns the symbol for it, else
null. -
Declaration
boolisIndexableNonAggregate(Typet);Determine if type
tcan be indexed or sliced given that it is not an aggregate with operator overloads.Parameters
Typettype to check
Return Value
trueif an expression of typetcan be e1 in an array expression -
Declaration
boolisCopyable(Typet);Determine if type
tis copyable.Parameters
Typettype to check
Return Value
trueif we can copy it