5 types derived from Tests
Microsoft.CodeAnalysis.CSharp (5)
Binder\DecisionDagBuilder.cs (5)
3356
public sealed class True :
Tests
3380
public sealed class False :
Tests
3406
public sealed class One :
Tests
3980
public sealed class Not :
Tests
4033
public abstract class SequenceTests :
Tests
247 references to Tests
Microsoft.CodeAnalysis.CSharp (247)
Binder\DecisionDagBuilder.cs (239)
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)));
1019
tests.Add(new
Tests
.One(new BoundDagTypeTest(recursive.Syntax, ErrorType(), input, hasErrors: true)));
1037
return
Tests
.AndSequence.Create(tests);
1072
tests.Add(new
Tests
.One(evaluation));
1077
private
Tests
MakeTestsAndBindingsForNegatedPattern(TestInputOutputInfo input, BoundNegatedPattern neg, ArrayBuilder<BoundPatternBinding> bindings)
1079
var
tests = MakeTestsAndBindings(input, neg.Negated, output: out _, bindings);
1080
return
Tests
.Not.Create(tests);
1083
private
Tests
MakeTestsAndBindingsForBinaryPattern(
1101
Tests
result = MakeTestsAndBindings(inputInfo, currentNode.Left, out outputInfo, bindings);
1112
Tests
makeTestsAndBindingsForBinaryPattern(DecisionDagBuilder @this,
Tests
leftTests, TestInputOutputInfo leftOutputInfo, TestInputOutputInfo inputInfo, BoundBinaryPattern bin, out TestInputOutputInfo outputInfo, ArrayBuilder<BoundPatternBinding> bindings)
1114
var builder = ArrayBuilder<
Tests
>.GetInstance(2);
1119
var
result =
Tests
.OrSequence.Create(builder);
1127
builder = ArrayBuilder<
Tests
>.GetInstance(2);
1133
builder.Add(new
Tests
.One(evaluation));
1134
return
Tests
.AndSequence.Create(builder);
1146
return
Tests
.AndSequence.Create(builder);
1151
private
Tests
MakeTestsAndBindingsForRelationalPattern(
1159
var tests = ArrayBuilder<
Tests
>.GetInstance(2);
1166
tests.Add(
Tests
.False.Instance);
1170
tests.Add(new
Tests
.One(new BoundDagRelationalTest(rel.Syntax, rel.Relation, rel.ConstantValue, output, rel.HasErrors)));
1173
return
Tests
.AndSequence.Create(tests);
1618
RoslynDebug.Assert(!(first.RemainingTests is
Tests
.False));
1685
stateForCase.RemainingTests.Filter(this, test, state, whenTrueValues, whenFalseValues, out
Tests
whenTrueTests, out
Tests
whenFalseTests, ref foundExplicitNullTest);
1900
var
remainingTests = stateForCase.RemainingTests.RemoveEvaluation(this, state, stateForCase.Bindings, e);
1901
if (remainingTests is
Tests
.False)
3139
public readonly
Tests
RemainingTests;
3146
Tests
RemainingTests,
3162
public bool IsFullyMatched => RemainingTests is
Tests
.True && (WhenClause is null || WhenClause.ConstantValueOpt == ConstantValue.True);
3167
public bool PatternIsSatisfied => RemainingTests is
Tests
.True;
3173
public bool IsImpossible => RemainingTests is
Tests
.False;
3193
public StateForCase WithRemainingTests(
Tests
newRemainingTests)
3200
/// <inheritdoc cref="
Tests
.RewriteNestedLengthTests"/>
3223
out
Tests
whenTrue,
3224
out
Tests
whenFalse,
3233
public readonly
Tests
FinalResult;
3239
public readonly
Tests
? ConditionToUseFinalResult;
3240
public readonly
Tests
? TempsUpdatedResult;
3243
Tests
finalResult,
3245
Tests
? conditionToUseFinalResult,
3246
Tests
? tempsUpdatedResult)
3259
public
Tests
RemoveEvaluation(DecisionDagBuilder dagBuilder, DagState state, ImmutableArray<BoundPatternBinding> bindings, BoundDagEvaluation e)
3264
protected
Tests
RemoveEvaluationAndUpdateTempReferences(DecisionDagBuilder dagBuilder, DagState state, ImmutableArray<BoundPatternBinding> bindings, ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagEvaluation e)
3273
var finalResult = ArrayBuilder<
Tests
>.GetInstance(2);
3310
private static void AddBindingsPatchingAssignments(ImmutableArray<BoundPatternBinding> bindings, ImmutableDictionary<BoundDagTemp, BoundDagTemp> oldTempMap, ImmutableDictionary<BoundDagTemp, BoundDagTemp> newTempMap, ArrayBuilder<
Tests
> assignments)
3325
assignments.Add(new
Tests
.One(new BoundDagAssignmentEvaluation(useValueFrom.Syntax, b.TempContainingValue, useValueFrom)));
3350
public virtual
Tests
RewriteNestedLengthTests() => this;
3366
out
Tests
whenTrue,
3367
out
Tests
whenFalse,
3390
out
Tests
whenTrue,
3391
out
Tests
whenFalse,
3417
out
Tests
whenTrue,
3418
out
Tests
whenFalse,
3471
void split(bool trueDecisionPermitsTrueOther, bool falseDecisionPermitsTrueOther, bool trueDecisionImpliesTrueOther, bool falseDecisionImpliesTrueOther, out
Tests
whenTrue, out
Tests
whenFalse)
3473
whenTrue = trueDecisionImpliesTrueOther ?
Tests
.True.Instance : trueDecisionPermitsTrueOther ? this : (
Tests
)
Tests
.False.Instance;
3474
whenFalse = falseDecisionImpliesTrueOther ?
Tests
.True.Instance : falseDecisionPermitsTrueOther ? this : (
Tests
)
Tests
.False.Instance;
3482
public override
Tests
RewriteNestedLengthTests()
3521
static
Tests
? knownResult(BinaryOperatorKind relation, ConstantValue constant, int offset)
3555
return new RemoveEvaluationAndUpdateTempReferencesResult(
Tests
.True.Instance, tempMap, conditionToUseFinalResult: null, tempsUpdatedResult: null);
3565
return new RemoveEvaluationAndUpdateTempReferencesResult(
Tests
.True.Instance, tempMap, conditionToUseFinalResult: null, tempsUpdatedResult: null);
3580
Tests
finalResult = RemoveEvaluation(tempsUpdatedResult, builder, state, ref tempMap, e, out
var
condition);
3618
public static
Tests
RemoveEvaluation(One tests, DecisionDagBuilder builder, DagState state, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagEvaluation e, out
Tests
? condition)
3669
private static
Tests
RemoveAssignmentEvaluation(One tests, BoundDagAssignmentEvaluation e1)
3673
return
Tests
.True.Instance;
3679
private static
Tests
RemoveSimpleEvaluationWithResultTemp(One tests, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagEvaluation e1)
3685
return
Tests
.True.Instance;
3713
private static
Tests
RemoveDeconstructEvaluation(One tests, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagDeconstructEvaluation e1)
3719
return
Tests
.True.Instance;
3737
private static
Tests
RemoveTypeEvaluation(One tests, DecisionDagBuilder dagBuilder, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagTypeEvaluation e1)
3747
return
Tests
.True.Instance;
3779
static
Tests
? replaceUnionTypeEvaluation(DecisionDagBuilder dagBuilder, BoundDagTypeEvaluation e1, BoundDagTypeEvaluation typeEval)
3804
return AndSequence.Create(new
Tests
.One(newTypeEval), new
Tests
.One(new BoundDagPassThroughEvaluation(typeEval.Syntax, newTemp)));
3814
private static
Tests
RemoveIndexerEvaluation(One tests, DecisionDagBuilder dagBuilder, DagState state, ref ImmutableDictionary<BoundDagTemp, BoundDagTemp> tempMap, BoundDagIndexerEvaluation s1, out
Tests
? condition)
3834
return
Tests
.True.Instance;
3852
return
Tests
.True.Instance;
3860
condition = new
Tests
.One(new BoundDagValueTest(s2.Syntax, ConstantValue.Create(lengthValue), s1LengthTemp));
3862
return
Tests
.True.Instance;
3983
public readonly
Tests
Negated;
3984
private Not(
Tests
negated) => Negated = negated;
3985
public static
Tests
Create(
Tests
negated) => negated switch
3987
Tests
.True _ =>
Tests
.False.Instance,
3988
Tests
.False _ =>
Tests
.True.Instance,
3989
Tests
.Not n => n.Negated, // double negative
3990
Tests
.AndSequence a => new Not(a),
3991
Tests
.OrSequence a =>
Tests
.AndSequence.Create(NegateSequenceElements(a.RemainingTests)), // use demorgan to prefer and sequences
3992
Tests
.One o => new Not(o),
3995
private static ArrayBuilder<
Tests
> NegateSequenceElements(ImmutableArray<
Tests
> seq)
3997
var builder = ArrayBuilder<
Tests
>.GetInstance(seq.Length);
3998
foreach (
var
t in seq)
4012
public override
Tests
RewriteNestedLengthTests() => Create(Negated.RewriteNestedLengthTests());
4021
out
Tests
whenTrue,
4022
out
Tests
whenFalse,
4025
Negated.Filter(builder, test, state, whenTrueValues, whenFalseValues, out
var
whenTestTrue, out
var
whenTestFalse, ref foundExplicitNullTest);
4035
public readonly ImmutableArray<
Tests
> RemainingTests;
4036
protected SequenceTests(ImmutableArray<
Tests
> remainingTests)
4041
public abstract
Tests
Update(ArrayBuilder<
Tests
> remainingTests);
4048
out
Tests
whenTrue,
4049
out
Tests
whenFalse,
4052
var testsToFilter = ArrayBuilder<
Tests
?>.GetInstance();
4054
var trueTests = ArrayBuilder<
Tests
>.GetInstance();
4055
var falseTests = ArrayBuilder<
Tests
>.GetInstance();
4061
var
current = testsToFilter.Pop();
4083
current.Filter(builder, test, state, whenTrueValues, whenFalseValues, out
Tests
oneTrue, out
Tests
oneFalse, ref foundExplicitNullTest);
4105
static void assemble(SequenceTests toAssemble, ArrayBuilder<
Tests
> tests)
4108
var newSequence = ArrayBuilder<
Tests
>.GetInstance(length, null!);
4126
var testsToRewrite = ArrayBuilder<(
Tests
? Tests, bool SkipRewrite)>.GetInstance();
4132
var testsRewritten = ArrayBuilder<
Tests
>.GetInstance();
4143
ImmutableArray<
Tests
> remainingTests = seq.RemainingTests;
4157
var newSequence = ArrayBuilder<
Tests
>.GetInstance(childCount);
4211
var
result = testsRewritten.Pop();
4240
var leftToRewriteBuilder = ArrayBuilder<
Tests
>.GetInstance();
4267
void pushConditionalResult(RemoveEvaluationAndUpdateTempReferencesResult rewriteResult, ArrayBuilder<
Tests
> leftToRewriteBuilder)
4331
void popAndAddChildrenLeftToRewrite(ArrayBuilder<
Tests
> leftToRewriteBuilder)
4349
public sealed override
Tests
RewriteNestedLengthTests()
4351
var testsToRewrite = ArrayBuilder<
Tests
?>.GetInstance();
4353
var testsRewritten = ArrayBuilder<
Tests
>.GetInstance();
4359
var
current = testsToRewrite.Pop();
4372
var newSequence = ArrayBuilder<
Tests
>.GetInstance(length);
4388
var
result = testsRewritten.Pop();
4412
var tests1 = ArrayBuilder<
Tests
>.GetInstance();
4413
var tests2 = ArrayBuilder<
Tests
>.GetInstance();
4420
var
t1 = tests1.Pop();
4421
var
t2 = tests2.Pop();
4492
var tests = ArrayBuilder<
Tests
>.GetInstance();
4497
var
t = tests.Pop();
4538
Tests
firstTest;
4570
private AndSequence(ImmutableArray<
Tests
> remainingTests) : base(remainingTests)
4574
public override
Tests
Update(ArrayBuilder<
Tests
> remainingTests) => Create(remainingTests);
4575
public static
Tests
Create(
Tests
t1,
Tests
t2)
4580
var builder = ArrayBuilder<
Tests
>.GetInstance(2);
4585
public static
Tests
Create(ArrayBuilder<
Tests
> remainingTests)
4605
var
result = remainingTests.Count switch
4676
private OrSequence(ImmutableArray<
Tests
> remainingTests) : base(remainingTests)
4680
public override
Tests
Update(ArrayBuilder<
Tests
> remainingTests) => Create(remainingTests);
4681
public static
Tests
Create(
Tests
t1,
Tests
t2)
4686
var builder = ArrayBuilder<
Tests
>.GetInstance(2);
4691
public static
Tests
Create(ArrayBuilder<
Tests
> remainingTests)
4711
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);