Movatterモバイル変換


[0]ホーム

URL:


D Logo
Menu
Search

Library Reference

version 2.112.0

overview

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 usinga local clone.

dmd.mtype

Defines a D type.
Authors:
Walter Bright
License:
Boost License 1.0

Sourcemtype.d

Documentationhttps://dlang.org/phobos/dmd_mtype.html

Coveragehttps://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/mtype.d

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 tokenmod corresponds 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.Ifsemantic() 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.
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. Usebefore semantic analysis is run.
final TypetoBasetype();
If this is a shell around another type, get that other type.
MODdeduceWild(Typet, boolisRef);
Compute MOD bits matchingthis argument type to wild parameter type.
Parameters:
Typetcorresponding parameter type
boolisRefparameter isref orout
Returns:
MOD bits
structalign_talignment();
Return alignment to use for this type.
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 members
Returns:
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 ulongsizemask();
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 type
Returns:
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 forextern (D) U func(T t, ...) variadic function type, which has_arguments[] added as the first argument.
Returns:
true if D-style variadic
pure nothrow @nogc @safe booliswild() const;
Returns:
true the function isisInOutQual orisInOutParam ,false otherwise.
pure nothrow @nogc @safe boolattributesEqual(scope const TypeFunctionother, booltrustSystemEqualsDefault = true) const;
Returns:
whetherthis 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(), seehttps://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;
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
Expressions*alignExps;
alignment of struct itself
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 ofbounds. 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 lengthand calling N times opIndex.
intopApply(scope Parameter.SemanticForeachDgdg);
Iterates over the expanded parameters, matching them with the unexpandedones, 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 nthParameter, folding in tuples.
Sinceparameters can include tuples, which would increase its length, this function allows to get thenth parameter as if all tuples transitively contained inparameters were flattened.
Parameters:
Parameters*parametersArray ofParameter to iterate over
size_tnthIndex of the desired parameter.
Returns:
The parameter at indexnth (taking tuples into account), ornull 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 parametersthis andp as determined by the storage classes of both.
Parameters:
boolreturnByReftrue if the function returns by ref
ParameterpParameter to compare with
Returns:
true =this can be used in place ofp false = nope
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
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) callfp 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) callfp 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:
Typettype 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 wide
Parameters:
STCstcstorage 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:
ScopeRefsrvalue
Returns:
corresponding string
TypeVectortoBooleanVector(TypeVectortv);
Creates an appropriate vector type fortv that 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:
TypeVectortvTheTypeVector 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:
stringhandlerstring for the name of the visit handler
Returns:
boilerplate code for a case
TypeIdentifiergetThrowable();
Returns:
TypeIdentifier corresponding toobject.Throwable
TypeIdentifiergetException();
Returns:
TypeIdentifier corresponding toobject.Exception
Copyright © 1999-2026 by theD Language Foundation | Page generated byDdoc on Sat Feb 21 00:05:01 2026

[8]ページ先頭

©2009-2026 Movatter.jp