Example #1
0
 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));
Example #2
0
 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()));
 }
Example #3
0
        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)));
            }
        }