dmd.optimize
Perform constant folding.
License
Source: optimize.d
Documentation: https://dlang.org/phobos/dmd_optimize.html
-
Declaration
Expression
expandVar
(intresult
, VarDeclarationv
);If variable has a const initializer, return that initializer.
Return Value
initializer if there is one,
null
if not, ErrorExp if error -
Declaration
package void
setLengthVarIfKnown
(VarDeclarationlengthVar
, Expressionarr
);It is possible for constant folding to change an array expression of unknown length, into one where the length is known. If the expression '
arr
' is a literal, setlengthVar
to be its length.Parameters
VarDeclaration
lengthVar
variable declaration for the
.length
propertyExpression
arr
String, ArrayLiteral, or of TypeSArray
-
Declaration
package void
setLengthVarIfKnown
(VarDeclarationlengthVar
, Typetype
);Same as above, but determines the length from '
type
'.Parameters
VarDeclaration
lengthVar
variable declaration for the
.length
propertyType
type
TypeSArray
-
Declaration
Expression
Expression_optimize
(Expressione
, intresult
, boolkeepLvalue
);Constant fold an Expression.
Parameters
Expression
e
expression to const fold; this may get modified in-place
int
result
WANTvalue, WANTexpand, or both
bool
keepLvalue
is an lvalue, and keep it as an lvalue since it is an argument to ae
ref
orout
parameter, or the operand of&
operatorReturn Value
Constant folded version of
e