dmd.optimize
Perform constant folding.
License
Source: optimize.d
Documentation: https://dlang.org/phobos/dmd_optimize.html
-
Declaration
ExpressionexpandVar(intresult, VarDeclarationv);If variable has a const initializer, return that initializer.
Return Value
initializer if there is one,
nullif not, ErrorExp if error -
Declaration
package voidsetLengthVarIfKnown(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, setlengthVarto be its length.Parameters
VarDeclarationlengthVarvariable declaration for the
.lengthpropertyExpressionarrString, ArrayLiteral, or of TypeSArray
-
Declaration
package voidsetLengthVarIfKnown(VarDeclarationlengthVar, Typetype);Same as above, but determines the length from '
type'.Parameters
VarDeclarationlengthVarvariable declaration for the
.lengthpropertyTypetypeTypeSArray
-
Declaration
ExpressionExpression_optimize(Expressione, intresult, boolkeepLvalue);Constant fold an Expression.
Parameters
Expressioneexpression to const fold; this may get modified in-place
intresultWANTvalue, WANTexpand, or both
boolkeepLvalueis an lvalue, and keep it as an lvalue since it is an argument to aereforoutparameter, or the operand of&operatorReturn Value
Constant folded version of
e