dmd.dcast
Semantic analysis for cast-expressions.
License
Source: dcast.d
Documentation: https://dlang.org/phobos/dmd_dcast.html
-
Declaration
ExpressionimplicitCastTo(Expressione, Scope*sc, Typet);Attempt to implicitly cast the expression into type
.tDiscussion
This routine will change
. To check the matching level, useeimplicitConvTo.Parameters
ExpressioneExpression that is to be casted
Scope*scCurrent scope
TypetExpected resulting type
Return Value
The resulting casted expression (mutating
), oreErrorExpif such an implicit conversion is not possible. -
Declaration
MATCHimplicitConvTo(Expressione, Typet);Checks whether or not an expression can be implicitly converted to type
.tDiscussion
Unlike
implicitCastTo, this routine does not perform the actual cast, but only checks up to whatMATCHlevel the conversion would be possible.Parameters
ExpressioneExpression that is to be casted
TypetExpected resulting type
Return Value
The
MATCHlevel betweenande.type.t -
Declaration
MATCHcimplicitConvTo(Expressione, Typet);Same as implicitConvTo(); except follow C11 rules, which are quite a bit more permissive than D. C11 6.3 and 6.5.16.1
Parameters
ExpressioneExpression that is to be casted
TypetExpected resulting type
Return Value
The
MATCHlevel betweenande.type.t -
Declaration
TypetoStaticArrayType(SliceExpe); -
Declaration
ExpressioncastTo(Expressione, Scope*sc, Typet, Typeatt= null);Do an explicit cast. Assume that the expression
does not have any indirections. (Parameter 'eatt' is used to stop 'alias this' recursion) -
Declaration
ExpressioninferType(Expressione, Typet, intflag= 0);Set type inference target
tTarget typeflag1: don'tput an error when inference fails -
Declaration
ExpressionscaleFactor(BinExpbe, Scope*sc);Scale addition/subtraction to/from pointer.
-
Declaration
TypetypeMerge(Scope*sc, TOKop, ref Expressionpe1, ref Expressionpe2);Merge types of
e1ande2into a common subsetDiscussion
Parameters
e1ande2will be rewritten in place as needed.Parameters
Scope*scCurrent scope
TOKopOperator such as
e1. In practice, either TOK.question or one of the binary operator.ope2Expressionpe1The LHS of the operation, will be rewritten
Expressionpe2The RHS of the operation, will be rewritten
Return Value
The resulting type in case of success,
nullin case of error -
Declaration
ExpressiontypeCombine(BinExpbe, Scope*sc);Bring leaves to common type.
Return Value
nullon success, ErrorExp if error occurs -
Declaration
ExpressionintegralPromotions(Expressione, Scope*sc);Do integral promotions (convertchk). Don't convert
to -
Declaration
voidfix16997(Scope*sc, UnaExpue);This provides a transition from the non-promoting behavior of unary + - ~ to the C-like integral promotion behavior.
Parameters
Scope*sccontext
UnaExpueNegExp, UAddExp, or ComExp which is revised per rules
References: https://issues.dlang.org/show_bug.cgi?id=16997
-
Declaration
boolarrayTypeCompatibleWithoutCasting(Typet1, Typet2);See if both types are arrays that can be compared for equality without any casting. Return
trueif so. This is to enable comparing things like an immutable array with a mutable one. -
Declaration
IntRangegetIntRange(Expressione);