5 types derived from Tests
Microsoft.CodeAnalysis.CSharp (5)
Binder\DecisionDagBuilder.cs (5)
2131public sealed class True : Tests 2152public sealed class False : Tests 2175public sealed class One : Tests 2320public sealed class Not : Tests 2365public abstract class SequenceTests : Tests
204 references to Tests
Microsoft.CodeAnalysis.CSharp (204)
Binder\DecisionDagBuilder.cs (196)
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( 378var tests = ArrayBuilder<Tests>.GetInstance(4 + patternLength * 2); 380tests.Add(new Tests.One(new BoundDagTypeTest(syntax, iTupleType, input))); 382tests.Add(new Tests.One(valueAsITupleEvaluation)); 387tests.Add(new Tests.One(lengthEvaluation)); 389tests.Add(new Tests.One(new BoundDagValueTest(syntax, ConstantValue.Create(patternLength), lengthTemp))); 395tests.Add(new Tests.One(indexEvaluation)); 400return Tests.AndSequence.Create(tests); 437private Tests MakeTestsAndBindingsForDeclarationPattern( 444var tests = ArrayBuilder<Tests>.GetInstance(1); 462return Tests.AndSequence.Create(tests); 465private Tests MakeTestsForTypePattern( 471var tests = ArrayBuilder<Tests>.GetInstance(4); 473return Tests.AndSequence.Create(tests); 480ArrayBuilder<Tests> tests) 487tests.Add(new Tests.One(new BoundDagNonNullTest(syntax, isExplicitTest, input))); 499ArrayBuilder<Tests> tests) 517tests.Add(new Tests.One(new BoundDagTypeTest(syntax, type, input))); 522tests.Add(new Tests.One(evaluation)); 528private Tests MakeTestsForConstantPattern( 536return new Tests.One(new BoundDagExplicitNullTest(constant.Syntax, input)); 541return new Tests.One(new BoundDagValueTest(constant.Syntax, constant.ConstantValue, input)); 545var tests = ArrayBuilder<Tests>.GetInstance(2); 552tests.Add(Tests.False.Instance); 556tests.Add(new Tests.One(new BoundDagValueTest(constant.Syntax, constant.ConstantValue, input))); 558return Tests.AndSequence.Create(tests); 562private Tests MakeTestsAndBindingsForRecursivePattern( 570var tests = ArrayBuilder<Tests>.GetInstance(5); 580tests.Add(new Tests.One(evaluation)); 610tests.Add(new Tests.One(evaluation)); 620tests.Add(new Tests.One(new BoundDagTypeTest(recursive.Syntax, ErrorType(), input, hasErrors: true))); 634tests.Add(new Tests.One(new BoundDagTypeTest(recursive.Syntax, ErrorType(), input, hasErrors: true))); 649return Tests.AndSequence.Create(tests); 676tests.Add(new Tests.One(evaluation)); 682private Tests MakeTestsAndBindingsForNegatedPattern(BoundDagTemp input, BoundNegatedPattern neg, ArrayBuilder<BoundPatternBinding> bindings) 684var tests = MakeTestsAndBindings(input, neg.Negated, bindings); 685return Tests.Not.Create(tests); 688private Tests MakeTestsAndBindingsForBinaryPattern( 706Tests result = MakeTestsAndBindings(input, currentNode.Left, out output, bindings); 717static Tests makeTestsAndBindingsForBinaryPattern(DecisionDagBuilder @this, Tests leftTests, BoundDagTemp leftOutput, BoundDagTemp input, BoundBinaryPattern bin, out BoundDagTemp output, ArrayBuilder<BoundPatternBinding> bindings) 719var builder = ArrayBuilder<Tests>.GetInstance(2); 724var result = Tests.OrSequence.Create(builder); 732builder = ArrayBuilder<Tests>.GetInstance(2); 736builder.Add(new Tests.One(evaluation)); 737return Tests.AndSequence.Create(builder); 746return Tests.AndSequence.Create(builder); 751private Tests MakeTestsAndBindingsForRelationalPattern( 759var tests = ArrayBuilder<Tests>.GetInstance(2); 765tests.Add(Tests.False.Instance); 769tests.Add(new Tests.One(new BoundDagRelationalTest(rel.Syntax, rel.Relation, rel.ConstantValue, output, rel.HasErrors))); 772return Tests.AndSequence.Create(tests); 1060RoslynDebug.Assert(!(first.RemainingTests is Tests.False)); 1127stateForCase.RemainingTests.Filter(this, test, state, whenTrueValues, whenFalseValues, out Tests whenTrueTests, out Tests whenFalseTests, ref foundExplicitNullTest); 1259var remainingTests = stateForCase.RemainingTests.RemoveEvaluation(e); 1260if (remainingTests is Tests.False) 1462out Tests relationCondition, 1463out Tests relationEffect) 1465relationCondition = Tests.True.Instance; 1466relationEffect = Tests.True.Instance; 1488ArrayBuilder<Tests>? conditions = null; 1502relationCondition = Tests.AndSequence.Create(conditions); 1506relationEffect = new Tests.One(new BoundDagAssignmentEvaluation(syntax, target: other.Input, input: test.Input)); 1546(conditions ??= ArrayBuilder<Tests>.GetInstance()).Add(new Tests.One(new BoundDagValueTest(syntax, ConstantValue.Create(lengthValue), s1LengthTemp))); 2033public readonly Tests RemainingTests; 2040Tests RemainingTests, 2056public bool IsFullyMatched => RemainingTests is Tests.True && (WhenClause is null || WhenClause.ConstantValueOpt == ConstantValue.True); 2061public bool PatternIsSatisfied => RemainingTests is Tests.True; 2067public bool IsImpossible => RemainingTests is Tests.False; 2087public StateForCase WithRemainingTests(Tests newRemainingTests) 2094/// <inheritdoc cref="Tests.RewriteNestedLengthTests"/> 2117out Tests whenTrue, 2118out Tests whenFalse, 2121public virtual Tests RemoveEvaluation(BoundDagEvaluation e) => this; 2125public virtual Tests RewriteNestedLengthTests() => this; 2141out Tests whenTrue, 2142out Tests whenFalse, 2162out Tests whenTrue, 2163out Tests whenFalse, 2186out Tests whenTrue, 2187out Tests whenFalse, 2194relationCondition: out Tests relationCondition, 2195relationEffect: out Tests relationEffect)) 2243static Tests rewrite(bool decisionImpliesTrueOther, bool decisionPermitsTrueOther, Tests relationCondition, Tests relationEffect, Tests other) 2253public override Tests RemoveEvaluation(BoundDagEvaluation e) => e.Equals(Test) ? Tests.True.Instance : (Tests)this; 2257public override Tests RewriteNestedLengthTests() 2296static Tests? knownResult(BinaryOperatorKind relation, ConstantValue constant, int offset) 2323public readonly Tests Negated; 2324private Not(Tests negated) => Negated = negated; 2325public static Tests Create(Tests negated) => negated switch 2327Tests.True _ => Tests.False.Instance, 2328Tests.False _ => Tests.True.Instance, 2329Tests.Not n => n.Negated, // double negative 2330Tests.AndSequence a => new Not(a), 2331Tests.OrSequence a => Tests.AndSequence.Create(NegateSequenceElements(a.RemainingTests)), // use demorgan to prefer and sequences 2332Tests.One o => new Not(o), 2335private static ArrayBuilder<Tests> NegateSequenceElements(ImmutableArray<Tests> seq) 2337var builder = ArrayBuilder<Tests>.GetInstance(seq.Length); 2338foreach (var t in seq) 2343public override Tests RemoveEvaluation(BoundDagEvaluation e) => Create(Negated.RemoveEvaluation(e)); 2344public override Tests RewriteNestedLengthTests() => Create(Negated.RewriteNestedLengthTests()); 2353out Tests whenTrue, 2354out Tests whenFalse, 2357Negated.Filter(builder, test, state, whenTrueValues, whenFalseValues, out var whenTestTrue, out var whenTestFalse, ref foundExplicitNullTest); 2367public readonly ImmutableArray<Tests> RemainingTests; 2368protected SequenceTests(ImmutableArray<Tests> remainingTests) 2373public abstract Tests Update(ArrayBuilder<Tests> remainingTests); 2380out Tests whenTrue, 2381out Tests whenFalse, 2384var testsToFilter = ArrayBuilder<Tests?>.GetInstance(); 2386var trueTests = ArrayBuilder<Tests>.GetInstance(); 2387var falseTests = ArrayBuilder<Tests>.GetInstance(); 2393var current = testsToFilter.Pop(); 2415current.Filter(builder, test, state, whenTrueValues, whenFalseValues, out Tests oneTrue, out Tests oneFalse, ref foundExplicitNullTest); 2437static void assemble(SequenceTests toAssemble, ArrayBuilder<Tests> tests) 2440var newSequence = ArrayBuilder<Tests>.GetInstance(length, null!); 2450public sealed override Tests RemoveEvaluation(BoundDagEvaluation e) 2452var testsToRewrite = ArrayBuilder<Tests?>.GetInstance(); 2454var testsRewritten = ArrayBuilder<Tests>.GetInstance(); 2460var current = testsToRewrite.Pop(); 2473var newSequence = ArrayBuilder<Tests>.GetInstance(length); 2489var result = testsRewritten.Pop(); 2503public sealed override Tests RewriteNestedLengthTests() 2505var testsToRewrite = ArrayBuilder<Tests?>.GetInstance(); 2507var testsRewritten = ArrayBuilder<Tests>.GetInstance(); 2513var current = testsToRewrite.Pop(); 2526var newSequence = ArrayBuilder<Tests>.GetInstance(length); 2542var result = testsRewritten.Pop(); 2566var tests1 = ArrayBuilder<Tests>.GetInstance(); 2567var tests2 = ArrayBuilder<Tests>.GetInstance(); 2574var t1 = tests1.Pop(); 2575var t2 = tests2.Pop(); 2642var tests = ArrayBuilder<Tests>.GetInstance(); 2647var t = tests.Pop(); 2688Tests firstTest; 2720private AndSequence(ImmutableArray<Tests> remainingTests) : base(remainingTests) { } 2721public override Tests Update(ArrayBuilder<Tests> remainingTests) => Create(remainingTests); 2722public static Tests Create(Tests t1, Tests t2) 2727var builder = ArrayBuilder<Tests>.GetInstance(2); 2732public static Tests Create(ArrayBuilder<Tests> remainingTests) 2752var result = remainingTests.Count switch 2799private OrSequence(ImmutableArray<Tests> remainingTests) : base(remainingTests) { } 2800public override Tests Update(ArrayBuilder<Tests> remainingTests) => Create(remainingTests); 2801public static Tests Create(Tests t1, Tests t2) 2806var builder = ArrayBuilder<Tests>.GetInstance(2); 2811public static Tests Create(ArrayBuilder<Tests> remainingTests) 2831var 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);