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.dcast
Semantic analysis for cast-expressions.
Authors:
License:
Source dcast.d
Documentation https://dlang.org/phobos/dmd_dcast.html
- Expression
implicitCastTo
(Expressione
, Scope*sc
, Typet
); - Attempt to implicitly cast the expression into type
t
.This routine will changee
. To check the matching level, use implicitConvTo.Parameters:Expression e
Expression that is to be casted Scope* sc
Current scope Type t
Expected resulting type Returns:The resulting casted expression (mutatinge
), or ErrorExp if such an implicit conversion is not possible. - MATCH
implicitConvTo
(Expressione
, Typet
); - Checks whether or not an expression can be implicitly converted to type
t
.Unlike implicitCastTo, this routine does not perform the actual cast, but only checks up to what MATCH level the conversion would be possible.Parameters:Expression e
Expression that is to be casted Type t
Expected resulting type Returns:The MATCH level betweene
.type andt
. - MATCH
cimplicitConvTo
(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.1Parameters:
Expression e
Expression that is to be casted Type t
Expected resulting type Returns:The MATCH level betweene
.type andt
. - Type
toStaticArrayType
(SliceExpe
); - Expression
castTo
(Expressione
, Scope*sc
, Typet
, Typeatt
= null); - Do an explicit cast. Assume that the expression
e
does not have any indirections. (Parameter 'att' is used to stop 'alias this' recursion) - Expression
inferType
(Expressione
, Typet
, intflag
= 0); - Set type inference target t Target type flag 1: don't put an error when inference fails
- Expression
scaleFactor
(BinExpbe
, Scope*sc
); - Scale addition/subtraction to/from pointer.
- Type
typeMerge
(Scope*sc
, EXPop
, ref Expressionpe1
, ref Expressionpe2
); - Merge types of e1 and e2 into a common subsetParameters e1 and e2 will be rewritten in place as needed.Parameters:
Scope* sc
Current scope EXP op
Operator such as e1 op
e2. In practice, either EXP.question or one of the binary operator.Expression pe1
The LHS of the operation, will be rewritten Expression pe2
The RHS of the operation, will be rewritten Returns:The resulting type in case of success, null in case of error - Expression
typeCombine
(BinExpbe
, Scope*sc
); - Bring leaves to common type.Returns:null on success, ErrorExp if error occurs
- Expression
integralPromotions
(Expressione
, Scope*sc
); - Do integral promotions (convertchk). Don't convert
to - void
fix16997
(Scope*sc
, UnaExpue
); - This provides a transition from the non-promoting behavior of unary + - ~ to the C-like integral promotion behavior.Parameters:
Scope* sc
context UnaExp ue
NegExp, UAddExp, or ComExp which is revised per rules - bool
arrayTypeCompatibleWithoutCasting
(Typet1
, Typet2
); - See if both types are arrays that can be compared for equality without any casting. Return true if so. This is to enable comparing things like an immutable array with a mutable one.
- @trusted IntRange
getIntRange
(Expressione
); - Expression
specialNoreturnCast
(ExpressiontoBeCasted
, Typeto
); - A helper function to "cast" from expressions of type noreturn to any other type - noreturn is implicitly convertible to any other type. However, the dmd backend does not like a naive cast from a noreturn expression (particularly an assert(0)) so this function generates:(assert(0), value) instead of cast(
to
)(assert(0)). value is currentlyto
.init however it cannot be read so could be made simpler.Parameters:Expression toBeCasted
Expression of type noreturn to cast Type to
Type to cast the expression to. Returns:A CommaExp, upon any failure ErrorExp will be returned.
Copyright © 1999-2024 by the D Language Foundation | Page generated by
Ddoc on Wed Dec 18 08:51:39 2024