105 references to StateMachineState
Microsoft.CodeAnalysis (26)
CodeGen\StateMachineStateDebugInfo.cs (11)
12
internal readonly struct StateMachineStateDebugInfo(int syntaxOffset, AwaitDebugId awaitId,
StateMachineState
stateNumber)
16
public readonly
StateMachineState
StateNumber = stateNumber;
34
public readonly
StateMachineState
? FirstUnusedIncreasingStateMachineState;
43
public readonly
StateMachineState
? FirstUnusedDecreasingStateMachineState;
45
private StateMachineStatesDebugInfo(ImmutableArray<StateMachineStateDebugInfo> states,
StateMachineState
? firstUnusedIncreasingStateMachineState,
StateMachineState
? firstUnusedDecreasingStateMachineState)
54
StateMachineState
? firstUnusedIncreasingStateMachineState = null, firstUnusedDecreasingStateMachineState = null;
67
var
maxState = stateInfos.Max(info => info.StateNumber) + 1;
68
var
minState = stateInfos.Min(info => info.StateNumber) - 1;
70
firstUnusedIncreasingStateMachineState = (firstUnusedIncreasingStateMachineState != null) ? (
StateMachineState
)Math.Max((int)firstUnusedIncreasingStateMachineState.Value, (int)maxState) : maxState;
74
firstUnusedDecreasingStateMachineState = (firstUnusedDecreasingStateMachineState != null) ? (
StateMachineState
)Math.Min((int)firstUnusedDecreasingStateMachineState.Value, (int)minState) : minState;
CodeGen\VariableSlotAllocator.cs (2)
106
public abstract
StateMachineState
? GetFirstUnusedStateMachineState(bool increasing);
116
public abstract bool TryGetPreviousStateMachineState(SyntaxNode syntax, AwaitDebugId awaitId, out
StateMachineState
state);
Emit\EditAndContinue\DefinitionMap.cs (4)
232
IReadOnlyDictionary<(int syntaxOffset, AwaitDebugId debugId),
StateMachineState
>? stateMachineStateMap = null;
233
StateMachineState
? firstUnusedIncreasingStateMachineState = null;
234
StateMachineState
? firstUnusedDecreasingStateMachineState = null;
486
private static IReadOnlyDictionary<(int syntaxOffset, AwaitDebugId debugId),
StateMachineState
>? MakeStateMachineStateMap(ImmutableArray<StateMachineStateDebugInfo> debugInfos)
Emit\EditAndContinue\EncVariableSlotAllocator.cs (8)
37
private readonly IReadOnlyDictionary<(int syntaxOffset, AwaitDebugId awaitId),
StateMachineState
>? _stateMachineStateMap;
38
private readonly
StateMachineState
? _firstUnusedDecreasingStateMachineState;
39
private readonly
StateMachineState
? _firstUnusedIncreasingStateMachineState;
59
IReadOnlyDictionary<(int syntaxOffset, AwaitDebugId awaitId),
StateMachineState
>? stateMachineStateMap,
60
StateMachineState
? firstUnusedIncreasingStateMachineState,
61
StateMachineState
? firstUnusedDecreasingStateMachineState,
358
public override
StateMachineState
? GetFirstUnusedStateMachineState(bool increasing)
361
public override bool TryGetPreviousStateMachineState(SyntaxNode syntax, AwaitDebugId awaitId, out
StateMachineState
state)
Emit\EditAndContinueMethodDebugInformation.cs (1)
349
mapBuilder.Add(new StateMachineStateDebugInfo(syntaxOffset, new AwaitDebugId((byte)relativeOrdinal), (
StateMachineState
)stateNumber));
Microsoft.CodeAnalysis.CSharp (67)
Lowering\AsyncRewriter\AsyncIteratorMethodToStateMachineRewriter.cs (7)
43
/// States for `yield return` are decreasing from <see cref="
StateMachineState
.InitialAsyncIteratorState"/>.
76
firstState:
StateMachineState
.FirstResumableAsyncIteratorState,
231
return F.IntEqual(F.Local(cachedState), F.Literal(
StateMachineState
.NotStartedOrRunningState));
250
AddState(
StateMachineState
.InitialAsyncIteratorState, out GeneratedLabelSymbol resumeLabel);
258
GenerateSetBothStates(
StateMachineState
.NotStartedOrRunningState), // this.state = cachedState = -1;
277
AddResumableState(_iteratorStateAllocator, node.Syntax, awaitId: default, out
var
stateNumber, out GeneratedLabelSymbol resumeLabel);
302
GenerateSetBothStates(
StateMachineState
.NotStartedOrRunningState));
Lowering\AsyncRewriter\AsyncMethodToStateMachineRewriter.cs (6)
135
protected sealed override
StateMachineState
FirstIncreasingResumableState
136
=>
StateMachineState
.FirstResumableAsyncState;
172
var stateDone = F.Assignment(F.Field(F.This(), stateField), F.Literal(
StateMachineState
.FinishedState));
233
F.ExpressionStatement(F.AssignmentExpression(F.Field(F.This(), stateField), F.Literal(
StateMachineState
.FinishedState)));
469
AddResumableState(awaitSyntax, debugInfo.AwaitId, out
StateMachineState
stateNumber, out GeneratedLabelSymbol resumeLabel);
532
GenerateSetBothStates(
StateMachineState
.NotStartedOrRunningState));
Lowering\AsyncRewriter\AsyncRewriter.AsyncIteratorRewriter.cs (8)
203
var
initialState = _isEnumerable ?
StateMachineState
.FinishedState :
StateMachineState
.InitialAsyncIteratorState;
332
F.IntEqual(F.InstanceField(stateField), F.Literal(
StateMachineState
.FinishedState)),
442
F.IntGreaterThanOrEqual(F.InstanceField(stateField), F.Literal(
StateMachineState
.NotStartedOrRunningState)),
448
F.IntEqual(F.InstanceField(stateField), F.Literal(
StateMachineState
.FinishedState)),
660
GenerateIteratorGetEnumerator(IAsyncEnumerableOfElementType_GetEnumerator, ref managedThreadId, initialState:
StateMachineState
.InitialAsyncIteratorState);
663
protected override void GenerateResetInstance(ArrayBuilder<BoundStatement> builder,
StateMachineState
initialState)
Lowering\AsyncRewriter\AsyncRewriter.cs (1)
242
F.Literal(
StateMachineState
.NotStartedOrRunningState)));
Lowering\IteratorRewriter\IteratorMethodToStateMachineRewriter.cs (11)
54
private
StateMachineState
_nextFinalizeState;
74
_nextFinalizeState = slotAllocatorOpt?.GetFirstUnusedStateMachineState(increasing: false) ??
StateMachineState
.FirstIteratorFinalizeState;
86
protected override
StateMachineState
FirstIncreasingResumableState
87
=>
StateMachineState
.FirstResumableIteratorState;
104
AddState(
StateMachineState
.InitialIteratorState, out GeneratedLabelSymbol initialLabel);
127
F.Assignment(F.Field(F.This(), stateField), F.Literal(
StateMachineState
.NotStartedOrRunningState)),
171
F.Assignment(F.Field(F.This(), stateField), F.Literal(
StateMachineState
.FinishedState)),
186
F.Assignment(F.Field(F.This(), stateField), F.Literal(
StateMachineState
.FinishedState)),
342
AddResumableState(node.Syntax, awaitId: default, out
StateMachineState
stateNumber, out GeneratedLabelSymbol resumeLabel);
473
if (slotAllocator?.TryGetPreviousStateMachineState(syntax, awaitId: default, out
var
finalizeState) != true)
499
private IteratorFinallyMethodSymbol MakeSynthesizedFinally(
StateMachineState
finalizeState)
Lowering\IteratorRewriter\IteratorMethodToStateMachineRewriter.IteratorFinallyFrame.cs (7)
19
public readonly
StateMachineState
finalizeState;
31
public Dictionary<
StateMachineState
, IteratorFinallyFrame> knownStates;
45
StateMachineState
finalizeState,
60
this.finalizeState =
StateMachineState
.NotStartedOrRunningState;
68
public void AddState(
StateMachineState
state)
79
private void AddState(
StateMachineState
state, IteratorFinallyFrame innerHandler)
84
this.knownStates = knownStates = new Dictionary<
StateMachineState
, IteratorFinallyFrame>();
Lowering\IteratorRewriter\IteratorRewriter.cs (4)
262
var getEnumeratorGeneric = GenerateIteratorGetEnumerator(IEnumerableOfElementType_GetEnumerator, ref managedThreadId,
StateMachineState
.InitialIteratorState);
305
var
initialState = _isEnumerable ?
StateMachineState
.FinishedState :
StateMachineState
.InitialIteratorState;
Lowering\StateMachineRewriter\MethodToStateMachineRewriter.cs (13)
64
private Dictionary<LabelSymbol, List<
StateMachineState
>> _dispatches = new Dictionary<LabelSymbol, List<
StateMachineState
>>();
167
protected abstract
StateMachineState
FirstIncreasingResumableState { get; }
214
protected void AddResumableState(SyntaxNode awaitOrYieldReturnSyntax, AwaitDebugId awaitId, out
StateMachineState
state, out GeneratedLabelSymbol resumeLabel)
217
protected void AddResumableState(ResumableStateMachineStateAllocator allocator, SyntaxNode awaitOrYieldReturnSyntax, AwaitDebugId awaitId, out
StateMachineState
stateNumber, out GeneratedLabelSymbol resumeLabel)
224
protected void AddStateDebugInfo(SyntaxNode node, AwaitDebugId awaitId,
StateMachineState
state)
232
protected void AddState(
StateMachineState
stateNumber, out GeneratedLabelSymbol resumeLabel)
234
_dispatches ??= new Dictionary<LabelSymbol, List<
StateMachineState
>>();
237
_dispatches.Add(resumeLabel, new List<
StateMachineState
> { stateNumber });
900
oldDispatches ??= new Dictionary<LabelSymbol, List<
StateMachineState
>>();
901
oldDispatches.Add(dispatchLabel, new List<
StateMachineState
>(from kv in _dispatches.Values from n in kv orderby n select n));
936
return F.IntLessThan(F.Local(cachedState), F.Literal(
StateMachineState
.FirstUnusedState));
942
protected BoundExpressionStatement GenerateSetBothStates(
StateMachineState
stateNumber)
Lowering\StateMachineRewriter\ResumableStateMachineStateAllocator.cs (5)
23
private readonly
StateMachineState
_firstState;
28
private
StateMachineState
_nextState;
41
public ResumableStateMachineStateAllocator(VariableSlotAllocator? slotAllocator,
StateMachineState
firstState, bool increasing)
50
public
StateMachineState
AllocateState(SyntaxNode awaitOrYieldReturnSyntax, AwaitDebugId awaitId)
56
if (_slotAllocator?.TryGetPreviousStateMachineState(awaitOrYieldReturnSyntax, awaitId, out
var
state) == true)
Lowering\StateMachineRewriter\StateMachineRewriter.cs (3)
402
protected SynthesizedImplementationMethod GenerateIteratorGetEnumerator(MethodSymbol getEnumeratorMethod, ref BoundExpression managedThreadId,
StateMachineState
initialState)
455
F.IntEqual(F.Field(F.This(), stateField), F.Literal(
StateMachineState
.FinishedState)),
512
protected virtual void GenerateResetInstance(ArrayBuilder<BoundStatement> builder,
StateMachineState
initialState)
Lowering\SyntheticBoundNodeFactory.cs (1)
731
public BoundLiteral Literal(
StateMachineState
value)
Symbols\Synthesized\GeneratedNames.cs (1)
33
internal static string MakeIteratorFinallyMethodName(
StateMachineState
finalizeState)
Microsoft.CodeAnalysis.UnitTests (12)
Emit\CustomDebugInfoTests.cs (12)
304
new StateMachineStateDebugInfo(syntaxOffset: 0x10, new AwaitDebugId(2), (
StateMachineState
)0),
305
new StateMachineStateDebugInfo(syntaxOffset: 0x30, new AwaitDebugId(0), (
StateMachineState
)5),
306
new StateMachineStateDebugInfo(syntaxOffset: 0x10, new AwaitDebugId(0), (
StateMachineState
)1),
307
new StateMachineStateDebugInfo(syntaxOffset: 0x20, new AwaitDebugId(0), (
StateMachineState
)3),
308
new StateMachineStateDebugInfo(syntaxOffset: 0x10, new AwaitDebugId(1), (
StateMachineState
)2),
309
new StateMachineStateDebugInfo(syntaxOffset: 0x20, new AwaitDebugId(1), (
StateMachineState
)4)
324
new StateMachineStateDebugInfo(syntaxOffset: 0x10, new AwaitDebugId(0), (
StateMachineState
)1),
325
new StateMachineStateDebugInfo(syntaxOffset: 0x10, new AwaitDebugId(1), (
StateMachineState
)2),
326
new StateMachineStateDebugInfo(syntaxOffset: 0x10, new AwaitDebugId(2), (
StateMachineState
)0),
327
new StateMachineStateDebugInfo(syntaxOffset: 0x20, new AwaitDebugId(0), (
StateMachineState
)3),
328
new StateMachineStateDebugInfo(syntaxOffset: 0x20, new AwaitDebugId(1), (
StateMachineState
)4),
329
new StateMachineStateDebugInfo(syntaxOffset: 0x30, new AwaitDebugId(0), (
StateMachineState
)5),