Defines a D type.
pure nothrow @nogc @safe bool
MODimplicitConv(MOD
modfrom, MOD
modto);
Return !=0 if modfrom can be implicitly converted to modto
pure nothrow @nogc @safe MATCH
MODmethodConv(MOD
modfrom, MOD
modto);
Return MATCH.exact or MATCH.constant if a method of type '() modfrom' can call a method of type '() modto'.
pure nothrow @nogc @safe MOD
MODmerge(MOD
mod1, MOD
mod2);
Merge mod bits to form common mod.
nothrow @safe void
MODtoBuffer(ref OutBuffer
buf, MOD
mod);
Store modifier name into buf.
pure nothrow const(char)*
MODtoChars(MOD
mod);
pure nothrow @safe string
MODtoString(MOD
mod);
Returns:a human readable representation ofmod, which is the tokenmod corresponds to
pure nothrow @nogc @safe string
trustToString(TRUST
trust);
Pick off one of the trust flags from trust, and return a string representation of it.
pure nothrow @nogc @safe STC
ModToStc(uint
mod);
Convert MODxxxx to STCxxx
pure nothrow @nogc @safe bool
isSomeChar(TY
ty);
Returns true if ty is char, wchar, or dchar
dotExp() bit flags
Result of a check whether two types are covariant
types are distinct
types are covariant
arguments match as far as overloading goes, but types are not covariant
cannot determine covariance because of forward references
abstract class
Type:
dmd.ast_node.ASTNode;
final size_t
getUniqueID() 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(bool
QualifyTypes = false);
For pretty-printing a type.
static void
deinitialize();
Deinitializes the global state of the compiler.
This can be used to restore the state set by_init to its original state.
final nothrow void
modToBuffer(ref OutBuffer
buf) const;
Store this type's modifier name into buf.
final nothrow char*
modToChars() const;
Return this type's modifier name.
Returns true if T can be converted to boolean value.
final nothrow Type
nullAttributes() const;
Return a copy of this type with all attributes null-initialized. Useful for creating a type with different modifiers.
For our new type 'this', which is type-constructed from t, fill in the cto, ito, sto, scto, wto shortcuts.
Look for bugs in constructing types.
final Type
addSTC(STC
stc);
Apply STCxxxx bits to existing type. Usebefore semantic analysis is run.
If this is a shell around another type, get that other type.
MOD
deduceWild(Type
t, bool
isRef);
Compute MOD bits matchingthis argument type to wild parameter type.
Parameters:Typet | corresponding parameter type |
boolisRef | parameter isref orout |
structalign_t
alignment();
Return alignment to use for this type.
Return !=0 if the type or any of its subtypes is wild.
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.
bool
hasUnsafeBitpatterns();
Detect if this is an unsafe type because of the presence of@system members
Returns:true if type has any invariants
If this is a type of something, return that something.
If this is a type of static array, return its base element type.
Return the mask that an integral type will fit into.
true if when type goes out of scope, it needs a destructor applied. Only applies to value types, not ref types.
bool
needsCopyOrPostblit();
true if when type is copied, it needs a copy constructor or postblit applied. Only applies to value types, not ref types.
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
class
TypeError:
dmd.mtype.Type;
abstract class
TypeNext:
dmd.mtype.Type;
final @safe Type
nextOf();
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.
class
TypeBasic:
dmd.mtype.Type;
class
TypeVector:
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 class
TypeArray:
dmd.mtype.TypeNext;
class
TypeSArray:
dmd.mtype.TypeArray;
Static array, one with a fixed dimension
C11 6.7.6.2-4 incomplete array type
Returns:true if incomplete type
class
TypeDArray:
dmd.mtype.TypeArray;
Dynamic array, no dimension
class
TypeAArray:
dmd.mtype.TypeArray;
class
TypePointer:
dmd.mtype.TypeNext;
class
TypeReference:
dmd.mtype.TypeNext;
class
TypeFunction:
dmd.mtype.TypeNext;
Return true if there are lazy parameters.
pure nothrow @safe bool
isDstyleVariadic() 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 bool
iswild() const;
Returns:true the function isisInOutQual orisInOutParam ,false otherwise.
pure nothrow @nogc @safe bool
attributesEqual(scope const TypeFunction
other, bool
trustSystemEqualsDefault = true) const;
Returns:whetherthis function type has the same attributes (@safe,...) asother
class
TypeDelegate:
dmd.mtype.TypeNext;
class
TypeTraits:
dmd.mtype.Type;
This is a shell containing a TraitsExp that can be either resolved to a type or to a symbol.
The expression to resolve as type or symbol.
Cached type/symbol after semantic analysis.
class
TypeMixin:
dmd.mtype.Type;
Implements mixin types.
Semantic analysis will convert it to a real type.
abstract class
TypeQualified:
dmd.mtype.Type;
class
TypeIdentifier:
dmd.mtype.TypeQualified;
class
TypeInstance:
dmd.mtype.TypeQualified;
Similar to TypeIdentifier, but with a TemplateInstance as the root
class
TypeTypeof:
dmd.mtype.TypeQualified;
class
TypeReturn:
dmd.mtype.TypeQualified;
class
TypeStruct:
dmd.mtype.Type;
class
TypeEnum:
dmd.mtype.Type;
class
TypeClass:
dmd.mtype.Type;
class
TypeTuple:
dmd.mtype.Type;
Form TypeTuple from the types of the expressions. Assume exps[] is already tuple expanded.
Type tuple with 0, 1 or 2 types in it.
class
TypeSlice:
dmd.mtype.TypeNext;
This is so we can slice a TypeTuple
class
TypeNull:
dmd.mtype.Type;
class
TypeNoreturn:
dmd.mtype.Type;
class
TypeTag:
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().
location of declaration
TOK.struct_, TOK.union_, TOK.enum_
alignment of struct/union fields
alignment of struct itself
tag name identifier
base type for enums otherwise null
members of struct, null if none
type after semantic() in case there are more others
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)
The raw (unexpanded) formal parameters, possibly containing tuples.
Returns the number of expanded parameters. Complexity: O(N).
Parameter
opIndex(size_t
i);
Returns the expanded parameter at the given index, or null if out ofbounds. Complexity: O(i).
int
opApply(scope Parameter.ForeachDg
dg);
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.
int
opApply(scope Parameter.SemanticForeachDg
dg);
Iterates over the expanded parameters, matching them with the unexpandedones, for semantic processing
bool
opEquals(ref scope ParameterList
other) const;
Compares this to another ParameterList (and expands tuples if necessary)
Returns:true if any parameter has a default argument
class
Parameter:
dmd.ast_node.ASTNode;
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()
dimpure nothrow @nogc @safe bool
isLazy() const;
Returns:Whether the function parameter is lazy
pure nothrow @nogc @safe bool
isReference() const;
Returns:Whether the function parameter is a reference (out / ref)
static size_t
dim(Parameters*
parameters);
Determine number of arguments, folding in tuples.
static Parameter
getNth(Parameters*
parameters, size_t
nth);
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*parameters | Array ofParameter to iterate over |
size_tnth | Index of the desired parameter. |
Returns:The parameter at indexnth (taking tuples into account), ornull if out of bound.
alias
ForeachDg = int delegate(ulong paramidx, Parameter param);
Type of delegate when iterating solely on the parameters
alias
SemanticForeachDg = 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 ForeachDg
dg);
static int
_foreach(Parameters*
parameters, scope SemanticForeachDg
dg);
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 bool
isCovariant(bool
returnByRef, const Parameter
p) const;
Compute covariance of parametersthis andp as determined by the storage classes of both.
Parameters:boolreturnByRef | true if the function returns by ref |
Parameterp | Parameter to compare with |
Returns:true =this can be used in place ofp false = nope
const(char*)[2]
toAutoQualChars(Type
t1, Type
t2);
For printing two types with qualification when necessary.
Parameters:Typet1 | The first type to receive the type name for |
Typet2 | The 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.
void
modifiersApply(const TypeFunction
tf, 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.
void
attributesApply(const TypeFunction
tf, void delegate(string)
dg, TRUSTformat
trustFormat = TRUSTformatDefault);
For each active attribute (ref/const/nogc/etc) callfp with a void* for the work param and a string representation of the attribute.
AggregateDeclaration
isAggregate(Type
t);
If the type is a class or struct, returns the symbol for it, else null.
bool
isIndexableNonAggregate(Type
t);
Determine if type t can be indexed or sliced given that it is not an aggregate with operator overloads.
Returns:true if an expression of type t can be e1 in an array expression
pure nothrow @nogc @safe ScopeRef
buildScopeRef(STC
stc);
Computes how a parameter may be returned. Shrinking the representation is necessary because STC is so wide
Parameters:STCstc | storage class of parameter |
Returns:value from enum ScopeRef
Classification of 'scope-return-ref' possibilities
pure nothrow @nogc @safe const(char)*
ScopeRefToChars(ScopeRef
sr);
Give us a nice string for debugging purposes.
Returns:corresponding string
TypeVector
toBooleanVector(TypeVector
tv);
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:TypeVectortv | TheTypeVector to build a vector from. |
Returns:A vector type suitable for the result of a vector comparison operation.
Result
VisitType(Result)(Type
t);
Dispatch to function based on static type of Type.
pure @safe string
visitTYCase(string
handler);
CTFE-only helper function for VisitInitializer.
Parameters:stringhandler | string for the name of the visit handler |
Returns:boilerplate code for a case
TypeIdentifier
getThrowable();
Returns:TypeIdentifier corresponding toobject.Throwable
TypeIdentifier
getException();
Returns:TypeIdentifier corresponding toobject.Exception