5 types derived from Tests
Microsoft.CodeAnalysis.CSharp (5)
Binder\DecisionDagBuilder.cs (5)
1933public sealed class True : Tests 1954public sealed class False : Tests 1977public sealed class One : Tests 2122public sealed class Not : Tests 2167public abstract class SequenceTests : Tests
179 references to Tests
Microsoft.CodeAnalysis.CSharp (179)
Binder\DecisionDagBuilder.cs (171)
188Tests tests = MakeAndSimplifyTestsAndBindings(input, pattern, out ImmutableArray<BoundPatternBinding> bindings); 192private Tests MakeAndSimplifyTestsAndBindings( 198Tests tests = MakeTestsAndBindings(input, pattern, bindingsBuilder); 204private static Tests SimplifyTestsAndBindings( 205Tests tests, 221var result = scanAndSimplify(tests); 225Tests scanAndSimplify(Tests tests) 229case Tests.SequenceTests seq: 232var newSequence = ArrayBuilder<Tests>.GetInstance(length); 239case Tests.True _: 240case Tests.False _: 242case Tests.One(BoundDagEvaluation e): 251return Tests.True.Instance; 253case Tests.One(BoundDagTest d): 257case Tests.Not n: 258return Tests.Not.Create(scanAndSimplify(n.Negated)); 265private Tests MakeTestsAndBindings( 278private Tests MakeTestsAndBindings( 294return Tests.True.Instance; 315private Tests MakeTestsAndBindingsForITuplePattern( 329var tests = ArrayBuilder<Tests>.GetInstance(4 + patternLength * 2); 331tests.Add(new Tests.One(new BoundDagTypeTest(syntax, iTupleType, input))); 333tests.Add(new Tests.One(valueAsITupleEvaluation)); 338tests.Add(new Tests.One(lengthEvaluation)); 340tests.Add(new Tests.One(new BoundDagValueTest(syntax, ConstantValue.Create(patternLength), lengthTemp))); 346tests.Add(new Tests.One(indexEvaluation)); 351return Tests.AndSequence.Create(tests); 388private Tests MakeTestsAndBindingsForDeclarationPattern( 395var tests = ArrayBuilder<Tests>.GetInstance(1); 413return Tests.AndSequence.Create(tests); 416private Tests MakeTestsForTypePattern( 422var tests = ArrayBuilder<Tests>.GetInstance(4); 424return Tests.AndSequence.Create(tests); 431ArrayBuilder<Tests> tests) 438tests.Add(new Tests.One(new BoundDagNonNullTest(syntax, isExplicitTest, input))); 450ArrayBuilder<Tests> tests) 468tests.Add(new Tests.One(new BoundDagTypeTest(syntax, type, input))); 473tests.Add(new Tests.One(evaluation)); 479private Tests MakeTestsForConstantPattern( 487return new Tests.One(new BoundDagExplicitNullTest(constant.Syntax, input)); 492return new Tests.One(new BoundDagValueTest(constant.Syntax, constant.ConstantValue, input)); 496var tests = ArrayBuilder<Tests>.GetInstance(2); 503tests.Add(Tests.False.Instance); 507tests.Add(new Tests.One(new BoundDagValueTest(constant.Syntax, constant.ConstantValue, input))); 509return Tests.AndSequence.Create(tests); 513private Tests MakeTestsAndBindingsForRecursivePattern( 521var tests = ArrayBuilder<Tests>.GetInstance(5); 531tests.Add(new Tests.One(evaluation)); 561tests.Add(new Tests.One(evaluation)); 571tests.Add(new Tests.One(new BoundDagTypeTest(recursive.Syntax, ErrorType(), input, hasErrors: true))); 585tests.Add(new Tests.One(new BoundDagTypeTest(recursive.Syntax, ErrorType(), input, hasErrors: true))); 600return Tests.AndSequence.Create(tests); 627tests.Add(new Tests.One(evaluation)); 633private Tests MakeTestsAndBindingsForNegatedPattern(BoundDagTemp input, BoundNegatedPattern neg, ArrayBuilder<BoundPatternBinding> bindings) 635var tests = MakeTestsAndBindings(input, neg.Negated, bindings); 636return Tests.Not.Create(tests); 639private Tests MakeTestsAndBindingsForBinaryPattern( 645var builder = ArrayBuilder<Tests>.GetInstance(2); 650var result = Tests.OrSequence.Create(builder); 658builder = ArrayBuilder<Tests>.GetInstance(2); 661return Tests.AndSequence.Create(builder); 670return Tests.AndSequence.Create(builder); 674private Tests MakeTestsAndBindingsForRelationalPattern( 681var tests = ArrayBuilder<Tests>.GetInstance(2); 687tests.Add(Tests.False.Instance); 691tests.Add(new Tests.One(new BoundDagRelationalTest(rel.Syntax, rel.Relation, rel.ConstantValue, output, rel.HasErrors))); 694return Tests.AndSequence.Create(tests); 963RoslynDebug.Assert(!(first.RemainingTests is Tests.False)); 1030stateForCase.RemainingTests.Filter(this, test, state, whenTrueValues, whenFalseValues, out Tests whenTrueTests, out Tests whenFalseTests, ref foundExplicitNullTest); 1162var remainingTests = stateForCase.RemainingTests.RemoveEvaluation(e); 1163if (remainingTests is Tests.False) 1365out Tests relationCondition, 1366out Tests relationEffect) 1368relationCondition = Tests.True.Instance; 1369relationEffect = Tests.True.Instance; 1391ArrayBuilder<Tests>? conditions = null; 1405relationCondition = Tests.AndSequence.Create(conditions); 1409relationEffect = new Tests.One(new BoundDagAssignmentEvaluation(syntax, target: other.Input, input: test.Input)); 1453(conditions ??= ArrayBuilder<Tests>.GetInstance()).Add(new Tests.One(new BoundDagValueTest(syntax, ConstantValue.Create(lengthValue), s1LengthTemp))); 1833public readonly Tests RemainingTests; 1840Tests RemainingTests, 1856public bool IsFullyMatched => RemainingTests is Tests.True && (WhenClause is null || WhenClause.ConstantValueOpt == ConstantValue.True); 1861public bool PatternIsSatisfied => RemainingTests is Tests.True; 1867public bool IsImpossible => RemainingTests is Tests.False; 1889public StateForCase WithRemainingTests(Tests newRemainingTests) 1896/// <inheritdoc cref="Tests.RewriteNestedLengthTests"/> 1919out Tests whenTrue, 1920out Tests whenFalse, 1923public virtual Tests RemoveEvaluation(BoundDagEvaluation e) => this; 1927public virtual Tests RewriteNestedLengthTests() => this; 1943out Tests whenTrue, 1944out Tests whenFalse, 1964out Tests whenTrue, 1965out Tests whenFalse, 1988out Tests whenTrue, 1989out Tests whenFalse, 1996relationCondition: out Tests relationCondition, 1997relationEffect: out Tests relationEffect)) 2045static Tests rewrite(bool decisionImpliesTrueOther, bool decisionPermitsTrueOther, Tests relationCondition, Tests relationEffect, Tests other) 2055public override Tests RemoveEvaluation(BoundDagEvaluation e) => e.Equals(Test) ? Tests.True.Instance : (Tests)this; 2059public override Tests RewriteNestedLengthTests() 2098static Tests? knownResult(BinaryOperatorKind relation, ConstantValue constant, int offset) 2125public readonly Tests Negated; 2126private Not(Tests negated) => Negated = negated; 2127public static Tests Create(Tests negated) => negated switch 2129Tests.True _ => Tests.False.Instance, 2130Tests.False _ => Tests.True.Instance, 2131Tests.Not n => n.Negated, // double negative 2132Tests.AndSequence a => new Not(a), 2133Tests.OrSequence a => Tests.AndSequence.Create(NegateSequenceElements(a.RemainingTests)), // use demorgan to prefer and sequences 2134Tests.One o => new Not(o), 2137private static ArrayBuilder<Tests> NegateSequenceElements(ImmutableArray<Tests> seq) 2139var builder = ArrayBuilder<Tests>.GetInstance(seq.Length); 2140foreach (var t in seq) 2145public override Tests RemoveEvaluation(BoundDagEvaluation e) => Create(Negated.RemoveEvaluation(e)); 2146public override Tests RewriteNestedLengthTests() => Create(Negated.RewriteNestedLengthTests()); 2155out Tests whenTrue, 2156out Tests whenFalse, 2159Negated.Filter(builder, test, state, whenTrueValues, whenFalseValues, out var whenTestTrue, out var whenTestFalse, ref foundExplicitNullTest); 2169public readonly ImmutableArray<Tests> RemainingTests; 2170protected SequenceTests(ImmutableArray<Tests> remainingTests) 2175public abstract Tests Update(ArrayBuilder<Tests> remainingTests); 2182out Tests whenTrue, 2183out Tests whenFalse, 2186var trueBuilder = ArrayBuilder<Tests>.GetInstance(RemainingTests.Length); 2187var falseBuilder = ArrayBuilder<Tests>.GetInstance(RemainingTests.Length); 2188foreach (var other in RemainingTests) 2190other.Filter(builder, test, state, whenTrueValues, whenFalseValues, out Tests oneTrue, out Tests oneFalse, ref foundExplicitNullTest); 2198public sealed override Tests RemoveEvaluation(BoundDagEvaluation e) 2200var builder = ArrayBuilder<Tests>.GetInstance(RemainingTests.Length); 2201foreach (var test in RemainingTests) 2206public sealed override Tests RewriteNestedLengthTests() 2208var builder = ArrayBuilder<Tests>.GetInstance(RemainingTests.Length); 2209foreach (var test in RemainingTests) 2231private AndSequence(ImmutableArray<Tests> remainingTests) : base(remainingTests) { } 2232public override Tests Update(ArrayBuilder<Tests> remainingTests) => Create(remainingTests); 2233public static Tests Create(Tests t1, Tests t2) 2238var builder = ArrayBuilder<Tests>.GetInstance(2); 2243public static Tests Create(ArrayBuilder<Tests> remainingTests) 2263var result = remainingTests.Count switch 2310private OrSequence(ImmutableArray<Tests> remainingTests) : base(remainingTests) { } 2312public override Tests Update(ArrayBuilder<Tests> remainingTests) => Create(remainingTests); 2313public static Tests Create(Tests t1, Tests t2) 2318var builder = ArrayBuilder<Tests>.GetInstance(2); 2323public static Tests Create(ArrayBuilder<Tests> remainingTests) 2343var result = remainingTests.Count switch
Binder\DecisionDagBuilder_ListPatterns.cs (8)
13private Tests MakeTestsAndBindingsForListPattern(BoundDagTemp input, BoundListPattern list, out BoundDagTemp output, ArrayBuilder<BoundPatternBinding> bindings) 23var tests = ArrayBuilder<Tests>.GetInstance(4 + subpatterns.Length * 2); 28tests.Add(new Tests.One(new BoundDagTypeTest(list.Syntax, ErrorType(), input, hasErrors: true))); 42tests.Add(new Tests.One(lengthEvaluation)); 44tests.Add(new Tests.One(list.HasSlice 66tests.Add(new Tests.One(sliceEvaluation)); 81tests.Add(new Tests.One(indexEvaluation)); 92return Tests.AndSequence.Create(tests);