5 types derived from Tests
Microsoft.CodeAnalysis.CSharp (5)
Binder\DecisionDagBuilder.cs (5)
3376
public sealed class True :
Tests
3400
public sealed class False :
Tests
3426
public sealed class One :
Tests
4000
public sealed class Not :
Tests
4053
public abstract class SequenceTests :
Tests
248 references to Tests
Microsoft.CodeAnalysis.CSharp (248)
Binder\DecisionDagBuilder.cs (240)
199
Tests
tests = MakeAndSimplifyTestsAndBindings(input, pattern, out ImmutableArray<BoundPatternBinding> bindings);
203
private
Tests
MakeAndSimplifyTestsAndBindings(
209
Tests
tests = MakeTestsAndBindings(input, pattern, bindingsBuilder);
215
private static
Tests
SimplifyTestsAndBindings(
216
Tests
tests,
232
var testsToSimplify = ArrayBuilder<
Tests
?>.GetInstance();
233
var testsToAssemble = ArrayBuilder<
Tests
>.GetInstance();
234
var testsSimplified = ArrayBuilder<
Tests
>.GetInstance();
240
var
current = testsToSimplify.Pop();
244
case
Tests
.SequenceTests seq:
249
case
Tests
.True _:
250
case
Tests
.False _:
253
case
Tests
.One(BoundDagEvaluation e):
263
testsSimplified.Push(
Tests
.True.Instance);
266
case
Tests
.One(BoundDagTest d):
272
case
Tests
.Not n:
279
var
toAssemble = testsToAssemble.Pop();
282
case
Tests
.SequenceTests seq:
284
var newSequence = ArrayBuilder<
Tests
>.GetInstance(length);
293
case
Tests
.Not:
294
testsSimplified.Push(
Tests
.Not.Create(testsSimplified.Pop()));
307
var
result = testsSimplified.Pop();
322
private
Tests
MakeTestsAndBindings(
358
private
Tests
MakeTestsAndBindings(
381
return
Tests
.True.Instance;
412
private BoundDagTemp PrepareForUnionValuePropertyMatching(ref TestInputOutputInfo input, ArrayBuilder<
Tests
> tests)
418
tests.Add(new
Tests
.One(valueEvaluation));
490
private
Tests
MakeTestsAndBindingsForITuplePattern(
503
var tests = ArrayBuilder<
Tests
>.GetInstance(4 + patternLength * 2);
510
tests.Add(new
Tests
.One(lengthEvaluation));
512
tests.Add(new
Tests
.One(new BoundDagValueTest(syntax, ConstantValue.Create(patternLength), lengthTemp)));
518
tests.Add(new
Tests
.One(indexEvaluation));
523
return
Tests
.AndSequence.Create(tests);
577
private
Tests
MakeTestsAndBindingsForDeclarationPattern(
584
var tests = ArrayBuilder<
Tests
>.GetInstance(1);
603
return
Tests
.AndSequence.Create(tests);
606
private
Tests
MakeTestsForTypePattern(
612
var tests = ArrayBuilder<
Tests
>.GetInstance(4);
614
return
Tests
.AndSequence.Create(tests);
621
ArrayBuilder<
Tests
> tests)
628
tests.Add(new
Tests
.One(new BoundDagNonNullTest(syntax, isExplicitTest, input)));
742
private bool TryMakeTestsForUnionHasValue(SyntaxNode syntax, TestInputOutputInfo inputInfo, bool sense, [NotNullWhen(true)] out
Tests
? tests)
752
Tests
test = MakeConstantTest(syntax, temp, sense ? ConstantValue.True : ConstantValue.False);
753
Debug.Assert(test is
Tests
.One { Test: BoundDagValueTest });
755
tests =
Tests
.AndSequence.Create(new
Tests
.One(hasValueEvaluation), test);
776
ArrayBuilder<
Tests
> tests)
781
TryMakeTestsForUnionHasValue(syntax, inputInfo, sense: true, out
var
hasValueTests))
792
tests.Add(new
Tests
.One(deconstructEvaluation));
797
Tests
test = MakeConstantTest(syntax, boolResult, ConstantValue.True);
798
Debug.Assert(test is
Tests
.One { Test: var tryGetValueResultTest } && IsUnionTryGetValueTest(tryGetValueResultTest, out _, out _, out _));
808
tests.Add(new
Tests
.One(typeEvaluation));
813
tests.Add(new
Tests
.One(new BoundDagTypeTest(syntax, type, typeEvaluationTemp)));
815
tests.Add(new
Tests
.One(typeEvaluation));
847
tests.Add(new
Tests
.One(new BoundDagTypeTest(syntax, type, input)));
852
tests.Add(new
Tests
.One(evaluation));
858
private
Tests
MakeTestsForConstantPattern(
865
if (TryMakeTestsForUnionHasValue(constant.Syntax, inputInfo, sense: false, out
var
tests))
871
var builder = ArrayBuilder<
Tests
>.GetInstance(2);
874
builder.Add(new
Tests
.One(new BoundDagExplicitNullTest(constant.Syntax, input)));
875
return
Tests
.AndSequence.Create(builder);
882
Tests
makeTestsForNonNullConstantPattern(TestInputOutputInfo inputInfo, BoundConstantPattern constant, out TestInputOutputInfo output)
887
var tests = ArrayBuilder<
Tests
>.GetInstance(2);
890
tests.Add(new
Tests
.One(new BoundDagValueTest(constant.Syntax, constantValue, input)));
891
return
Tests
.AndSequence.Create(tests);
895
var tests = ArrayBuilder<
Tests
>.GetInstance(2);
905
return
Tests
.AndSequence.Create(tests);
910
private static
Tests
MakeConstantTest(SyntaxNode syntax, BoundDagTemp input, ConstantValue constantValue)
916
return
Tests
.False.Instance;
920
return new
Tests
.One(new BoundDagValueTest(syntax, constantValue, input));
924
private
Tests
MakeTestsAndBindingsForRecursivePattern(
933
var tests = ArrayBuilder<
Tests
>.GetInstance(5);
944
tests.Add(new
Tests
.One(evaluation));
975
tests.Add(new
Tests
.One(evaluation));
986
tests.Add(new
Tests
.One(new BoundDagTypeTest(recursive.Syntax, ErrorType(), input, hasErrors: true)));
1034
return
Tests
.AndSequence.Create(tests);
1060
tests.Add(new
Tests
.One(new BoundDagTypeTest(subpattern.Syntax, ErrorType(), input, hasErrors: true)));
1088
tests.Add(new
Tests
.One(new BoundDagTypeTest(subpattern.Syntax, ErrorType(), input, hasErrors: true)));
1092
tests.Add(new
Tests
.One(evaluation));
1097
private
Tests
MakeTestsAndBindingsForNegatedPattern(TestInputOutputInfo input, BoundNegatedPattern neg, ArrayBuilder<BoundPatternBinding> bindings)
1099
var
tests = MakeTestsAndBindings(input, neg.Negated, output: out _, bindings);
1100
return
Tests
.Not.Create(tests);
1103
private
Tests
MakeTestsAndBindingsForBinaryPattern(
1121
Tests
result = MakeTestsAndBindings(inputInfo, currentNode.Left, out outputInfo, bindings);
1132
Tests
makeTestsAndBindingsForBinaryPattern(DecisionDagBuilder @this,
Tests
leftTests, TestInputOutputInfo leftOutputInfo, TestInputOutputInfo inputInfo, BoundBinaryPattern bin, out TestInputOutputInfo outputInfo, ArrayBuilder<BoundPatternBinding> bindings)
1134
var builder = ArrayBuilder<
Tests
>.GetInstance(2);
1139
var
result =
Tests
.OrSequence.Create(builder);
1147
builder = ArrayBuilder<
Tests
>.GetInstance(2);
1153
builder.Add(new
Tests
.One(evaluation));
1154
return
Tests
.AndSequence.Create(builder);
1166
return
Tests
.AndSequence.Create(builder);
1171
private
Tests
MakeTestsAndBindingsForRelationalPattern(
1179
var tests = ArrayBuilder<
Tests
>.GetInstance(2);
1186
tests.Add(
Tests
.False.Instance);
1190
tests.Add(new
Tests
.One(new BoundDagRelationalTest(rel.Syntax, rel.Relation, rel.ConstantValue, output, rel.HasErrors)));
1193
return
Tests
.AndSequence.Create(tests);
1638
RoslynDebug.Assert(!(first.RemainingTests is
Tests
.False));
1705
stateForCase.RemainingTests.Filter(this, test, state, whenTrueValues, whenFalseValues, out
Tests
whenTrueTests, out
Tests
whenFalseTests, ref foundExplicitNullTest);
1920
var
remainingTests = stateForCase.RemainingTests.RemoveEvaluation(this, state, stateForCase.Bindings, e);
1921
if (remainingTests is
Tests
.False)
3159
public readonly
Tests
RemainingTests;
3166
Tests
RemainingTests,
3182
public bool IsFullyMatched => RemainingTests is
Tests
.True && (WhenClause is null || WhenClause.ConstantValueOpt == ConstantValue.True);
3187
public bool PatternIsSatisfied => RemainingTests is
Tests
.True;
3193
public bool IsImpossible => RemainingTests is
Tests
.False;
3213
public StateForCase WithRemainingTests(
Tests
newRemainingTests)
3220
/// <inheritdoc cref="
Tests
.RewriteNestedLengthTests"/>
3243
out
Tests
whenTrue,
3244
out
Tests
whenFalse,
3253
public readonly
Tests
FinalResult;
3259
public readonly
Tests
? ConditionToUseFinalResult;
3260
public readonly
Tests
? TempsUpdatedResult;
3263
Tests
finalResult,
3265
Tests
? conditionToUseFinalResult,
3266
Tests
? tempsUpdatedResult)
3279
public
Tests
RemoveEvaluation(DecisionDagBuilder dagBuilder, DagState state, ImmutableArray<BoundPatternBinding> bindings, BoundDagEvaluation e)
3284
protected
Tests
RemoveEvaluationAndUpdateTempReferences(DecisionDagBuilder dagBuilder, DagState state, ImmutableArray<BoundPatternBinding> bindings, ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagEvaluation e)
3293
var finalResult = ArrayBuilder<
Tests
>.GetInstance(2);
3330
private static void AddBindingsPatchingAssignments(ImmutableArray<BoundPatternBinding> bindings, ImmutableDictionary<BoundDagTemp, BoundDagTemp> oldTempMap, ImmutableDictionary<BoundDagTemp, BoundDagTemp> newTempMap, ArrayBuilder<
Tests
> assignments)
3345
assignments.Add(new
Tests
.One(new BoundDagAssignmentEvaluation(useValueFrom.Syntax, b.TempContainingValue, useValueFrom)));
3370
public virtual
Tests
RewriteNestedLengthTests() => this;
3386
out
Tests
whenTrue,
3387
out
Tests
whenFalse,
3410
out
Tests
whenTrue,
3411
out
Tests
whenFalse,
3437
out
Tests
whenTrue,
3438
out
Tests
whenFalse,
3491
void split(bool trueDecisionPermitsTrueOther, bool falseDecisionPermitsTrueOther, bool trueDecisionImpliesTrueOther, bool falseDecisionImpliesTrueOther, out
Tests
whenTrue, out
Tests
whenFalse)
3493
whenTrue = trueDecisionImpliesTrueOther ?
Tests
.True.Instance : trueDecisionPermitsTrueOther ? this : (
Tests
)
Tests
.False.Instance;
3494
whenFalse = falseDecisionImpliesTrueOther ?
Tests
.True.Instance : falseDecisionPermitsTrueOther ? this : (
Tests
)
Tests
.False.Instance;
3502
public override
Tests
RewriteNestedLengthTests()
3541
static
Tests
? knownResult(BinaryOperatorKind relation, ConstantValue constant, int offset)
3575
return new RemoveEvaluationAndUpdateTempReferencesResult(
Tests
.True.Instance, tempMap, conditionToUseFinalResult: null, tempsUpdatedResult: null);
3585
return new RemoveEvaluationAndUpdateTempReferencesResult(
Tests
.True.Instance, tempMap, conditionToUseFinalResult: null, tempsUpdatedResult: null);
3600
Tests
finalResult = RemoveEvaluation(tempsUpdatedResult, builder, state, ref tempMap, e, out
var
condition);
3638
public static
Tests
RemoveEvaluation(One tests, DecisionDagBuilder builder, DagState state, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagEvaluation e, out
Tests
? condition)
3689
private static
Tests
RemoveAssignmentEvaluation(One tests, BoundDagAssignmentEvaluation e1)
3693
return
Tests
.True.Instance;
3699
private static
Tests
RemoveSimpleEvaluationWithResultTemp(One tests, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagEvaluation e1)
3705
return
Tests
.True.Instance;
3733
private static
Tests
RemoveDeconstructEvaluation(One tests, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagDeconstructEvaluation e1)
3739
return
Tests
.True.Instance;
3757
private static
Tests
RemoveTypeEvaluation(One tests, DecisionDagBuilder dagBuilder, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagTypeEvaluation e1)
3767
return
Tests
.True.Instance;
3799
static
Tests
? replaceUnionTypeEvaluation(DecisionDagBuilder dagBuilder, BoundDagTypeEvaluation e1, BoundDagTypeEvaluation typeEval)
3824
return AndSequence.Create(new
Tests
.One(newTypeEval), new
Tests
.One(new BoundDagPassThroughEvaluation(typeEval.Syntax, newTemp)));
3834
private static
Tests
RemoveIndexerEvaluation(One tests, DecisionDagBuilder dagBuilder, DagState state, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagIndexerEvaluation s1, out
Tests
? condition)
3854
return
Tests
.True.Instance;
3872
return
Tests
.True.Instance;
3880
condition = new
Tests
.One(new BoundDagValueTest(s2.Syntax, ConstantValue.Create(lengthValue), s1LengthTemp));
3882
return
Tests
.True.Instance;
4003
public readonly
Tests
Negated;
4004
private Not(
Tests
negated) => Negated = negated;
4005
public static
Tests
Create(
Tests
negated) => negated switch
4007
Tests
.True _ =>
Tests
.False.Instance,
4008
Tests
.False _ =>
Tests
.True.Instance,
4009
Tests
.Not n => n.Negated, // double negative
4010
Tests
.AndSequence a => new Not(a),
4011
Tests
.OrSequence a =>
Tests
.AndSequence.Create(NegateSequenceElements(a.RemainingTests)), // use demorgan to prefer and sequences
4012
Tests
.One o => new Not(o),
4015
private static ArrayBuilder<
Tests
> NegateSequenceElements(ImmutableArray<
Tests
> seq)
4017
var builder = ArrayBuilder<
Tests
>.GetInstance(seq.Length);
4018
foreach (
var
t in seq)
4032
public override
Tests
RewriteNestedLengthTests() => Create(Negated.RewriteNestedLengthTests());
4041
out
Tests
whenTrue,
4042
out
Tests
whenFalse,
4045
Negated.Filter(builder, test, state, whenTrueValues, whenFalseValues, out
var
whenTestTrue, out
var
whenTestFalse, ref foundExplicitNullTest);
4055
public readonly ImmutableArray<
Tests
> RemainingTests;
4056
protected SequenceTests(ImmutableArray<
Tests
> remainingTests)
4061
public abstract
Tests
Update(ArrayBuilder<
Tests
> remainingTests);
4068
out
Tests
whenTrue,
4069
out
Tests
whenFalse,
4072
var testsToFilter = ArrayBuilder<
Tests
?>.GetInstance();
4074
var trueTests = ArrayBuilder<
Tests
>.GetInstance();
4075
var falseTests = ArrayBuilder<
Tests
>.GetInstance();
4081
var
current = testsToFilter.Pop();
4103
current.Filter(builder, test, state, whenTrueValues, whenFalseValues, out
Tests
oneTrue, out
Tests
oneFalse, ref foundExplicitNullTest);
4125
static void assemble(SequenceTests toAssemble, ArrayBuilder<
Tests
> tests)
4128
var newSequence = ArrayBuilder<
Tests
>.GetInstance(length, null!);
4146
var testsToRewrite = ArrayBuilder<(
Tests
? Tests, bool SkipRewrite)>.GetInstance();
4152
var testsRewritten = ArrayBuilder<
Tests
>.GetInstance();
4163
ImmutableArray<
Tests
> remainingTests = seq.RemainingTests;
4177
var newSequence = ArrayBuilder<
Tests
>.GetInstance(childCount);
4231
var
result = testsRewritten.Pop();
4260
var leftToRewriteBuilder = ArrayBuilder<
Tests
>.GetInstance();
4287
void pushConditionalResult(RemoveEvaluationAndUpdateTempReferencesResult rewriteResult, ArrayBuilder<
Tests
> leftToRewriteBuilder)
4351
void popAndAddChildrenLeftToRewrite(ArrayBuilder<
Tests
> leftToRewriteBuilder)
4369
public sealed override
Tests
RewriteNestedLengthTests()
4371
var testsToRewrite = ArrayBuilder<
Tests
?>.GetInstance();
4373
var testsRewritten = ArrayBuilder<
Tests
>.GetInstance();
4379
var
current = testsToRewrite.Pop();
4392
var newSequence = ArrayBuilder<
Tests
>.GetInstance(length);
4408
var
result = testsRewritten.Pop();
4432
var tests1 = ArrayBuilder<
Tests
>.GetInstance();
4433
var tests2 = ArrayBuilder<
Tests
>.GetInstance();
4440
var
t1 = tests1.Pop();
4441
var
t2 = tests2.Pop();
4512
var tests = ArrayBuilder<
Tests
>.GetInstance();
4517
var
t = tests.Pop();
4558
Tests
firstTest;
4590
private AndSequence(ImmutableArray<
Tests
> remainingTests) : base(remainingTests)
4594
public override
Tests
Update(ArrayBuilder<
Tests
> remainingTests) => Create(remainingTests);
4595
public static
Tests
Create(
Tests
t1,
Tests
t2)
4600
var builder = ArrayBuilder<
Tests
>.GetInstance(2);
4605
public static
Tests
Create(ArrayBuilder<
Tests
> remainingTests)
4625
var
result = remainingTests.Count switch
4696
private OrSequence(ImmutableArray<
Tests
> remainingTests) : base(remainingTests)
4700
public override
Tests
Update(ArrayBuilder<
Tests
> remainingTests) => Create(remainingTests);
4701
public static
Tests
Create(
Tests
t1,
Tests
t2)
4706
var builder = ArrayBuilder<
Tests
>.GetInstance(2);
4711
public static
Tests
Create(ArrayBuilder<
Tests
> remainingTests)
4731
var
result = remainingTests.Count switch
Binder\DecisionDagBuilder_ListPatterns.cs (8)
14
private
Tests
MakeTestsAndBindingsForListPattern(TestInputOutputInfo inputInfo, BoundListPattern list, out TestInputOutputInfo outputInfo, ArrayBuilder<BoundPatternBinding> bindings)
26
var tests = ArrayBuilder<
Tests
>.GetInstance(4 + subpatterns.Length * 2);
32
tests.Add(new
Tests
.One(new BoundDagTypeTest(list.Syntax, ErrorType(), input, hasErrors: true)));
47
tests.Add(new
Tests
.One(lengthEvaluation));
49
tests.Add(new
Tests
.One(list.HasSlice
71
tests.Add(new
Tests
.One(sliceEvaluation));
86
tests.Add(new
Tests
.One(indexEvaluation));
99
return
Tests
.AndSequence.Create(tests);