5 types derived from Tests
Microsoft.CodeAnalysis.CSharp (5)
Binder\DecisionDagBuilder.cs (5)
3329
public sealed class True :
Tests
3353
public sealed class False :
Tests
3379
public sealed class One :
Tests
3953
public sealed class Not :
Tests
4006
public abstract class SequenceTests :
Tests
245 references to Tests
Microsoft.CodeAnalysis.CSharp (245)
Binder\DecisionDagBuilder.cs (237)
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)));
748
private bool TryMakeTestsForUnionHasValue(SyntaxNode syntax, TestInputOutputInfo inputInfo, bool sense, [NotNullWhen(true)] out
Tests
? tests)
758
Tests
test = MakeConstantTest(syntax, temp, sense ? ConstantValue.True : ConstantValue.False);
759
Debug.Assert(test is
Tests
.One { Test: BoundDagValueTest });
761
tests =
Tests
.AndSequence.Create(new
Tests
.One(hasValueEvaluation), test);
782
ArrayBuilder<
Tests
> tests)
787
TryMakeTestsForUnionHasValue(syntax, inputInfo, sense: true, out
var
hasValueTests))
798
tests.Add(new
Tests
.One(deconstructEvaluation));
803
Tests
test = MakeConstantTest(syntax, boolResult, ConstantValue.True);
804
Debug.Assert(test is
Tests
.One { Test: var tryGetValueResultTest } && IsUnionTryGetValueTest(tryGetValueResultTest, out _, out _, out _));
814
tests.Add(new
Tests
.One(typeEvaluation));
844
tests.Add(new
Tests
.One(new BoundDagTypeTest(syntax, type, input)));
849
tests.Add(new
Tests
.One(evaluation));
855
private
Tests
MakeTestsForConstantPattern(
862
if (TryMakeTestsForUnionHasValue(constant.Syntax, inputInfo, sense: false, out
var
tests))
868
var builder = ArrayBuilder<
Tests
>.GetInstance(2);
871
builder.Add(new
Tests
.One(new BoundDagExplicitNullTest(constant.Syntax, input)));
872
return
Tests
.AndSequence.Create(builder);
879
Tests
makeTestsForNonNullConstantPattern(TestInputOutputInfo inputInfo, BoundConstantPattern constant, out TestInputOutputInfo output)
884
var tests = ArrayBuilder<
Tests
>.GetInstance(2);
887
tests.Add(new
Tests
.One(new BoundDagValueTest(constant.Syntax, constantValue, input)));
888
return
Tests
.AndSequence.Create(tests);
892
var tests = ArrayBuilder<
Tests
>.GetInstance(2);
902
return
Tests
.AndSequence.Create(tests);
907
private static
Tests
MakeConstantTest(SyntaxNode syntax, BoundDagTemp input, ConstantValue constantValue)
913
return
Tests
.False.Instance;
917
return new
Tests
.One(new BoundDagValueTest(syntax, constantValue, input));
921
private
Tests
MakeTestsAndBindingsForRecursivePattern(
930
var tests = ArrayBuilder<
Tests
>.GetInstance(5);
941
tests.Add(new
Tests
.One(evaluation));
972
tests.Add(new
Tests
.One(evaluation));
983
tests.Add(new
Tests
.One(new BoundDagTypeTest(recursive.Syntax, ErrorType(), input, hasErrors: true)));
1013
tests.Add(new
Tests
.One(new BoundDagTypeTest(recursive.Syntax, ErrorType(), input, hasErrors: true)));
1031
return
Tests
.AndSequence.Create(tests);
1066
tests.Add(new
Tests
.One(evaluation));
1071
private
Tests
MakeTestsAndBindingsForNegatedPattern(TestInputOutputInfo input, BoundNegatedPattern neg, ArrayBuilder<BoundPatternBinding> bindings)
1073
var
tests = MakeTestsAndBindings(input, neg.Negated, output: out _, bindings);
1074
return
Tests
.Not.Create(tests);
1077
private
Tests
MakeTestsAndBindingsForBinaryPattern(
1095
Tests
result = MakeTestsAndBindings(inputInfo, currentNode.Left, out outputInfo, bindings);
1106
Tests
makeTestsAndBindingsForBinaryPattern(DecisionDagBuilder @this,
Tests
leftTests, TestInputOutputInfo leftOutputInfo, TestInputOutputInfo inputInfo, BoundBinaryPattern bin, out TestInputOutputInfo outputInfo, ArrayBuilder<BoundPatternBinding> bindings)
1108
var builder = ArrayBuilder<
Tests
>.GetInstance(2);
1113
var
result =
Tests
.OrSequence.Create(builder);
1121
builder = ArrayBuilder<
Tests
>.GetInstance(2);
1128
builder.Add(new
Tests
.One(evaluation));
1129
return
Tests
.AndSequence.Create(builder);
1141
return
Tests
.AndSequence.Create(builder);
1146
private
Tests
MakeTestsAndBindingsForRelationalPattern(
1154
var tests = ArrayBuilder<
Tests
>.GetInstance(2);
1161
tests.Add(
Tests
.False.Instance);
1165
tests.Add(new
Tests
.One(new BoundDagRelationalTest(rel.Syntax, rel.Relation, rel.ConstantValue, output, rel.HasErrors)));
1168
return
Tests
.AndSequence.Create(tests);
1613
RoslynDebug.Assert(!(first.RemainingTests is
Tests
.False));
1680
stateForCase.RemainingTests.Filter(this, test, state, whenTrueValues, whenFalseValues, out
Tests
whenTrueTests, out
Tests
whenFalseTests, ref foundExplicitNullTest);
1895
var
remainingTests = stateForCase.RemainingTests.RemoveEvaluation(this, state, stateForCase.Bindings, e);
1896
if (remainingTests is
Tests
.False)
3112
public readonly
Tests
RemainingTests;
3119
Tests
RemainingTests,
3135
public bool IsFullyMatched => RemainingTests is
Tests
.True && (WhenClause is null || WhenClause.ConstantValueOpt == ConstantValue.True);
3140
public bool PatternIsSatisfied => RemainingTests is
Tests
.True;
3146
public bool IsImpossible => RemainingTests is
Tests
.False;
3166
public StateForCase WithRemainingTests(
Tests
newRemainingTests)
3173
/// <inheritdoc cref="
Tests
.RewriteNestedLengthTests"/>
3196
out
Tests
whenTrue,
3197
out
Tests
whenFalse,
3206
public readonly
Tests
FinalResult;
3212
public readonly
Tests
? ConditionToUseFinalResult;
3213
public readonly
Tests
? TempsUpdatedResult;
3216
Tests
finalResult,
3218
Tests
? conditionToUseFinalResult,
3219
Tests
? tempsUpdatedResult)
3232
public
Tests
RemoveEvaluation(DecisionDagBuilder dagBuilder, DagState state, ImmutableArray<BoundPatternBinding> bindings, BoundDagEvaluation e)
3237
protected
Tests
RemoveEvaluationAndUpdateTempReferences(DecisionDagBuilder dagBuilder, DagState state, ImmutableArray<BoundPatternBinding> bindings, ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagEvaluation e)
3246
var finalResult = ArrayBuilder<
Tests
>.GetInstance(2);
3283
private static void AddBindingsPatchingAssignments(ImmutableArray<BoundPatternBinding> bindings, ImmutableDictionary<BoundDagTemp, BoundDagTemp> oldTempMap, ImmutableDictionary<BoundDagTemp, BoundDagTemp> newTempMap, ArrayBuilder<
Tests
> assignments)
3298
assignments.Add(new
Tests
.One(new BoundDagAssignmentEvaluation(useValueFrom.Syntax, b.TempContainingValue, useValueFrom)));
3323
public virtual
Tests
RewriteNestedLengthTests() => this;
3339
out
Tests
whenTrue,
3340
out
Tests
whenFalse,
3363
out
Tests
whenTrue,
3364
out
Tests
whenFalse,
3390
out
Tests
whenTrue,
3391
out
Tests
whenFalse,
3444
void split(bool trueDecisionPermitsTrueOther, bool falseDecisionPermitsTrueOther, bool trueDecisionImpliesTrueOther, bool falseDecisionImpliesTrueOther, out
Tests
whenTrue, out
Tests
whenFalse)
3446
whenTrue = trueDecisionImpliesTrueOther ?
Tests
.True.Instance : trueDecisionPermitsTrueOther ? this : (
Tests
)
Tests
.False.Instance;
3447
whenFalse = falseDecisionImpliesTrueOther ?
Tests
.True.Instance : falseDecisionPermitsTrueOther ? this : (
Tests
)
Tests
.False.Instance;
3455
public override
Tests
RewriteNestedLengthTests()
3494
static
Tests
? knownResult(BinaryOperatorKind relation, ConstantValue constant, int offset)
3528
return new RemoveEvaluationAndUpdateTempReferencesResult(
Tests
.True.Instance, tempMap, conditionToUseFinalResult: null, tempsUpdatedResult: null);
3538
return new RemoveEvaluationAndUpdateTempReferencesResult(
Tests
.True.Instance, tempMap, conditionToUseFinalResult: null, tempsUpdatedResult: null);
3553
Tests
finalResult = RemoveEvaluation(tempsUpdatedResult, builder, state, ref tempMap, e, out
var
condition);
3591
public static
Tests
RemoveEvaluation(One tests, DecisionDagBuilder builder, DagState state, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagEvaluation e, out
Tests
? condition)
3642
private static
Tests
RemoveAssignmentEvaluation(One tests, BoundDagAssignmentEvaluation e1)
3646
return
Tests
.True.Instance;
3652
private static
Tests
RemoveSimpleEvaluationWithResultTemp(One tests, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagEvaluation e1)
3658
return
Tests
.True.Instance;
3686
private static
Tests
RemoveDeconstructEvaluation(One tests, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagDeconstructEvaluation e1)
3692
return
Tests
.True.Instance;
3710
private static
Tests
RemoveTypeEvaluation(One tests, DecisionDagBuilder dagBuilder, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagTypeEvaluation e1)
3720
return
Tests
.True.Instance;
3752
static
Tests
? replaceUnionTypeEvaluation(DecisionDagBuilder dagBuilder, BoundDagTypeEvaluation e1, BoundDagTypeEvaluation typeEval)
3777
return AndSequence.Create(new
Tests
.One(newTypeEval), new
Tests
.One(new BoundDagPassThroughEvaluation(typeEval.Syntax, newTemp)));
3787
private static
Tests
RemoveIndexerEvaluation(One tests, DecisionDagBuilder dagBuilder, DagState state, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagIndexerEvaluation s1, out
Tests
? condition)
3807
return
Tests
.True.Instance;
3825
return
Tests
.True.Instance;
3833
condition = new
Tests
.One(new BoundDagValueTest(s2.Syntax, ConstantValue.Create(lengthValue), s1LengthTemp));
3835
return
Tests
.True.Instance;
3956
public readonly
Tests
Negated;
3957
private Not(
Tests
negated) => Negated = negated;
3958
public static
Tests
Create(
Tests
negated) => negated switch
3960
Tests
.True _ =>
Tests
.False.Instance,
3961
Tests
.False _ =>
Tests
.True.Instance,
3962
Tests
.Not n => n.Negated, // double negative
3963
Tests
.AndSequence a => new Not(a),
3964
Tests
.OrSequence a =>
Tests
.AndSequence.Create(NegateSequenceElements(a.RemainingTests)), // use demorgan to prefer and sequences
3965
Tests
.One o => new Not(o),
3968
private static ArrayBuilder<
Tests
> NegateSequenceElements(ImmutableArray<
Tests
> seq)
3970
var builder = ArrayBuilder<
Tests
>.GetInstance(seq.Length);
3971
foreach (
var
t in seq)
3985
public override
Tests
RewriteNestedLengthTests() => Create(Negated.RewriteNestedLengthTests());
3994
out
Tests
whenTrue,
3995
out
Tests
whenFalse,
3998
Negated.Filter(builder, test, state, whenTrueValues, whenFalseValues, out
var
whenTestTrue, out
var
whenTestFalse, ref foundExplicitNullTest);
4008
public readonly ImmutableArray<
Tests
> RemainingTests;
4009
protected SequenceTests(ImmutableArray<
Tests
> remainingTests)
4014
public abstract
Tests
Update(ArrayBuilder<
Tests
> remainingTests);
4021
out
Tests
whenTrue,
4022
out
Tests
whenFalse,
4025
var testsToFilter = ArrayBuilder<
Tests
?>.GetInstance();
4027
var trueTests = ArrayBuilder<
Tests
>.GetInstance();
4028
var falseTests = ArrayBuilder<
Tests
>.GetInstance();
4034
var
current = testsToFilter.Pop();
4056
current.Filter(builder, test, state, whenTrueValues, whenFalseValues, out
Tests
oneTrue, out
Tests
oneFalse, ref foundExplicitNullTest);
4078
static void assemble(SequenceTests toAssemble, ArrayBuilder<
Tests
> tests)
4081
var newSequence = ArrayBuilder<
Tests
>.GetInstance(length, null!);
4099
var testsToRewrite = ArrayBuilder<(
Tests
? Tests, bool SkipRewrite)>.GetInstance();
4105
var testsRewritten = ArrayBuilder<
Tests
>.GetInstance();
4116
ImmutableArray<
Tests
> remainingTests = seq.RemainingTests;
4130
var newSequence = ArrayBuilder<
Tests
>.GetInstance(childCount);
4184
var
result = testsRewritten.Pop();
4213
var leftToRewriteBuilder = ArrayBuilder<
Tests
>.GetInstance();
4240
void pushConditionalResult(RemoveEvaluationAndUpdateTempReferencesResult rewriteResult, ArrayBuilder<
Tests
> leftToRewriteBuilder)
4304
void popAndAddChildrenLeftToRewrite(ArrayBuilder<
Tests
> leftToRewriteBuilder)
4322
public sealed override
Tests
RewriteNestedLengthTests()
4324
var testsToRewrite = ArrayBuilder<
Tests
?>.GetInstance();
4326
var testsRewritten = ArrayBuilder<
Tests
>.GetInstance();
4332
var
current = testsToRewrite.Pop();
4345
var newSequence = ArrayBuilder<
Tests
>.GetInstance(length);
4361
var
result = testsRewritten.Pop();
4385
var tests1 = ArrayBuilder<
Tests
>.GetInstance();
4386
var tests2 = ArrayBuilder<
Tests
>.GetInstance();
4393
var
t1 = tests1.Pop();
4394
var
t2 = tests2.Pop();
4461
var tests = ArrayBuilder<
Tests
>.GetInstance();
4466
var
t = tests.Pop();
4507
Tests
firstTest;
4539
private AndSequence(ImmutableArray<
Tests
> remainingTests) : base(remainingTests)
4543
public override
Tests
Update(ArrayBuilder<
Tests
> remainingTests) => Create(remainingTests);
4544
public static
Tests
Create(
Tests
t1,
Tests
t2)
4549
var builder = ArrayBuilder<
Tests
>.GetInstance(2);
4554
public static
Tests
Create(ArrayBuilder<
Tests
> remainingTests)
4574
var
result = remainingTests.Count switch
4645
private OrSequence(ImmutableArray<
Tests
> remainingTests) : base(remainingTests)
4649
public override
Tests
Update(ArrayBuilder<
Tests
> remainingTests) => Create(remainingTests);
4650
public static
Tests
Create(
Tests
t1,
Tests
t2)
4655
var builder = ArrayBuilder<
Tests
>.GetInstance(2);
4660
public static
Tests
Create(ArrayBuilder<
Tests
> remainingTests)
4680
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);