public static ForStatementSyntax GetReverseForStatement(RewriteDesign design, LocalVariable indexerVariable, ValueBridge min, ValueBridge increment, List <IStatementSyntax> loopContent) => ForStatement( null, default, indexerVariable.GeThan(min), CreateSeparatedExpressionList(indexerVariable.AddAssign(increment)), GetBody(design, loopContent));
private static void CalculateSimpleAverage(RewriteDesign design, TypedValueBridge selectionValue, LocalVariable sumVariable) { if (!AssertResultSizeGreaterEqual(design, 1)) { return; } design.ForAdd(sumVariable.AddAssign(selectionValue)); design.ResultAdd(Return(sumVariable / design.GetResultSize())); }
private static void CalculateNullableAverage(RewriteDesign design, TypeBridge elementType, TypedValueBridge selectionValue, LocalVariable sumVariable) { var inlinedValue = selectionValue.Reusable(design); design.ForAdd(If(inlinedValue.IsEqual(null), Continue())); design.ForAdd(sumVariable.AddAssign(inlinedValue.Cast(elementType))); design.Indexer = null; if (design.Unchecked) { design.ResultAdd(sumVariable.Cast(design.ReturnType.Type) / design.Indexer); } else { design.ResultAdd(Return(SyntaxFactory.ConditionalExpression(design.Indexer.IsEqual(0), Null, sumVariable.Cast(design.ReturnType.Type) / design.Indexer))); } }