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.typesem

Semantic analysis for D types.
Authors:

Source typesem.d

Expression typeToExpression(Type t);
We've mistakenly parsed t as a type. Redo t as an Expression only if there are no type modifiers.
Parameters:
Type t mistaken type
Returns:
t redone as Expression, null if cannot
MATCH callMatch(TypeFunction tf, Type tthis, ArgumentList argumentList, int flag = 0, const(char)** pMessage = null, Scope* sc = null);
'args' are being matched to function type 'tf' Determine match level.
Parameters:
TypeFunction tf function type
Type tthis type of this pointer, null if not member function
ArgumentList argumentList arguments to function call
int flag 1: performing a partial ordering match
const(char)** pMessage address to store error message, or null
Scope* sc context
Returns:
MATCHxxxx
Type typeSemantic(Type type, const ref Loc loc, Scope* sc);
Perform semantic analysis on a type.
Parameters:
Type type Type AST node
Loc loc the location of the type
Scope* sc context
Returns:
Type with completed semantic analysis, Terror if errors were encountered
Type merge(Type type);
If an identical type to type is in type.stringtable, return the latter one. Otherwise, add it to type.stringtable. Some types don't get merged and are returned as-is.
Parameters:
Type type Type to check against existing types
Returns:
the type that was merged
Expression getProperty(Type t, Scope* scope_, const ref Loc loc, Identifier ident, int flag, Expression src = null);
Calculate built-in properties which just the type is necessary.
Parameters:
Type t the type for which the property is calculated
Scope* scope_ the scope from which the property is being accessed. Used for visibility checks only.
Loc loc the location where the property is encountered
Identifier ident the identifier of the property
int flag if flag & 1, don't report "not a property" error and just return NULL.
Expression src expression for type t or null.
Returns:
expression representing the property, or null if not a property and (flag & 1)
void resolve(Type mt, const ref Loc loc, Scope* sc, out Expression pe, out Type pt, out Dsymbol ps, bool intypeid = false);
Resolve type 'mt' to either type, symbol, or expression. If errors happened, resolved to Type.terror.
Parameters:
Type mt type to be resolved
Loc loc the location where the type is encountered
Scope* sc the scope of the type
Expression pe is set if t is an expression
Type pt is set if t is a type
Dsymbol ps is set if t is a symbol
bool intypeid true if in type id
Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag flag);
Access the members of the object e. This type is same as e.type.
Parameters:
Type mt type for which the dot expression is used
Scope* sc instantiating scope
Expression e expression to convert
Identifier ident identifier being used
DotExpFlag flag DotExpFlag bit flags
Returns:
resulting expression with e.ident resolved
Expression defaultInit(Type mt, const ref Loc loc, const bool isCfile = false);
Get the default initialization expression for a type.
Parameters:
Type mt the type for which the init expression is returned
Loc loc the location where the expression needs to be evaluated
bool isCfile default initializers are different with C
Returns:
The initialization expression for the type.
Type getComplexLibraryType(const ref Loc loc, Scope* sc, TY ty);
Extract complex type from core.stdc.config
Parameters:
Loc loc for error messages
Scope* sc context
TY ty a complex or imaginary type
Returns:
Complex!float, Complex!double, Complex!real or null for error
Covariant covariant(Type src, Type t, StorageClass* pstc = null, bool cppCovariant = false);
Covariant means that 'src' can substitute for 't', i.e. a pure function is a match for an impure type.
Parameters:
Type src source type
Type t type 'src' is covariant with
StorageClass* pstc if not null, store STCxxxx which would make it covariant
bool cppCovariant true if extern(C++) function types should follow C++ covariant rules
Returns:
An enum value of either Covariant.yes or a reason it's not covariant.