64 lines
1.8 KiB
C#
64 lines
1.8 KiB
C#
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
|
|
|
internal static class NullableFlowStateExtensions
|
|
{
|
|
public static bool MayBeNull(this NullableFlowState state)
|
|
{
|
|
return state != NullableFlowState.NotNull;
|
|
}
|
|
|
|
public static bool IsNotNull(this NullableFlowState state)
|
|
{
|
|
return state == NullableFlowState.NotNull;
|
|
}
|
|
|
|
public static NullableFlowState Join(this NullableFlowState a, NullableFlowState b)
|
|
{
|
|
if ((int)a <= (int)b)
|
|
{
|
|
return b;
|
|
}
|
|
return a;
|
|
}
|
|
|
|
public static NullableFlowState Meet(this NullableFlowState a, NullableFlowState b)
|
|
{
|
|
if ((int)a >= (int)b)
|
|
{
|
|
return b;
|
|
}
|
|
return a;
|
|
}
|
|
|
|
internal static NullableFlowState ToPublicFlowState(this NullableFlowState nullableFlowState)
|
|
{
|
|
//IL_0019: 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_0021: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
|
|
return (NullableFlowState)(nullableFlowState switch
|
|
{
|
|
NullableFlowState.NotNull => 1,
|
|
NullableFlowState.MaybeNull => 2,
|
|
NullableFlowState.MaybeDefault => 2,
|
|
_ => throw ExceptionUtilities.UnexpectedValue((object)nullableFlowState),
|
|
});
|
|
}
|
|
|
|
public static NullableFlowState ToInternalFlowState(this NullableFlowState flowState)
|
|
{
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0012: Expected I4, but got Unknown
|
|
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
|
|
return (int)flowState switch
|
|
{
|
|
0 => NullableFlowState.NotNull,
|
|
1 => NullableFlowState.NotNull,
|
|
2 => NullableFlowState.MaybeNull,
|
|
_ => throw ExceptionUtilities.UnexpectedValue((object)flowState),
|
|
};
|
|
}
|
|
}
|