Files
2026-08-27 10:56:38 -06:00

81 lines
3.6 KiB
C#

using System;
using Microsoft.CodeAnalysis.CodeGen;
namespace Microsoft.CodeAnalysis.CSharp;
internal sealed class ResumableStateMachineStateAllocator
{
private readonly VariableSlotAllocator? _slotAllocator;
private readonly bool _increasing;
private readonly StateMachineState _firstState;
private StateMachineState _nextState;
private int _matchedStateCount;
public bool HasMissingStates
{
get
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected I4, but got Unknown
int matchedStateCount = _matchedStateCount;
VariableSlotAllocator? slotAllocator = _slotAllocator;
return matchedStateCount < Math.Abs((((_003F?)((slotAllocator != null) ? slotAllocator.GetFirstUnusedStateMachineState(_increasing) : ((StateMachineState?)null))) ?? _firstState) - _firstState);
}
}
public ResumableStateMachineStateAllocator(VariableSlotAllocator? slotAllocator, StateMachineState firstState, bool increasing)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
_increasing = increasing;
_slotAllocator = slotAllocator;
_matchedStateCount = 0;
_firstState = firstState;
_nextState = (StateMachineState)(((_003F?)((slotAllocator != null) ? slotAllocator.GetFirstUnusedStateMachineState(increasing) : ((StateMachineState?)null))) ?? firstState);
}
public StateMachineState AllocateState(SyntaxNode awaitOrYieldReturnSyntax, AwaitDebugId awaitId)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
int num = (_increasing ? 1 : (-1));
VariableSlotAllocator? slotAllocator = _slotAllocator;
StateMachineState nextState = default(StateMachineState);
if (slotAllocator != null && slotAllocator.TryGetPreviousStateMachineState(awaitOrYieldReturnSyntax, awaitId, ref nextState))
{
_matchedStateCount++;
}
else
{
nextState = _nextState;
_nextState = (StateMachineState)(_nextState + num);
}
return nextState;
}
public BoundStatement? GenerateThrowMissingStateDispatch(SyntheticBoundNodeFactory f, BoundExpression cachedState, string message)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if (!HasMissingStates)
{
return null;
}
return f.If(f.Binary(_increasing ? BinaryOperatorKind.IntGreaterThanOrEqual : BinaryOperatorKind.IntLessThanOrEqual, f.SpecialType((SpecialType)7), cachedState, f.Literal(_firstState)), f.Throw(f.New(f.WellKnownMethod((WellKnownMember)454), f.StringLiteral(ConstantValue.Create(message)))));
}
}