Report a bug
		
				If you spot a problem with this page, click here to create a Bugzilla issue.
		
			Improve this page
		
			Quickly fork, edit online, and submit a pull request for this page.
			Requires a signed-in GitHub account. This works well for small changes.
			If you'd like to make larger changes you may want to consider using
			a local clone.
		
	dmd.mtype
Defines a D type.
Authors: 
License: 
Source mtype.d
Documentation https://dlang.org/phobos/dmd_mtype.html
- pure nothrow @nogc @safe boolMODimplicitConv(MODmodfrom, MODmodto);
- Return !=0 if modfrom can be implicitly converted to modto
- 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'.
- pure nothrow @nogc @safe MODMODmerge(MODmod1, MODmod2);
- Merge mod bits to form common mod.
- nothrow @safe voidMODtoBuffer(ref OutBufferbuf, MODmod);
- Store modifier name into buf.
- pure nothrow const(char)*MODtoChars(MODmod);
 pure nothrow @safe stringMODtoString(MODmod);
- Returns:a human readable representation ofmod, which is the tokenmodcorresponds to
- pure nothrow @nogc @safe stringtrustToString(TRUSTtrust);
- Pick off one of the trust flags from trust, and return a string representation of it.
- pure nothrow @nogc @safe STCModToStc(uintmod);
- Convert MODxxxx to STCxxx
- pure nothrow @nogc @safe boolisSomeChar(TYty);
- Returns true if ty is char, wchar, or dchar
- enumDotExpFlag: int;
- dotExp() bit flags
- enumCovariant: int;
- Result of a check whether two types are covariant- distinct
- types are distinct
- yes
- types are covariant
- no
- arguments match as far as overloading goes, but types are not covariant
- fwdref
- cannot determine covariance because of forward references
 
- abstract classType: dmd.ast_node.ASTNode;
- 
- final size_tgetUniqueID() const;
- 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.
- final const(char)*toChars() const;
 final char*toPrettyChars(boolQualifyTypes= false);
- For pretty-printing a type.
- static voiddeinitialize();
- Deinitializes the global state of the compiler.This can be used to restore the state set by _init to its original state.
- final nothrow voidmodToBuffer(ref OutBufferbuf) const;
- Store this type's modifier name into buf.
- final nothrow char*modToChars() const;
- Return this type's modifier name.
- boolisAssignable();
- When T is mutable,Given T a, b; Can we bitwise assign: a = b; ? 
- boolisBoolean();
- Returns true if T can be converted to boolean value.
- final nothrow TypenullAttributes() const;
- Return a copy of this type with all attributes null-initialized. Useful for creating a type with different modifiers.
- final voidfixTo(Typet);
- For our new type 'this', which is type-constructed from t, fill in the cto, ito, sto, scto, wto shortcuts.
- final voidcheck();
- Look for bugs in constructing types.
- final TypeaddSTC(STCstc);
- Apply STCxxxx bits to existing type. Use before semantic analysis is run.
- final TypetoBasetype();
- If this is a shell around another type, get that other type.
- MODdeduceWild(Typet, boolisRef);
- Compute MOD bits matching this argument type to wild parameter type.Parameters:Type tcorresponding parameter type bool isRefparameter is ref or out Returns:MOD bits
- structalign_talignment();
- Return alignment to use for this type.
- ExpressiondefaultInitLiteral(Locloc);
- Use when we prefer the default initializer to be a literal, rather than a global immutable variable.
- inthasWild() const;
- Return !=0 if the type or any of its subtypes is wild.
- 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.Returns:true if so
- boolhasUnsafeBitpatterns();
- Detect if this is an unsafe type because of the presence of @system membersReturns:true if so
- boolhasInvariant();
- Returns:true if type has any invariants
- TypenextOf();
- If this is a type of something, return that something.
- final TypebaseElemOf();
- If this is a type of static array, return its base element type.
- final uinteger_tsizemask();
- Return the mask that an integral type will fit into.
- boolneedsDestruction();
- true if when type goes out of scope, it needs a destructor applied. Only applies to value types, not ref types.
- boolneedsCopyOrPostblit();
- true if when type is copied, it needs a copy constructor or postblit applied. Only applies to value types, not ref types.
- boolneedsNested();
- final pure nothrow @nogc inout(TypeFunction)isPtrToFunction() inout;
- Is this type a pointer to a function?Returns:the function type if it is
- final pure nothrow @nogc inout(TypeFunction)isFunction_Delegate_PtrToFunction() inout;
- Is this type a function, delegate, or pointer to a function?Returns:the function type if it is
 
- classTypeError: dmd.mtype.Type;
- abstract classTypeNext: dmd.mtype.Type;
- 
- final @safe TypenextOf();
- For TypeFunction, nextOf() can return NULL if the function return type is meant to be inferred, and semantic() hasn't yet been run on the function. After semantic(), it must no longer be NULL.
 
- classTypeBasic: dmd.mtype.Type;
- 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]
- abstract classTypeArray: dmd.mtype.TypeNext;
- classTypeSArray: dmd.mtype.TypeArray;
- Static array, one with a fixed dimension- boolisIncomplete();
- C11 6.7.6.2-4 incomplete array typeReturns:true if incomplete type
- boolneedsNested();
 
- classTypeDArray: dmd.mtype.TypeArray;
- Dynamic array, no dimension
- classTypeAArray: dmd.mtype.TypeArray;
- classTypePointer: dmd.mtype.TypeNext;
- classTypeReference: dmd.mtype.TypeNext;
- classTypeFunction: dmd.mtype.TypeNext;
- 
- boolhasLazyParameters();
- Return true if there are lazy parameters.
- pure nothrow @safe boolisDstyleVariadic() const;
- Check for extern (D) U func(T t, ...) variadic function type, which has _arguments[] added as the first argument.Returns:true if D-style variadic
- static voidgetMatchError(ref OutBufferbuf, const(char)*format, ...);
- Append error message to buf.Input buf = message sink format = printf format 
- Expressions*resolveNamedArgs(ArgumentListargumentList, OutBuffer*buf);
- Convert anargumentList, which may contain named arguments, into a list of arguments in the order of the parameter list.Parameters:ArgumentList argumentListarray of function arguments OutBuffer* bufif not null, append error message to it Returns:re-ordered argument list, or null on error
- pure nothrow @nogc @safe booliswild() const;
- Returns:true the function is isInOutQual or isInOutParam ,false otherwise.
- pure nothrow @nogc @safe boolattributesEqual(scope const TypeFunctionother, booltrustSystemEqualsDefault= true) const;
- Returns:whether this function type has the same attributes (@safe,...) asother
 
- classTypeDelegate: dmd.mtype.TypeNext;
- classTypeTraits: dmd.mtype.Type;
- 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.- TraitsExpexp;
- The expression to resolve as type or symbol.
- RootObjectobj;
- Cached type/symbol after semantic analysis.
 
- classTypeMixin: dmd.mtype.Type;
- Implements mixin types.Semantic analysis will convert it to a real type.
- abstract classTypeQualified: dmd.mtype.Type;
- classTypeIdentifier: dmd.mtype.TypeQualified;
- classTypeInstance: dmd.mtype.TypeQualified;
- Similar to TypeIdentifier, but with a TemplateInstance as the root
- classTypeTypeof: dmd.mtype.TypeQualified;
- classTypeReturn: dmd.mtype.TypeQualified;
- classTypeStruct: dmd.mtype.Type;
- 
- ExpressiondefaultInitLiteral(Locloc);
- Use when we prefer the default initializer to be a literal, rather than a global immutable variable.
 
- classTypeEnum: dmd.mtype.Type;
- classTypeClass: dmd.mtype.Type;
- classTypeTuple: dmd.mtype.Type;
- 
- this(Expressions*exps);
- Form TypeTuple from the types of the expressions. Assume exps[] is already tuple expanded.
- @safe this();
- Type tuple with 0, 1 or 2 types in it.
 
- classTypeSlice: dmd.mtype.TypeNext;
- This is so we can slice a TypeTuple
- classTypeNull: dmd.mtype.Type;
- classTypeNoreturn: dmd.mtype.Type;
- classTypeTag: 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().- Locloc;
- location of declaration
- TOKtok;
- TOK.struct_, TOK.union_, TOK.enum_
- structalign_tpackalign;
- alignment of struct/union fields
- Identifierid;
- tag name identifier
- Typebase;
- base type for enums otherwise null
- Dsymbols*members;
- members of struct, null if none
- Typeresolved;
- type after semantic() in case there are more others
- MODmod;
- pointing to this instance, which can happen with struct S { int a; } s1, *s2;modifiers to apply after type is resolved (only MODFlags.const_ at the moment)
 
- 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- Parameters*parameters;
- The raw (unexpanded) formal parameters, possibly containing tuples.
- size_tlength();
- Returns the number of expanded parameters. Complexity: O(N).
- ParameteropIndex(size_ti);
- Returns the expanded parameter at the given index, or null if out of bounds. Complexity: O(i).
- 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.
- intopApply(scope Parameter.SemanticForeachDgdg);
- Iterates over the expanded parameters, matching them with the unexpanded ones, for semantic processing
- boolopEquals(ref scope ParameterListother) const;
- Compares this to another ParameterList (and expands tuples if necessary)
- boolhasDefaultArgs();
- Returns:true if any parameter has a default argument
 
- classParameter: dmd.ast_node.ASTNode;
- 
- TypeisLazyArray();
- Determine if parameter is a lazy array of delegates. If so, return the return type of those delegates. If not, return NULL.Returns T if the type is one of the following forms: T delegate()[] T delegate()dim
- pure nothrow @nogc @safe boolisLazy() const;
- Returns:Whether the function parameter is lazy
- pure nothrow @nogc @safe boolisReference() const;
- Returns:Whether the function parameter is a reference (out / ref)
- static size_tdim(Parameters*parameters);
- Determine number of arguments, folding in tuples.
- static ParametergetNth(Parameters*parameters, size_tnth);
- Get nth Parameter, folding in tuples.Sinceparameterscan include tuples, which would increase its length, this function allows to get thenthparameter as if all tuples transitively contained inparameterswere flattened.Parameters:Parameters* parametersArray of Parameter to iterate over size_t nthIndex of the desired parameter. Returns:The parameter at indexnth(taking tuples into account), or null if out of bound.
- aliasForeachDg= int delegate(ulong paramidx, Parameter param);
- Type of delegate when iterating solely on the parameters
- 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'.
- 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. If dg returns !=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.
- pure nothrow @nogc @safe boolisCovariant(boolreturnByRef, const Parameterp) const;
- Compute covariance of parameters this andpas determined by the storage classes of both.Parameters:bool returnByReftrue if the function returns by ref Parameter pParameter to compare with Returns:true = this can be used in place ofpfalse = nope
 
- const(char*)[2]toAutoQualChars(Typet1, Typet2);
- For printing two types with qualification when necessary.Parameters:Type t1The first type to receive the type name for Type t2The second type to receive the type name for Returns: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.
- voidmodifiersApply(const TypeFunctiontf, void delegate(string)dg);
- For each active modifier (MODFlags.const_, MODFlags.immutable_, etc) call fp with a void* for the work param and a string representation of the attribute.
- voidattributesApply(const TypeFunctiontf, void delegate(string)dg, TRUSTformattrustFormat= TRUSTformatDefault);
- For each active attribute (ref/const/nogc/etc) call fp with a void* for the work param and a string representation of the attribute.
- AggregateDeclarationisAggregate(Typet);
- If the type is a class or struct, returns the symbol for it, else null.
- boolisIndexableNonAggregate(Typet);
- Determine if type t can be indexed or sliced given that it is not an aggregate with operator overloads.Parameters:Type ttype to check Returns:true if an expression of type t can be e1 in an array expression
- pure nothrow @nogc @safe ScopeRefbuildScopeRef(STCstc);
- Computes how a parameter may be returned. Shrinking the representation is necessary because STC is so wideParameters:STC stcstorage class of parameter Returns:value from enum ScopeRef
- enumScopeRef: int;
- Classification of 'scope-return-ref' possibilities
- pure nothrow @nogc @safe const(char)*ScopeRefToChars(ScopeRefsr);
- Give us a nice string for debugging purposes.Parameters:ScopeRef srvalue Returns:corresponding string
- TypeVectortoBooleanVector(TypeVectortv);
- Creates an appropriate vector type fortvthat will hold one boolean result for each element of the vector type. The result of vector comparisons is a single or doubleword mask of all 1s (comparison true) or all 0s (comparison false). 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.Parameters:TypeVector tvThe TypeVector to build a vector from. Returns:A vector type suitable for the result of a vector comparison operation.
- ResultVisitType(Result)(Typet);
- Dispatch to function based on static type of Type.
- pure @safe stringvisitTYCase(stringhandler);
- CTFE-only helper function for VisitInitializer.Parameters:string handlerstring for the name of the visit handler Returns:boilerplate code for a case
- TypeIdentifiergetThrowable();
- Returns:TypeIdentifier corresponding to object.Throwable
- TypeIdentifiergetException();
- Returns:TypeIdentifier corresponding to object.Exception
Copyright © 1999-2025 by the D Language Foundation | Page generated by
Ddoc on Mon Mar 31 10:27:58 2025