95 lines
3.0 KiB
C#
95 lines
3.0 KiB
C#
namespace Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
|
|
internal static class SyntaxBindingUtilities
|
|
{
|
|
public static bool BindsToResumableStateMachineState(SyntaxNode node)
|
|
{
|
|
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
|
|
bool flag = node.IsKind(SyntaxKind.YieldReturnStatement) || node.IsKind(SyntaxKind.AwaitExpression);
|
|
bool flag2;
|
|
if (!flag)
|
|
{
|
|
if (node is CommonForEachStatementSyntax { AwaitKeyword: var awaitKeyword })
|
|
{
|
|
if (((SyntaxToken)(ref awaitKeyword)).RawKind != 0)
|
|
{
|
|
goto IL_00cc;
|
|
}
|
|
}
|
|
else if (node is VariableDeclaratorSyntax variableDeclaratorSyntax)
|
|
{
|
|
CSharpSyntaxNode parent = variableDeclaratorSyntax.Parent;
|
|
if (parent != null)
|
|
{
|
|
CSharpSyntaxNode parent2 = parent.Parent;
|
|
if (parent2 is UsingStatementSyntax { AwaitKeyword: var awaitKeyword2 })
|
|
{
|
|
if (((SyntaxToken)(ref awaitKeyword2)).RawKind != 0)
|
|
{
|
|
goto IL_00cc;
|
|
}
|
|
}
|
|
else if (parent2 is LocalDeclarationStatementSyntax { AwaitKeyword: var awaitKeyword3 } && ((SyntaxToken)(ref awaitKeyword3)).RawKind != 0)
|
|
{
|
|
goto IL_00cc;
|
|
}
|
|
}
|
|
}
|
|
else if (node is UsingStatementSyntax { Expression: not null, AwaitKeyword: var awaitKeyword4 } && ((SyntaxToken)(ref awaitKeyword4)).RawKind != 0)
|
|
{
|
|
goto IL_00cc;
|
|
}
|
|
flag2 = false;
|
|
goto IL_00d4;
|
|
}
|
|
goto IL_00d7;
|
|
IL_00cc:
|
|
flag2 = true;
|
|
goto IL_00d4;
|
|
IL_00d7:
|
|
return flag;
|
|
IL_00d4:
|
|
flag = flag2;
|
|
goto IL_00d7;
|
|
}
|
|
|
|
public static bool BindsToTryStatement(SyntaxNode node)
|
|
{
|
|
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
|
|
if (node is VariableDeclaratorSyntax variableDeclaratorSyntax)
|
|
{
|
|
CSharpSyntaxNode parent = variableDeclaratorSyntax.Parent;
|
|
if (parent != null)
|
|
{
|
|
CSharpSyntaxNode parent2 = parent.Parent;
|
|
if (parent2 is UsingStatementSyntax || (parent2 is LocalDeclarationStatementSyntax { UsingKeyword: var usingKeyword } && ((SyntaxToken)(ref usingKeyword)).RawKind != 0))
|
|
{
|
|
goto IL_006f;
|
|
}
|
|
}
|
|
}
|
|
else if (node is UsingStatementSyntax usingStatementSyntax)
|
|
{
|
|
if (usingStatementSyntax.Expression != null)
|
|
{
|
|
goto IL_006f;
|
|
}
|
|
}
|
|
else if (node is CommonForEachStatementSyntax || node is TryStatementSyntax || node is LockStatementSyntax)
|
|
{
|
|
goto IL_006f;
|
|
}
|
|
return false;
|
|
IL_006f:
|
|
return true;
|
|
}
|
|
}
|