5 types derived from Tests
Microsoft.CodeAnalysis.CSharp (5)
Binder\DecisionDagBuilder.cs (5)
2474public sealed class True : Tests 2498public sealed class False : Tests 2524public sealed class One : Tests 2988public sealed class Not : Tests 3041public abstract class SequenceTests : Tests
222 references to Tests
Microsoft.CodeAnalysis.CSharp (222)
Binder\DecisionDagBuilder.cs (214)
191Tests tests = MakeAndSimplifyTestsAndBindings(input, pattern, out ImmutableArray<BoundPatternBinding> bindings); 195private Tests MakeAndSimplifyTestsAndBindings( 201Tests tests = MakeTestsAndBindings(input, pattern, bindingsBuilder); 207private static Tests SimplifyTestsAndBindings( 208Tests tests, 224var testsToSimplify = ArrayBuilder<Tests?>.GetInstance(); 225var testsToAssemble = ArrayBuilder<Tests>.GetInstance(); 226var testsSimplified = ArrayBuilder<Tests>.GetInstance(); 232var current = testsToSimplify.Pop(); 236case Tests.SequenceTests seq: 241case Tests.True _: 242case Tests.False _: 245case Tests.One(BoundDagEvaluation e): 255testsSimplified.Push(Tests.True.Instance); 258case Tests.One(BoundDagTest d): 264case Tests.Not n: 271var toAssemble = testsToAssemble.Pop(); 274case Tests.SequenceTests seq: 276var newSequence = ArrayBuilder<Tests>.GetInstance(length); 285case Tests.Not: 286testsSimplified.Push(Tests.Not.Create(testsSimplified.Pop())); 299var result = testsSimplified.Pop(); 314private Tests MakeTestsAndBindings( 327private Tests MakeTestsAndBindings( 343return Tests.True.Instance; 364private Tests MakeTestsAndBindingsForITuplePattern( 377var tests = ArrayBuilder<Tests>.GetInstance(4 + patternLength * 2); 379tests.Add(new Tests.One(new BoundDagTypeTest(syntax, iTupleType, input))); 381tests.Add(new Tests.One(valueAsITupleEvaluation)); 386tests.Add(new Tests.One(lengthEvaluation)); 388tests.Add(new Tests.One(new BoundDagValueTest(syntax, ConstantValue.Create(patternLength), lengthTemp))); 394tests.Add(new Tests.One(indexEvaluation)); 399return Tests.AndSequence.Create(tests); 436private Tests MakeTestsAndBindingsForDeclarationPattern( 443var tests = ArrayBuilder<Tests>.GetInstance(1); 461return Tests.AndSequence.Create(tests); 464private Tests MakeTestsForTypePattern( 470var tests = ArrayBuilder<Tests>.GetInstance(4); 472return Tests.AndSequence.Create(tests); 479ArrayBuilder<Tests> tests) 486tests.Add(new Tests.One(new BoundDagNonNullTest(syntax, isExplicitTest, input))); 498ArrayBuilder<Tests> tests) 516tests.Add(new Tests.One(new BoundDagTypeTest(syntax, type, input))); 521tests.Add(new Tests.One(evaluation)); 527private Tests MakeTestsForConstantPattern( 535return new Tests.One(new BoundDagExplicitNullTest(constant.Syntax, input)); 540return new Tests.One(new BoundDagValueTest(constant.Syntax, constant.ConstantValue, input)); 544var tests = ArrayBuilder<Tests>.GetInstance(2); 551tests.Add(Tests.False.Instance); 555tests.Add(new Tests.One(new BoundDagValueTest(constant.Syntax, constant.ConstantValue, input))); 557return Tests.AndSequence.Create(tests); 561private Tests MakeTestsAndBindingsForRecursivePattern( 569var tests = ArrayBuilder<Tests>.GetInstance(5); 579tests.Add(new Tests.One(evaluation)); 609tests.Add(new Tests.One(evaluation)); 619tests.Add(new Tests.One(new BoundDagTypeTest(recursive.Syntax, ErrorType(), input, hasErrors: true))); 633tests.Add(new Tests.One(new BoundDagTypeTest(recursive.Syntax, ErrorType(), input, hasErrors: true))); 648return Tests.AndSequence.Create(tests); 683tests.Add(new Tests.One(evaluation)); 688private Tests MakeTestsAndBindingsForNegatedPattern(BoundDagTemp input, BoundNegatedPattern neg, ArrayBuilder<BoundPatternBinding> bindings) 690var tests = MakeTestsAndBindings(input, neg.Negated, bindings); 691return Tests.Not.Create(tests); 694private Tests MakeTestsAndBindingsForBinaryPattern( 712Tests result = MakeTestsAndBindings(input, currentNode.Left, out output, bindings); 723static Tests makeTestsAndBindingsForBinaryPattern(DecisionDagBuilder @this, Tests leftTests, BoundDagTemp leftOutput, BoundDagTemp input, BoundBinaryPattern bin, out BoundDagTemp output, ArrayBuilder<BoundPatternBinding> bindings) 725var builder = ArrayBuilder<Tests>.GetInstance(2); 730var result = Tests.OrSequence.Create(builder); 738builder = ArrayBuilder<Tests>.GetInstance(2); 742builder.Add(new Tests.One(evaluation)); 743return Tests.AndSequence.Create(builder); 752return Tests.AndSequence.Create(builder); 757private Tests MakeTestsAndBindingsForRelationalPattern( 765var tests = ArrayBuilder<Tests>.GetInstance(2); 771tests.Add(Tests.False.Instance); 775tests.Add(new Tests.One(new BoundDagRelationalTest(rel.Syntax, rel.Relation, rel.ConstantValue, output, rel.HasErrors))); 778return Tests.AndSequence.Create(tests); 1223RoslynDebug.Assert(!(first.RemainingTests is Tests.False)); 1290stateForCase.RemainingTests.Filter(this, test, state, whenTrueValues, whenFalseValues, out Tests whenTrueTests, out Tests whenFalseTests, ref foundExplicitNullTest); 1423var remainingTests = stateForCase.RemainingTests.RemoveEvaluation(this, state, stateForCase.Bindings, e); 1424if (remainingTests is Tests.False) 2257public readonly Tests RemainingTests; 2264Tests RemainingTests, 2280public bool IsFullyMatched => RemainingTests is Tests.True && (WhenClause is null || WhenClause.ConstantValueOpt == ConstantValue.True); 2285public bool PatternIsSatisfied => RemainingTests is Tests.True; 2291public bool IsImpossible => RemainingTests is Tests.False; 2311public StateForCase WithRemainingTests(Tests newRemainingTests) 2318/// <inheritdoc cref="Tests.RewriteNestedLengthTests"/> 2341out Tests whenTrue, 2342out Tests whenFalse, 2351public readonly Tests FinalResult; 2357public readonly Tests? ConditionToUseFinalResult; 2358public readonly Tests? TempsUpdatedResult; 2361Tests finalResult, 2363Tests? conditionToUseFinalResult, 2364Tests? tempsUpdatedResult) 2377public Tests RemoveEvaluation(DecisionDagBuilder dagBuilder, DagState state, ImmutableArray<BoundPatternBinding> bindings, BoundDagEvaluation e) 2382protected Tests RemoveEvaluationAndUpdateTempReferences(DecisionDagBuilder dagBuilder, DagState state, ImmutableArray<BoundPatternBinding> bindings, ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagEvaluation e) 2391var finalResult = ArrayBuilder<Tests>.GetInstance(2); 2428private static void AddBindingsPatchingAssignments(ImmutableArray<BoundPatternBinding> bindings, ImmutableDictionary<BoundDagTemp, BoundDagTemp> oldTempMap, ImmutableDictionary<BoundDagTemp, BoundDagTemp> newTempMap, ArrayBuilder<Tests> assignments) 2443assignments.Add(new Tests.One(new BoundDagAssignmentEvaluation(useValueFrom.Syntax, b.TempContainingValue, useValueFrom))); 2468public virtual Tests RewriteNestedLengthTests() => this; 2484out Tests whenTrue, 2485out Tests whenFalse, 2508out Tests whenTrue, 2509out Tests whenFalse, 2535out Tests whenTrue, 2536out Tests whenFalse, 2562whenTrue = trueDecisionImpliesTrueOther ? Tests.True.Instance : trueDecisionPermitsTrueOther ? this : (Tests)Tests.False.Instance; 2563whenFalse = falseDecisionImpliesTrueOther ? Tests.True.Instance : falseDecisionPermitsTrueOther ? this : (Tests)Tests.False.Instance; 2570public override Tests RewriteNestedLengthTests() 2609static Tests? knownResult(BinaryOperatorKind relation, ConstantValue constant, int offset) 2638return new RemoveEvaluationAndUpdateTempReferencesResult(Tests.True.Instance, tempMap, conditionToUseFinalResult: null, tempsUpdatedResult: null); 2653Tests finalResult = RemoveEvaluation(tempsUpdatedResult, builder, state, ref tempMap, e, out var condition); 2691public static Tests RemoveEvaluation(One tests, DecisionDagBuilder builder, DagState state, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagEvaluation e, out Tests? condition) 2742private static Tests RemoveAssignmentEvaluation(One tests, BoundDagAssignmentEvaluation e1) 2746return Tests.True.Instance; 2752private static Tests RemoveSimpleEvaluationWithResultTemp(One tests, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagEvaluation e1) 2758return Tests.True.Instance; 2786private static Tests RemoveDeconstructEvaluation(One tests, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagDeconstructEvaluation e1) 2792return Tests.True.Instance; 2810private static Tests RemoveTypeEvaluation(One tests, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagTypeEvaluation e1) 2820return Tests.True.Instance; 2827private static Tests RemoveIndexerEvaluation(One tests, DecisionDagBuilder dagBuilder, DagState state, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagIndexerEvaluation s1, out Tests? condition) 2847return Tests.True.Instance; 2865return Tests.True.Instance; 2873condition = new Tests.One(new BoundDagValueTest(s2.Syntax, ConstantValue.Create(lengthValue), s1LengthTemp)); 2875return Tests.True.Instance; 2991public readonly Tests Negated; 2992private Not(Tests negated) => Negated = negated; 2993public static Tests Create(Tests negated) => negated switch 2995Tests.True _ => Tests.False.Instance, 2996Tests.False _ => Tests.True.Instance, 2997Tests.Not n => n.Negated, // double negative 2998Tests.AndSequence a => new Not(a), 2999Tests.OrSequence a => Tests.AndSequence.Create(NegateSequenceElements(a.RemainingTests)), // use demorgan to prefer and sequences 3000Tests.One o => new Not(o), 3003private static ArrayBuilder<Tests> NegateSequenceElements(ImmutableArray<Tests> seq) 3005var builder = ArrayBuilder<Tests>.GetInstance(seq.Length); 3006foreach (var t in seq) 3020public override Tests RewriteNestedLengthTests() => Create(Negated.RewriteNestedLengthTests()); 3029out Tests whenTrue, 3030out Tests whenFalse, 3033Negated.Filter(builder, test, state, whenTrueValues, whenFalseValues, out var whenTestTrue, out var whenTestFalse, ref foundExplicitNullTest); 3043public readonly ImmutableArray<Tests> RemainingTests; 3044protected SequenceTests(ImmutableArray<Tests> remainingTests) 3049public abstract Tests Update(ArrayBuilder<Tests> remainingTests); 3056out Tests whenTrue, 3057out Tests whenFalse, 3060var testsToFilter = ArrayBuilder<Tests?>.GetInstance(); 3062var trueTests = ArrayBuilder<Tests>.GetInstance(); 3063var falseTests = ArrayBuilder<Tests>.GetInstance(); 3069var current = testsToFilter.Pop(); 3091current.Filter(builder, test, state, whenTrueValues, whenFalseValues, out Tests oneTrue, out Tests oneFalse, ref foundExplicitNullTest); 3113static void assemble(SequenceTests toAssemble, ArrayBuilder<Tests> tests) 3116var newSequence = ArrayBuilder<Tests>.GetInstance(length, null!); 3134var testsToRewrite = ArrayBuilder<(Tests? Tests, bool SkipRewrite)>.GetInstance(); 3140var testsRewritten = ArrayBuilder<Tests>.GetInstance(); 3151ImmutableArray<Tests> remainingTests = seq.RemainingTests; 3165var newSequence = ArrayBuilder<Tests>.GetInstance(childCount); 3219var result = testsRewritten.Pop(); 3248var leftToRewriteBuilder = ArrayBuilder<Tests>.GetInstance(); 3275void pushConditionalResult(RemoveEvaluationAndUpdateTempReferencesResult rewriteResult, ArrayBuilder<Tests> leftToRewriteBuilder) 3339void popAndAddChildrenLeftToRewrite(ArrayBuilder<Tests> leftToRewriteBuilder) 3357public sealed override Tests RewriteNestedLengthTests() 3359var testsToRewrite = ArrayBuilder<Tests?>.GetInstance(); 3361var testsRewritten = ArrayBuilder<Tests>.GetInstance(); 3367var current = testsToRewrite.Pop(); 3380var newSequence = ArrayBuilder<Tests>.GetInstance(length); 3396var result = testsRewritten.Pop(); 3420var tests1 = ArrayBuilder<Tests>.GetInstance(); 3421var tests2 = ArrayBuilder<Tests>.GetInstance(); 3428var t1 = tests1.Pop(); 3429var t2 = tests2.Pop(); 3496var tests = ArrayBuilder<Tests>.GetInstance(); 3501var t = tests.Pop(); 3542Tests firstTest; 3574private AndSequence(ImmutableArray<Tests> remainingTests) : base(remainingTests) 3578public override Tests Update(ArrayBuilder<Tests> remainingTests) => Create(remainingTests); 3579public static Tests Create(Tests t1, Tests t2) 3584var builder = ArrayBuilder<Tests>.GetInstance(2); 3589public static Tests Create(ArrayBuilder<Tests> remainingTests) 3609var result = remainingTests.Count switch 3656private OrSequence(ImmutableArray<Tests> remainingTests) : base(remainingTests) 3660public override Tests Update(ArrayBuilder<Tests> remainingTests) => Create(remainingTests); 3661public static Tests Create(Tests t1, Tests t2) 3666var builder = ArrayBuilder<Tests>.GetInstance(2); 3671public static Tests Create(ArrayBuilder<Tests> remainingTests) 3691var result = remainingTests.Count switch
Binder\DecisionDagBuilder_ListPatterns.cs (8)
14private Tests MakeTestsAndBindingsForListPattern(BoundDagTemp input, BoundListPattern list, out BoundDagTemp output, ArrayBuilder<BoundPatternBinding> bindings) 24var tests = ArrayBuilder<Tests>.GetInstance(4 + subpatterns.Length * 2); 29tests.Add(new Tests.One(new BoundDagTypeTest(list.Syntax, ErrorType(), input, hasErrors: true))); 43tests.Add(new Tests.One(lengthEvaluation)); 45tests.Add(new Tests.One(list.HasSlice 67tests.Add(new Tests.One(sliceEvaluation)); 82tests.Add(new Tests.One(indexEvaluation)); 93return Tests.AndSequence.Create(tests);