dmd.mtype
Defines a D type.
License
Source: mtype.d
Documentation: https://dlang.org/phobos/dmd_mtype.html
- 
  Declarationpure nothrow @nogc @safe boolMODimplicitConv(MODmodfrom, MODmodto);Return !=0 if modfromcan be implicitly converted tomodto
- 
  Declarationpure 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'.
- 
  Declarationpure nothrow @nogc @safe MODMODmerge(MODmod1, MODmod2);Merge mod bits to form common mod. 
- 
  Declarationnothrow voidMODtoBuffer(OutBuffer*buf, MODmod);Store modifier name into buf.
- 
  Declarationpure nothrow const(char)*MODtoChars(MODmod);
 pure nothrow stringMODtoString(MODmod);Return Valuea human readable representation of modmod
- 
  Declarationpure nothrow @nogc @safe stringtrustToString(TRUSTtrust);Pick off one of the trustflags fromtrust, and return a string representation of it.
- 
  Declarationpure nothrow @nogc @safe StorageClassModToStc(uintmod);Convert MODxxxx to STCxxx 
- 
  Declarationpure nothrow @nogc @safe boolisSomeChar(TYty);Returns trueiftyis char, wchar, or dchar
- 
  DeclarationintmutabilityOfType(boolisref, Typet);Determine mutability of indirections in (ref) t.Return ValueWhen the type has any mutable indirections, returns 0. When all indirections are immutable, returns 2. Otherwise, when the type has const/inout indirections, returns 1. Parametersboolisrefif true, checkref; otherwise, check justttTypetthe type that is being checked 
- 
  DeclarationenumDotExpFlag: int;dotExp() bit flags 
- 
  DeclarationenumCovariant: int;Result of a check whether two types are covariant - 
  Declarationdistincttypes are distinct
- 
  Declarationyestypes are covariant 
- 
  Declarationnoarguments match as far as overloading goes, but types are not covariant 
- 
  Declarationfwdrefcannot determine covariance because of forward references 
 
- 
  
- 
  Declarationabstract classType: dmd.ast_node.ASTNode;- 
  Declarationfinal const size_tgetUniqueID();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.
- 
  Declarationfinal Covariantcovariant(Typet, StorageClass*pstc= null, boolcppCovariant= false);Covariant means that 'this' can substitute for ' t', i.e. a pure function is a match for an impure type.ParametersTypettype 'this' is covariantwithStorageClass*pstcif not null, store STCxxxx which would make itcovariantboolcppCovarianttrueif extern(C++) function types should follow C++covariantrulesReturn ValueAn enum value of either Covariant.yesor a reason it's notcovariant.
- 
  Declarationfinal const const(char)*toChars();
 final char*toPrettyChars(boolQualifyTypes= false);For pretty-printing a type. 
- 
  Declarationstatic voiddeinitialize();Deinitializes the global state of the compiler. DiscussionThis can be used to restore the state set by _initto its original state.
- 
  Declarationfinal Typemerge2();This version does a merge even if the deco is already computed. Necessary for types that have a deco, but are not merged. 
- 
  Declarationfinal const nothrow voidmodToBuffer(OutBuffer*buf);Store this type's modifier name into buf.
- 
  Declarationfinal const nothrow char*modToChars();Return this type's modifier name. 
- 
  DeclarationboolisAssignable();When T is mutable, Given: T a, b; Can we bitwise assign: a = b; ? 
- 
  DeclarationboolisBoolean();Returns trueif T can be converted to boolean value.
- 
  DeclarationvoidcheckDeprecated(const ref Locloc, Scope*sc);Check type to see if it is based on a deprecated symbol. 
- 
  Declarationfinal const nothrow TypenullAttributes();Return a copy of this type with all attributes null-initialized. Useful for creating a type with different modifiers.
- 
  Declarationfinal TypeconstOf();Convert to 'const'. 
- 
  Declarationfinal TypeimmutableOf();Convert to 'immutable'. 
- 
  Declarationfinal TypemutableOf();Make type mutable. 
- 
  Declarationfinal 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 
- 
  Declarationfinal TypewildOf();Convert to 'wild'. 
- 
  Declarationfinal voidfixTo(Typet);For our new type 'this', which is type-constructed from t, fill in the cto, ito, sto, scto, wto shortcuts.
- 
  Declarationfinal voidcheck();Look for bugs in constructing types. 
- 
  Declarationfinal TypeaddSTC(StorageClassstc);Apply STCxxxx bits to existing type. Use before semantic analysis is run. 
- 
  Declarationfinal TypecastMod(MODmod);Apply MODxxxx bits to existing type. 
- 
  Declarationfinal TypeaddMod(MODmod);Add MODxxxx bits to existing type. We're adding, not replacing, so adding const to a shared type => "shared const" 
- 
  DeclarationTypeaddStorageClass(StorageClassstc);Add storage class modifiers to type. 
- 
  Declarationfinal TypetoBasetype();If this is a shell around another type, get that other type. 
- 
  DeclarationMATCHimplicitConvTo(Typeto);Determine if 'this' can be implicitly converted totype 'to'.Return ValueMATCH.nomatch, MATCH.convert, MATCH.constant, MATCH.exact 
- 
  DeclarationMATCHconstConv(Typeto);Determine if converting 'this' to'to' is an identity operation, a conversiontoconst operation, or the types aren't the same.Return ValueMATCH.exact 'this' == ' to' MATCH.constant 'to' is const MATCH.nomatch conversiontomutable or invariant
- 
  DeclarationMODdeduceWild(Typet, boolisRef);Compute MOD bits matching thisargument type to wild parameter type.ParametersTypetcorresponding parameter type boolisRefparameter is reforoutReturn ValueMOD bits 
- 
  Declarationinout inout(Type)toHeadMutable();Return type with the top level of it being mutable. 
- 
  Declarationstructalign_talignment();Return alignmentto use for this type.
- 
  DeclarationExpressiondefaultInitLiteral(const ref Locloc);Use when we prefer the default initializer to be a literal, rather than a global immutable variable. 
- 
  Declarationconst inthasWild();Return !=0 if the type or any of its subtypes is wild. 
- 
  DeclarationboolhasPointers();Return !=0 if type has pointers that need to be scanned by the GC during a collection cycle. 
- 
  DeclarationboolhasVoidInitPointers();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 Valuetrueif so
- 
  DeclarationboolhasSystemFields();Detect if this is an unsafe type because of the presence of @systemmembersReturn Valuetrueif so
- 
  DeclarationboolhasInvariant();Return Valuetrueif type has any invariants
- 
  DeclarationTypenextOf();If this is a type of something, return that something. 
- 
  Declarationfinal TypebaseElemOf();If this is a type of static array, return its base element type. 
- 
  Declarationfinal uintnumberOfElems(const ref Locloc);Compute number of elements for a (possibly multidimensional) static array, or 1 for other types. ParametersLoclocfor error message Return Valuenumber of elements, uint.max on overflow 
- 
  Declarationfinal uinteger_tsizemask();Return the mask that an integral type will fit into. 
- 
  DeclarationboolneedsDestruction();trueif when type goes out of scope, it needs a destructor applied. Only applies to value types, not ref types.
- 
  DeclarationboolneedsCopyOrPostblit();trueif when type is copied, it needs a copy constructor or postblit applied. Only applies to value types, not ref types.
- 
  DeclarationboolneedsNested();
- 
  Declarationfinal boolcheckComplexTransition(const ref 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. ParametersLoclocThe source location. Scope*scscope of the type 
- 
  Declarationfinal inout pure nothrow @nogc inout(TypeFunction)isPtrToFunction();Is this type a pointer to a function? Return Valuethe function type if it is 
- 
  Declarationfinal inout pure nothrow @nogc inout(TypeFunction)isFunction_Delegate_PtrToFunction();Is this type a function, delegate, or pointer to a function? Return Valuethe function type if it is 
 
- 
  
- 
  DeclarationclassTypeError: dmd.mtype.Type;
- 
  Declarationabstract classTypeNext: dmd.mtype.Type;- 
  Declarationfinal 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.
 
- 
  
- 
  DeclarationclassTypeBasic: dmd.mtype.Type;
- 
  DeclarationclassTypeVector: 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] 
- 
  Declarationabstract classTypeArray: dmd.mtype.TypeNext;
- 
  DeclarationclassTypeSArray: dmd.mtype.TypeArray;Static array, one with a fixed dimension - 
  DeclarationboolisIncomplete();C11 6.7.6.2-4 incomplete array type Return Valuetrueif incomplete type
- 
  DeclarationboolneedsNested();
 
- 
  
- 
  DeclarationclassTypeDArray: dmd.mtype.TypeArray;Dynamic array, no dimension 
- 
  DeclarationclassTypeAArray: dmd.mtype.TypeArray;
- 
  DeclarationclassTypePointer: dmd.mtype.TypeNext;
- 
  DeclarationclassTypeReference: dmd.mtype.TypeNext;
- 
  DeclarationclassTypeFunction: dmd.mtype.TypeNext;- 
  DeclarationvoidpurityLevel();Set 'purity' field of 'this'. Do this lazily, as the parameter types might be forward referenced. 
- 
  DeclarationboolhasLazyParameters();Return trueif there are lazy parameters.
- 
  Declarationconst pure nothrow boolisDstyleVariadic();Check for extern (D) U func(T t, ...)variadic function type, which has_arguments[]added as the first argument.Return Valuetrueif D-style variadic
- 
  DeclarationStorageClassparameterStorageClass(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.)ParametersTypetthistype of thisparameter,nullif noneParameterpparameter to this function Return Valuestorage class with STC.scope_ or STC.return_ OR'd in 
- 
  DeclarationMATCHcallMatch(Typetthis, ArgumentListargumentList, intflag= 0, const(char)**pMessage= null, Scope*sc= null);'args' are being matched to function 'this' Determine match level. ParametersTypetthistype of thispointer,nullif not member functionArgumentListargumentListarguments to function call intflag1: performing a partial ordering match const(char)**pMessageaddress to store error message, or nullScope*sccontext Return ValueMATCHxxxx 
- 
  DeclarationExpressions*resolveNamedArgs(ArgumentListargumentList, const(char)**pMessage);Convert an argumentListParametersArgumentListargumentListarray of function arguments const(char)**pMessageaddress to store error message, or nullReturn Valuere-ordered argument list, or nullon error
- 
  DeclarationMATCHconstConv(Typeto);Extends TypeNext. constConvby also checking for matching attributes
- 
  Declarationconst pure nothrow @nogc @safe booliswild();Return Valuetruethe function isisInOutQualorisInOutParam,falseotherwise.
- 
  Declarationconst pure nothrow @nogc @safe boolattributesEqual(scope const TypeFunctionother, booltrustSystemEqualsDefault= true);Return Valuewhether thisfunction type has the same attributes (@safe,...) asother
 
- 
  
- 
  DeclarationclassTypeDelegate: dmd.mtype.TypeNext;
- 
  DeclarationclassTypeTraits: dmd.mtype.Type;This is a shell containing a TraitsExp that can be either resolved to a type or to a symbol. DiscussionThe point is to allow AliasDeclarationY to use __traits(), see issue 7804.- 
  DeclarationTraitsExpexp;The expression to resolve as type or symbol. 
- 
  DeclarationRootObjectobj;Cached type/symbol after semantic analysis. 
 
- 
  
- 
  DeclarationclassTypeMixin: dmd.mtype.Type;Implements mixin types. DiscussionSemantic analysis will convert it to a real type. 
- 
  Declarationabstract classTypeQualified: dmd.mtype.Type;
- 
  DeclarationclassTypeIdentifier: dmd.mtype.TypeQualified;- 
  DeclarationDsymboltoDsymbol(Scope*sc);See if type resolves to a symbol, if so, return that symbol. 
 
- 
  
- 
  DeclarationclassTypeInstance: dmd.mtype.TypeQualified;Similar to TypeIdentifier, but with a TemplateInstance as the root 
- 
  DeclarationclassTypeTypeof: dmd.mtype.TypeQualified;
- 
  DeclarationclassTypeReturn: dmd.mtype.TypeQualified;
- 
  DeclarationclassTypeStruct: dmd.mtype.Type;- 
  DeclarationExpressiondefaultInitLiteral(const ref Locloc);Use when we prefer the default initializer to be a literal, rather than a global immutable variable. 
 
- 
  
- 
  DeclarationclassTypeEnum: dmd.mtype.Type;
- 
  DeclarationclassTypeClass: dmd.mtype.Type;
- 
  DeclarationclassTypeTuple: dmd.mtype.Type;
- 
  DeclarationclassTypeSlice: dmd.mtype.TypeNext;This is so we can slice a TypeTuple 
- 
  DeclarationclassTypeNull: dmd.mtype.Type;
- 
  DeclarationclassTypeNoreturn: dmd.mtype.Type;
- 
  DeclarationclassTypeTag: dmd.mtype.Type;Unlike D, C can declare/define struct/union/enum tag names inside Declarators, instead of separately as in D. The order these appear in the symbol table must be in lexical order. There isn't enough info at the parsing stage to determine if it's a declaration or a reference to an existing name, so this Type collects the necessary info and defers it to semantic(). - 
  DeclarationLocloc;location of declaration 
- 
  DeclarationTOKtok;TOK.struct_, TOK.union_, TOK.enum_ 
- 
  DeclarationIdentifierid;tag name identifier 
- 
  DeclarationTypebase;basetype for enums otherwisenull
- 
  DeclarationDsymbols*members;membersof struct,nullif none
- 
  DeclarationTyperesolved;type after semantic() in case there are more others 
- 
  DeclarationMODmod;pointing to this instance, which can happen with struct S { int a; } s1, *s2; Discussionmodifiers to apply after type is resolved (only MODFlags.const_ at the moment) 
 
- 
  
- 
  DeclarationstructParameterList;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 - 
  DeclarationParameters*parameters;The raw (unexpanded) formal parameters, possibly containing tuples.
- 
  Declarationsize_tlength();Returns the number of expanded parameters. Complexity: O(N). 
- 
  DeclarationParameteropIndex(size_ti);Returns the expanded parameter at the given index, or nullif out of bounds. Complexity: O(i).
- 
  DeclarationintopApply(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. 
- 
  DeclarationintopApply(scope Parameter.SemanticForeachDgdg);Iterates over the expanded parameters, matching them with the unexpanded ones, for semantic processing 
- 
  Declarationconst boolopEquals(ref scope ParameterListother);Compares this to another ParameterList (and expands tuples if necessary) 
- 
  DeclarationboolhasDefaultArgs();Return Valuetrueif any parameter has a default argument
 
- 
  
- 
  DeclarationclassParameter: dmd.ast_node.ASTNode;- 
  DeclarationTypeisLazyArray();Determine if parameter is a lazy array of delegates. If so, return the return type of those delegates. If not, return NULL. DiscussionReturns T if the type is one of the following forms: T delegate()[] T delegate() dim
- 
  Declarationconst pure nothrow @nogc @safe boolisLazy();Return ValueWhether the function parameter is lazy 
- 
  Declarationconst pure nothrow @nogc @safe boolisReference();Return ValueWhether the function parameter is a reference (out / ref) 
- 
  Declarationstatic size_tdim(Parameters*parameters);Determine number of arguments, folding in tuples. 
- 
  Declarationstatic ParametergetNth(Parameters*parameters, size_tnth);Get nthParameter, folding in tuples.DiscussionSince parametersnthparametersParametersParameters*parametersArray of Parameterto iterate oversize_tnthIndex of the desired parameter. Return ValueThe parameter at index nthnullif out of bound.
- 
  DeclarationaliasForeachDg= int delegate(ulong paramidx, Parameter param);Type of delegate when iterating solely on the parameters 
- 
  DeclarationaliasSemanticForeachDg= 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'. 
- 
  Declarationstatic 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.
- 
  Declarationconst pure nothrow @nogc @safe boolisCovariant(boolreturnByRef, const Parameterp, boolpreviewIn= global.params.previewIn);Compute covariance of parameters thisandpParametersboolreturnByReftrueif the function returns by refParameterpParameter to compare with boolpreviewInWhether -preview=inis being used, and thus ifinmeansscope [ref].Return Valuetrue=thiscan be used in place ofpfalse= nope
 
- 
  
- 
  Declarationconst(char*)[2]toAutoQualChars(Typet1, Typet2);For printing two types with qualification when necessary. ParametersTypet1The first type to receive the type name for Typet2The second type to receive the type name for Return ValueThe 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. 
- 
  DeclarationvoidmodifiersApply(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.
- 
  DeclarationvoidattributesApply(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.
- 
  DeclarationAggregateDeclarationisAggregate(Typet);If the type is a class or struct, returns the symbol for it, else null.
- 
  DeclarationboolisIndexableNonAggregate(Typet);Determine if type tcan be indexed or sliced given that it is not an aggregate with operator overloads.ParametersTypettype to check Return Valuetrueif an expression of typetcan be e1 in an array expression
- 
  DeclarationboolisCopyable(Typet);Determine if type tis copyable.ParametersTypettype to check Return Valuetrueif we can copy it
- 
  Declarationpure nothrow @nogc @safe ScopeRefbuildScopeRef(StorageClassstc);Computes how a parameter may be returned. Shrinking the representation is necessary because StorageClass is so wide ParametersStorageClassstcstorage class of parameter Return Valuevalue from enum ScopeRef 
- 
  DeclarationenumScopeRef: int;Classification of 'scope-return-ref' possibilities 
- 
  Declarationpure nothrow @nogc @safe const(char)*toChars(ScopeRefsr);Give us a nice string for debugging purposes. ParametersScopeRefsrvalue Return Valuecorresponding string 
- 
  DeclarationTypeVectortoBooleanVector(TypeVectortv);Creates an appropriate vector type for tvtrue) or all 0s (comparisonfalse). This SIMD mask type does not have an equivalent D type, however its closest equivalent would be an integer vector of the same unit size and length.ParametersTypeVectortvThe TypeVectorto build a vector from.Return ValueA vector type suitable for the result of a vector comparison operation.