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