/// <summary> /// Reduces the expression node to a simpler expression. /// </summary> /// <returns>The reduced expression.</returns> public override Expression Reduce() { var left = MakeWriteable(Left); if (CSharpNodeType == CSharpExpressionType.NullCoalescingAssign) { // NB: NullCoalescingAssign is handled by the Reduce implementation on the derived type. throw ContractUtils.Unreachable; } if (CSharpNodeType == CSharpExpressionType.Assign) { // NB: We still use `ReduceAssignment` here to deal with IndexCSharpExpression which is not // a valid LHS to Expression.Assign. return(left switch { IndexCSharpExpression indexCSharp => indexCSharp.ReduceAssign(lhs => Expression.Assign(lhs, Right)), ArrayAccessCSharpExpression arrayAccessCSharp => arrayAccessCSharp.ReduceAssign(lhs => Expression.Assign(lhs, Right)), IndexerAccessCSharpExpression indexerAccessCSharp => indexerAccessCSharp.ReduceAssign(lhs => Expression.Assign(lhs, Right)), _ => Expression.Assign(left, Right) });
private static Expression ReduceIndexCSharp(IndexCSharpExpression index, Func <Expression, Expression> functionalOp, bool prefix, LambdaExpression leftConversion) { return(index.ReduceAssign(x => ReduceVariable(x, functionalOp, prefix, leftConversion))); }
private static Expression ReduceIndexCSharp(IndexCSharpExpression index, Func<Expression, Expression> functionalOp, bool prefix, LambdaExpression leftConversion) { return index.ReduceAssign(x => ReduceVariable(x, functionalOp, prefix, leftConversion)); }