965 lines
36 KiB
C#
965 lines
36 KiB
C#
using System;
|
|||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Collections.Immutable;
|
||
|
|
using System.Diagnostics.CodeAnalysis;
|
||
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
||
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
||
|
|
using Roslyn.Utilities;
|
||
|
|
|
||
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
||
|
|
|
||
|
|
internal sealed class LocalBinderFactory : CSharpSyntaxWalker
|
||
|
|
{
|
||
|
|
private readonly SmallDictionary<SyntaxNode, Binder> _map;
|
||
|
|
|
||
|
|
private Symbol _containingMemberOrLambda;
|
||
|
|
|
||
|
|
private Binder _enclosing;
|
||
|
|
|
||
|
|
private readonly SyntaxNode _root;
|
||
|
|
|
||
|
|
private void Visit(CSharpSyntaxNode syntax, Binder enclosing)
|
||
|
|
{
|
||
|
|
if (_enclosing == enclosing)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)syntax);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
Binder enclosing2 = _enclosing;
|
||
|
|
_enclosing = enclosing;
|
||
|
|
Visit((SyntaxNode?)(object)syntax);
|
||
|
|
_enclosing = enclosing2;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void VisitRankSpecifiers(TypeSyntax type, Binder enclosing)
|
||
|
|
{
|
||
|
|
type.VisitRankSpecifiers(delegate(ArrayRankSpecifierSyntax rankSpecifier, (LocalBinderFactory localBinderFactory, Binder binder) args)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
Enumerator<ExpressionSyntax> enumerator = rankSpecifier.Sizes.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
ExpressionSyntax current = enumerator.Current;
|
||
|
|
if (current.Kind() != SyntaxKind.OmittedArraySizeExpression)
|
||
|
|
{
|
||
|
|
args.localBinderFactory.Visit(current, args.binder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}, (this, enclosing));
|
||
|
|
}
|
||
|
|
|
||
|
|
public static SmallDictionary<SyntaxNode, Binder> BuildMap(Symbol containingMemberOrLambda, SyntaxNode syntax, Binder enclosing, Action<Binder, SyntaxNode> binderUpdatedHandler = null)
|
||
|
|
{
|
||
|
|
LocalBinderFactory localBinderFactory = new LocalBinderFactory(containingMemberOrLambda, syntax, enclosing);
|
||
|
|
if (syntax is ExpressionSyntax syntax2)
|
||
|
|
{
|
||
|
|
enclosing = new ExpressionVariableBinder(syntax, enclosing);
|
||
|
|
binderUpdatedHandler?.Invoke(enclosing, syntax);
|
||
|
|
localBinderFactory.AddToMap(syntax, enclosing);
|
||
|
|
localBinderFactory.Visit(syntax2, enclosing);
|
||
|
|
}
|
||
|
|
else if (syntax.Kind() != SyntaxKind.Block && syntax is StatementSyntax statementSyntax)
|
||
|
|
{
|
||
|
|
enclosing = localBinderFactory.GetBinderForPossibleEmbeddedStatement(statementSyntax, enclosing, out var embeddedScopeDesignator);
|
||
|
|
binderUpdatedHandler?.Invoke(enclosing, (SyntaxNode)(object)embeddedScopeDesignator);
|
||
|
|
if (embeddedScopeDesignator != null)
|
||
|
|
{
|
||
|
|
localBinderFactory.AddToMap((SyntaxNode)(object)embeddedScopeDesignator, enclosing);
|
||
|
|
}
|
||
|
|
localBinderFactory.Visit(statementSyntax, enclosing);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
binderUpdatedHandler?.Invoke(enclosing, null);
|
||
|
|
localBinderFactory.Visit((CSharpSyntaxNode)(object)syntax, enclosing);
|
||
|
|
}
|
||
|
|
return localBinderFactory._map;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitCompilationUnit(CompilationUnitSyntax node)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
Enumerator<MemberDeclarationSyntax> enumerator = node.Members.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
MemberDeclarationSyntax current = enumerator.Current;
|
||
|
|
if (current.Kind() == SyntaxKind.GlobalStatement)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)current);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private LocalBinderFactory(Symbol containingMemberOrLambda, SyntaxNode root, Binder enclosing)
|
||
|
|
: base((SyntaxWalkerDepth)0)
|
||
|
|
{
|
||
|
|
_map = new SmallDictionary<SyntaxNode, Binder>((IEqualityComparer<SyntaxNode>)ReferenceEqualityComparer.Instance);
|
||
|
|
_containingMemberOrLambda = containingMemberOrLambda;
|
||
|
|
_enclosing = enclosing;
|
||
|
|
_root = root;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitMethodDeclaration(MethodDeclarationSyntax node)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)node.Body);
|
||
|
|
Visit((SyntaxNode?)(object)node.ExpressionBody);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitConstructorDeclaration(ConstructorDeclarationSyntax node)
|
||
|
|
{
|
||
|
|
Binder binder = new ExpressionVariableBinder((SyntaxNode)(object)node, _enclosing);
|
||
|
|
AddToMap((SyntaxNode)(object)node, binder);
|
||
|
|
Visit(node.Initializer, binder);
|
||
|
|
Visit(node.Body, binder);
|
||
|
|
Visit(node.ExpressionBody, binder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitClassDeclaration(ClassDeclarationSyntax node)
|
||
|
|
{
|
||
|
|
VisitTypeDeclaration(node);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitRecordDeclaration(RecordDeclarationSyntax node)
|
||
|
|
{
|
||
|
|
VisitTypeDeclaration(node);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void VisitTypeDeclaration(TypeDeclarationSyntax node)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)node.PrimaryConstructorBaseTypeIfClass);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitPrimaryConstructorBaseType(PrimaryConstructorBaseTypeSyntax node)
|
||
|
|
{
|
||
|
|
Binder binder = new ExpressionVariableBinder((SyntaxNode)(object)node, _enclosing).WithAdditionalFlags(BinderFlags.ConstructorInitializer);
|
||
|
|
AddToMap((SyntaxNode)(object)node, binder);
|
||
|
|
VisitConstructorInitializerArgumentList(node, node.ArgumentList, binder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitDestructorDeclaration(DestructorDeclarationSyntax node)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)node.Body);
|
||
|
|
Visit((SyntaxNode?)(object)node.ExpressionBody);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitAccessorDeclaration(AccessorDeclarationSyntax node)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)node.Body);
|
||
|
|
Visit((SyntaxNode?)(object)node.ExpressionBody);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitConversionOperatorDeclaration(ConversionOperatorDeclarationSyntax node)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)node.Body);
|
||
|
|
Visit((SyntaxNode?)(object)node.ExpressionBody);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitOperatorDeclaration(OperatorDeclarationSyntax node)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)node.Body);
|
||
|
|
Visit((SyntaxNode?)(object)node.ExpressionBody);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitInvocationExpression(InvocationExpressionSyntax node)
|
||
|
|
{
|
||
|
|
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
InvocationExpressionSyntax nested;
|
||
|
|
if (node.MayBeNameofOperator())
|
||
|
|
{
|
||
|
|
Binder enclosing = _enclosing;
|
||
|
|
WithTypeParametersBinder withTypeParametersBinder;
|
||
|
|
Binder withParametersBinder;
|
||
|
|
if ((_enclosing.Flags & BinderFlags.InContextualAttributeBinder) != BinderFlags.None)
|
||
|
|
{
|
||
|
|
Symbol target = getAttributeTarget(_enclosing);
|
||
|
|
withTypeParametersBinder = getExtraWithTypeParametersBinder(_enclosing, target);
|
||
|
|
withParametersBinder = getExtraWithParametersBinder(_enclosing, target);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
withTypeParametersBinder = null;
|
||
|
|
withParametersBinder = null;
|
||
|
|
}
|
||
|
|
NameofBinder nameofBinder = new NameofBinder((SyntaxNode)(object)node.ArgumentList.Arguments[0].Expression, _enclosing, withTypeParametersBinder, withParametersBinder);
|
||
|
|
AddToMap((SyntaxNode)(object)node, nameofBinder);
|
||
|
|
_enclosing = nameofBinder;
|
||
|
|
base.VisitInvocationExpression(node);
|
||
|
|
_enclosing = enclosing;
|
||
|
|
}
|
||
|
|
else if (receiverIsInvocation(node, out nested))
|
||
|
|
{
|
||
|
|
ArrayBuilder<InvocationExpressionSyntax> instance = ArrayBuilder<InvocationExpressionSyntax>.GetInstance();
|
||
|
|
ArrayBuilderExtensions.Push<InvocationExpressionSyntax>(instance, node);
|
||
|
|
node = nested;
|
||
|
|
while (receiverIsInvocation(node, out nested))
|
||
|
|
{
|
||
|
|
ArrayBuilderExtensions.Push<InvocationExpressionSyntax>(instance, node);
|
||
|
|
node = nested;
|
||
|
|
}
|
||
|
|
Visit((SyntaxNode?)(object)node.Expression);
|
||
|
|
do
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)node.ArgumentList);
|
||
|
|
}
|
||
|
|
while (ArrayBuilderExtensions.TryPop<InvocationExpressionSyntax>(instance, ref node));
|
||
|
|
instance.Free();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)node.Expression);
|
||
|
|
Visit((SyntaxNode?)(object)node.ArgumentList);
|
||
|
|
}
|
||
|
|
static ImmutableArray<ParameterSymbol> getAllParameters(ParameterSymbol parameter)
|
||
|
|
{
|
||
|
|
Symbol containingSymbol = parameter.ContainingSymbol;
|
||
|
|
if (containingSymbol is MethodSymbol methodSymbol)
|
||
|
|
{
|
||
|
|
return methodSymbol.Parameters;
|
||
|
|
}
|
||
|
|
if (containingSymbol is PropertySymbol propertySymbol)
|
||
|
|
{
|
||
|
|
return propertySymbol.Parameters;
|
||
|
|
}
|
||
|
|
return default(ImmutableArray<ParameterSymbol>);
|
||
|
|
}
|
||
|
|
static Symbol getAttributeTarget(Binder current)
|
||
|
|
{
|
||
|
|
return Binder.TryGetContextualAttributeBinder(current).AttributeTarget;
|
||
|
|
}
|
||
|
|
static ImmutableArray<ParameterSymbol> getDelegateParameters(NamedTypeSymbol delegateType)
|
||
|
|
{
|
||
|
|
return delegateType.DelegateInvokeMethod?.Parameters ?? default(ImmutableArray<ParameterSymbol>);
|
||
|
|
}
|
||
|
|
static Binder? getExtraWithParametersBinder(Binder binder, Symbol symbol)
|
||
|
|
{
|
||
|
|
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0028: Invalid comparison between Unknown and I4
|
||
|
|
if (symbol is LambdaSymbol lambdaSymbol)
|
||
|
|
{
|
||
|
|
return new WithLambdaParametersBinder(lambdaSymbol, binder);
|
||
|
|
}
|
||
|
|
MethodSymbol methodSymbol;
|
||
|
|
ImmutableArray<ParameterSymbol> immutableArray;
|
||
|
|
if (symbol is SourcePropertyAccessorSymbol sourcePropertyAccessorSymbol)
|
||
|
|
{
|
||
|
|
if ((int)sourcePropertyAccessorSymbol.MethodKind != 12)
|
||
|
|
{
|
||
|
|
methodSymbol = (MethodSymbol)symbol;
|
||
|
|
goto IL_0083;
|
||
|
|
}
|
||
|
|
immutableArray = getSetterParameters(sourcePropertyAccessorSymbol);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
methodSymbol = symbol as MethodSymbol;
|
||
|
|
if ((object)methodSymbol != null)
|
||
|
|
{
|
||
|
|
goto IL_0083;
|
||
|
|
}
|
||
|
|
immutableArray = ((symbol is ParameterSymbol parameter) ? getAllParameters(parameter) : ((symbol is TypeParameterSymbol typeParameter) ? getMethodParametersFromTypeParameter(typeParameter) : ((symbol is PropertySymbol propertySymbol) ? propertySymbol.Parameters : ((!(symbol is NamedTypeSymbol namedTypeSymbol) || !namedTypeSymbol.IsDelegateType()) ? default(ImmutableArray<ParameterSymbol>) : getDelegateParameters(namedTypeSymbol)))));
|
||
|
|
}
|
||
|
|
goto IL_00ce;
|
||
|
|
IL_00ce:
|
||
|
|
ImmutableArray<ParameterSymbol> parameters = immutableArray;
|
||
|
|
if (!parameters.IsDefaultOrEmpty)
|
||
|
|
{
|
||
|
|
return new WithParametersBinder(parameters, binder);
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
IL_0083:
|
||
|
|
immutableArray = methodSymbol.Parameters;
|
||
|
|
goto IL_00ce;
|
||
|
|
}
|
||
|
|
static WithTypeParametersBinder? getExtraWithTypeParametersBinder(Binder next, Symbol symbol)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0008: Invalid comparison between Unknown and I4
|
||
|
|
if ((int)symbol.Kind != 9)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return new WithMethodTypeParametersBinder((MethodSymbol)symbol, next);
|
||
|
|
}
|
||
|
|
static ImmutableArray<ParameterSymbol> getMethodParametersFromTypeParameter(TypeParameterSymbol typeParameter)
|
||
|
|
{
|
||
|
|
Symbol containingSymbol = typeParameter.ContainingSymbol;
|
||
|
|
if (containingSymbol is MethodSymbol methodSymbol)
|
||
|
|
{
|
||
|
|
return methodSymbol.Parameters;
|
||
|
|
}
|
||
|
|
if (containingSymbol is NamedTypeSymbol namedTypeSymbol && namedTypeSymbol.IsDelegateType())
|
||
|
|
{
|
||
|
|
return getDelegateParameters(namedTypeSymbol);
|
||
|
|
}
|
||
|
|
return default(ImmutableArray<ParameterSymbol>);
|
||
|
|
}
|
||
|
|
static ImmutableArray<ParameterSymbol> getSetterParameters(SourcePropertyAccessorSymbol setter)
|
||
|
|
{
|
||
|
|
ImmutableArray<ParameterSymbol> parameters = setter.Parameters;
|
||
|
|
return parameters.RemoveAt(parameters.Length - 1);
|
||
|
|
}
|
||
|
|
static bool receiverIsInvocation(InvocationExpressionSyntax invocationExpressionSyntax, [NotNullWhen(true)] out InvocationExpressionSyntax? reference)
|
||
|
|
{
|
||
|
|
if (invocationExpressionSyntax.Expression is MemberAccessExpressionSyntax { Expression: InvocationExpressionSyntax expression } && !expression.MayBeNameofOperator())
|
||
|
|
{
|
||
|
|
reference = expression;
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
reference = null;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitSimpleLambdaExpression(SimpleLambdaExpressionSyntax node)
|
||
|
|
{
|
||
|
|
VisitLambdaExpression(node);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void VisitLambdaExpression(LambdaExpressionSyntax node)
|
||
|
|
{
|
||
|
|
if ((object)_root == node)
|
||
|
|
{
|
||
|
|
CSharpSyntaxNode body = node.Body;
|
||
|
|
if (body.Kind() == SyntaxKind.Block)
|
||
|
|
{
|
||
|
|
VisitBlock((BlockSyntax)body);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
ExpressionVariableBinder expressionVariableBinder = new ExpressionVariableBinder((SyntaxNode)(object)body, _enclosing);
|
||
|
|
AddToMap((SyntaxNode)(object)body, expressionVariableBinder);
|
||
|
|
Visit(body, expressionVariableBinder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitParenthesizedLambdaExpression(ParenthesizedLambdaExpressionSyntax node)
|
||
|
|
{
|
||
|
|
VisitLambdaExpression(node);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitLocalFunctionStatement(LocalFunctionStatementSyntax node)
|
||
|
|
{
|
||
|
|
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
Symbol containingMemberOrLambda = _containingMemberOrLambda;
|
||
|
|
Binder enclosing = _enclosing;
|
||
|
|
LocalFunctionSymbol localFunctionSymbol = FindLocalFunction(node, _enclosing);
|
||
|
|
if ((object)localFunctionSymbol != null)
|
||
|
|
{
|
||
|
|
_containingMemberOrLambda = localFunctionSymbol;
|
||
|
|
enclosing = (localFunctionSymbol.IsGenericMethod ? new WithMethodTypeParametersBinder(localFunctionSymbol, _enclosing) : _enclosing);
|
||
|
|
enclosing = enclosing.WithUnsafeRegionIfNecessary(node.Modifiers);
|
||
|
|
enclosing = new InMethodBinder(localFunctionSymbol, enclosing);
|
||
|
|
}
|
||
|
|
BlockSyntax body = node.Body;
|
||
|
|
if (body != null)
|
||
|
|
{
|
||
|
|
Visit(body, enclosing);
|
||
|
|
}
|
||
|
|
ArrowExpressionClauseSyntax expressionBody = node.ExpressionBody;
|
||
|
|
if (expressionBody != null)
|
||
|
|
{
|
||
|
|
Visit(expressionBody, enclosing);
|
||
|
|
}
|
||
|
|
_containingMemberOrLambda = containingMemberOrLambda;
|
||
|
|
}
|
||
|
|
|
||
|
|
private static LocalFunctionSymbol FindLocalFunction(LocalFunctionStatementSyntax node, Binder enclosing)
|
||
|
|
{
|
||
|
|
//IL_003d: 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)
|
||
|
|
LocalFunctionSymbol result = null;
|
||
|
|
Binder binder = enclosing;
|
||
|
|
while (binder != null && !binder.IsLocalFunctionsScopeBinder)
|
||
|
|
{
|
||
|
|
binder = binder.Next;
|
||
|
|
}
|
||
|
|
if (binder != null)
|
||
|
|
{
|
||
|
|
ImmutableArray<LocalFunctionSymbol>.Enumerator enumerator = binder.LocalFunctions.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
LocalFunctionSymbol current = enumerator.Current;
|
||
|
|
Location firstLocation = current.GetFirstLocation();
|
||
|
|
SyntaxToken identifier = node.Identifier;
|
||
|
|
if (firstLocation == ((SyntaxToken)(ref identifier)).GetLocation())
|
||
|
|
{
|
||
|
|
result = current;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitArrowExpressionClause(ArrowExpressionClauseSyntax node)
|
||
|
|
{
|
||
|
|
ExpressionVariableBinder expressionVariableBinder = new ExpressionVariableBinder((SyntaxNode)(object)node, _enclosing);
|
||
|
|
AddToMap((SyntaxNode)(object)node, expressionVariableBinder);
|
||
|
|
Visit(node.Expression, expressionVariableBinder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitEqualsValueClause(EqualsValueClauseSyntax node)
|
||
|
|
{
|
||
|
|
ExpressionVariableBinder expressionVariableBinder = new ExpressionVariableBinder((SyntaxNode)(object)node, _enclosing);
|
||
|
|
AddToMap((SyntaxNode)(object)node, expressionVariableBinder);
|
||
|
|
Visit(node.Value, expressionVariableBinder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitAttribute(AttributeSyntax node)
|
||
|
|
{
|
||
|
|
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_003f: 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_0047: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
ExpressionVariableBinder expressionVariableBinder = new ExpressionVariableBinder((SyntaxNode)(object)node, _enclosing);
|
||
|
|
AddToMap((SyntaxNode)(object)node, expressionVariableBinder);
|
||
|
|
AttributeArgumentListSyntax? argumentList = node.ArgumentList;
|
||
|
|
if (argumentList != null && argumentList.Arguments.Count > 0)
|
||
|
|
{
|
||
|
|
Enumerator<AttributeArgumentSyntax> enumerator = node.ArgumentList.Arguments.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
AttributeArgumentSyntax current = enumerator.Current;
|
||
|
|
Visit(current.Expression, expressionVariableBinder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitConstructorInitializer(ConstructorInitializerSyntax node)
|
||
|
|
{
|
||
|
|
Binder binder = _enclosing.WithAdditionalFlags(BinderFlags.ConstructorInitializer);
|
||
|
|
AddToMap((SyntaxNode)(object)node, binder);
|
||
|
|
VisitConstructorInitializerArgumentList(node, node.ArgumentList, binder);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void VisitConstructorInitializerArgumentList(CSharpSyntaxNode node, ArgumentListSyntax argumentList, Binder binder)
|
||
|
|
{
|
||
|
|
if (argumentList != null)
|
||
|
|
{
|
||
|
|
if ((object)_root == node)
|
||
|
|
{
|
||
|
|
binder = new ExpressionVariableBinder((SyntaxNode)(object)argumentList, binder);
|
||
|
|
AddToMap((SyntaxNode)(object)argumentList, binder);
|
||
|
|
}
|
||
|
|
Visit(argumentList, binder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitAnonymousMethodExpression(AnonymousMethodExpressionSyntax node)
|
||
|
|
{
|
||
|
|
if ((object)_root == node)
|
||
|
|
{
|
||
|
|
VisitBlock(node.Block);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitGlobalStatement(GlobalStatementSyntax node)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)node.Statement);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitBlock(BlockSyntax node)
|
||
|
|
{
|
||
|
|
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
BlockBinder blockBinder = new BlockBinder(_enclosing, node);
|
||
|
|
AddToMap((SyntaxNode)(object)node, blockBinder);
|
||
|
|
Enumerator<StatementSyntax> enumerator = node.Statements.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
StatementSyntax current = enumerator.Current;
|
||
|
|
Visit(current, blockBinder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitUsingStatement(UsingStatementSyntax node)
|
||
|
|
{
|
||
|
|
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0043: 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_004c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
UsingStatementBinder usingStatementBinder = new UsingStatementBinder(_enclosing, node);
|
||
|
|
AddToMap((SyntaxNode)(object)node, usingStatementBinder);
|
||
|
|
ExpressionSyntax expression = node.Expression;
|
||
|
|
VariableDeclarationSyntax declaration = node.Declaration;
|
||
|
|
if (expression != null)
|
||
|
|
{
|
||
|
|
Visit(expression, usingStatementBinder);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
VisitRankSpecifiers(declaration.Type, usingStatementBinder);
|
||
|
|
Enumerator<VariableDeclaratorSyntax> enumerator = declaration.Variables.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
VariableDeclaratorSyntax current = enumerator.Current;
|
||
|
|
Visit(current, usingStatementBinder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
VisitPossibleEmbeddedStatement(node.Statement, usingStatementBinder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitWhileStatement(WhileStatementSyntax node)
|
||
|
|
{
|
||
|
|
WhileBinder whileBinder = new WhileBinder(_enclosing, node);
|
||
|
|
AddToMap((SyntaxNode)(object)node, whileBinder);
|
||
|
|
Visit(node.Condition, whileBinder);
|
||
|
|
VisitPossibleEmbeddedStatement(node.Statement, whileBinder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitDoStatement(DoStatementSyntax node)
|
||
|
|
{
|
||
|
|
WhileBinder whileBinder = new WhileBinder(_enclosing, node);
|
||
|
|
AddToMap((SyntaxNode)(object)node, whileBinder);
|
||
|
|
Visit(node.Condition, whileBinder);
|
||
|
|
VisitPossibleEmbeddedStatement(node.Statement, whileBinder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitForStatement(ForStatementSyntax node)
|
||
|
|
{
|
||
|
|
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//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_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_00ad: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
Binder binder = new ForLoopBinder(_enclosing, node);
|
||
|
|
AddToMap((SyntaxNode)(object)node, binder);
|
||
|
|
VariableDeclarationSyntax declaration = node.Declaration;
|
||
|
|
if (declaration != null)
|
||
|
|
{
|
||
|
|
VisitRankSpecifiers(declaration.Type, binder);
|
||
|
|
Enumerator<VariableDeclaratorSyntax> enumerator = declaration.Variables.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
VariableDeclaratorSyntax current = enumerator.Current;
|
||
|
|
Visit(current, binder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
Enumerator<ExpressionSyntax> enumerator2 = node.Initializers.GetEnumerator();
|
||
|
|
while (enumerator2.MoveNext())
|
||
|
|
{
|
||
|
|
ExpressionSyntax current2 = enumerator2.Current;
|
||
|
|
Visit(current2, binder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
ExpressionSyntax condition = node.Condition;
|
||
|
|
if (condition != null)
|
||
|
|
{
|
||
|
|
binder = new ExpressionVariableBinder((SyntaxNode)(object)condition, binder);
|
||
|
|
AddToMap((SyntaxNode)(object)condition, binder);
|
||
|
|
Visit(condition, binder);
|
||
|
|
}
|
||
|
|
SeparatedSyntaxList<ExpressionSyntax> incrementors = node.Incrementors;
|
||
|
|
if (incrementors.Count > 0)
|
||
|
|
{
|
||
|
|
ExpressionListVariableBinder expressionListVariableBinder = new ExpressionListVariableBinder(incrementors, binder);
|
||
|
|
AddToMap((SyntaxNode)(object)incrementors.First(), expressionListVariableBinder);
|
||
|
|
Enumerator<ExpressionSyntax> enumerator2 = incrementors.GetEnumerator();
|
||
|
|
while (enumerator2.MoveNext())
|
||
|
|
{
|
||
|
|
ExpressionSyntax current3 = enumerator2.Current;
|
||
|
|
Visit(current3, expressionListVariableBinder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
VisitPossibleEmbeddedStatement(node.Statement, binder);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void VisitCommonForEachStatement(CommonForEachStatementSyntax node)
|
||
|
|
{
|
||
|
|
ExpressionVariableBinder expressionVariableBinder = new ExpressionVariableBinder((SyntaxNode)(object)node.Expression, _enclosing);
|
||
|
|
AddToMap((SyntaxNode)(object)node.Expression, expressionVariableBinder);
|
||
|
|
Visit(node.Expression, expressionVariableBinder);
|
||
|
|
ForEachLoopBinder forEachLoopBinder = new ForEachLoopBinder(expressionVariableBinder, node);
|
||
|
|
AddToMap((SyntaxNode)(object)node, forEachLoopBinder);
|
||
|
|
if (node is ForEachVariableStatementSyntax forEachVariableStatementSyntax && !forEachVariableStatementSyntax.Variable.IsDeconstructionLeft())
|
||
|
|
{
|
||
|
|
Visit(forEachVariableStatementSyntax.Variable, forEachLoopBinder);
|
||
|
|
}
|
||
|
|
VisitPossibleEmbeddedStatement(node.Statement, forEachLoopBinder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitForEachStatement(ForEachStatementSyntax node)
|
||
|
|
{
|
||
|
|
VisitCommonForEachStatement(node);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitForEachVariableStatement(ForEachVariableStatementSyntax node)
|
||
|
|
{
|
||
|
|
VisitCommonForEachStatement(node);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitCheckedExpression(CheckedExpressionSyntax node)
|
||
|
|
{
|
||
|
|
Binder binder = _enclosing.WithCheckedOrUncheckedRegion(node.Kind() == SyntaxKind.CheckedExpression);
|
||
|
|
AddToMap((SyntaxNode)(object)node, binder);
|
||
|
|
Visit(node.Expression, binder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitCheckedStatement(CheckedStatementSyntax node)
|
||
|
|
{
|
||
|
|
Binder binder = _enclosing.WithCheckedOrUncheckedRegion(node.Kind() == SyntaxKind.CheckedStatement);
|
||
|
|
AddToMap((SyntaxNode)(object)node, binder);
|
||
|
|
Visit(node.Block, binder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitUnsafeStatement(UnsafeStatementSyntax node)
|
||
|
|
{
|
||
|
|
Binder binder = _enclosing.WithAdditionalFlags(BinderFlags.UnsafeRegion);
|
||
|
|
AddToMap((SyntaxNode)(object)node, binder);
|
||
|
|
Visit(node.Block, binder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitFixedStatement(FixedStatementSyntax node)
|
||
|
|
{
|
||
|
|
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_003d: 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)
|
||
|
|
FixedStatementBinder fixedStatementBinder = new FixedStatementBinder(_enclosing, node);
|
||
|
|
AddToMap((SyntaxNode)(object)node, fixedStatementBinder);
|
||
|
|
if (node.Declaration != null)
|
||
|
|
{
|
||
|
|
VisitRankSpecifiers(node.Declaration.Type, fixedStatementBinder);
|
||
|
|
Enumerator<VariableDeclaratorSyntax> enumerator = node.Declaration.Variables.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
VariableDeclaratorSyntax current = enumerator.Current;
|
||
|
|
Visit(current, fixedStatementBinder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
VisitPossibleEmbeddedStatement(node.Statement, fixedStatementBinder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitLockStatement(LockStatementSyntax node)
|
||
|
|
{
|
||
|
|
LockBinder lockBinder = new LockBinder(_enclosing, node);
|
||
|
|
AddToMap((SyntaxNode)(object)node, lockBinder);
|
||
|
|
Visit(node.Expression, lockBinder);
|
||
|
|
StatementSyntax statement = node.Statement;
|
||
|
|
Binder binder = lockBinder.WithAdditionalFlags(BinderFlags.InLockBody);
|
||
|
|
if (binder != lockBinder)
|
||
|
|
{
|
||
|
|
AddToMap((SyntaxNode)(object)statement, binder);
|
||
|
|
}
|
||
|
|
VisitPossibleEmbeddedStatement(statement, binder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitSwitchStatement(SwitchStatementSyntax node)
|
||
|
|
{
|
||
|
|
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_003f: 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_0047: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
AddToMap((SyntaxNode)(object)node.Expression, _enclosing);
|
||
|
|
Visit(node.Expression, _enclosing);
|
||
|
|
SwitchBinder switchBinder = SwitchBinder.Create(_enclosing, node);
|
||
|
|
AddToMap((SyntaxNode)(object)node, switchBinder);
|
||
|
|
Enumerator<SwitchSectionSyntax> enumerator = node.Sections.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
SwitchSectionSyntax current = enumerator.Current;
|
||
|
|
Visit(current, switchBinder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitSwitchSection(SwitchSectionSyntax node)
|
||
|
|
{
|
||
|
|
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
ExpressionVariableBinder expressionVariableBinder = new ExpressionVariableBinder((SyntaxNode)(object)node, _enclosing);
|
||
|
|
AddToMap((SyntaxNode)(object)node, expressionVariableBinder);
|
||
|
|
Enumerator<SwitchLabelSyntax> enumerator = node.Labels.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
SwitchLabelSyntax current = enumerator.Current;
|
||
|
|
switch (current.Kind())
|
||
|
|
{
|
||
|
|
case SyntaxKind.CasePatternSwitchLabel:
|
||
|
|
{
|
||
|
|
CasePatternSwitchLabelSyntax casePatternSwitchLabelSyntax = (CasePatternSwitchLabelSyntax)current;
|
||
|
|
Visit(casePatternSwitchLabelSyntax.Pattern, expressionVariableBinder);
|
||
|
|
if (casePatternSwitchLabelSyntax.WhenClause != null)
|
||
|
|
{
|
||
|
|
Visit(casePatternSwitchLabelSyntax.WhenClause.Condition, expressionVariableBinder);
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
case SyntaxKind.CaseSwitchLabel:
|
||
|
|
{
|
||
|
|
CaseSwitchLabelSyntax caseSwitchLabelSyntax = (CaseSwitchLabelSyntax)current;
|
||
|
|
Visit(caseSwitchLabelSyntax.Value, expressionVariableBinder);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
Enumerator<StatementSyntax> enumerator2 = node.Statements.GetEnumerator();
|
||
|
|
while (enumerator2.MoveNext())
|
||
|
|
{
|
||
|
|
StatementSyntax current2 = enumerator2.Current;
|
||
|
|
Visit(current2, expressionVariableBinder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitSwitchExpression(SwitchExpressionSyntax node)
|
||
|
|
{
|
||
|
|
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_002b: 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)
|
||
|
|
SwitchExpressionBinder switchExpressionBinder = new SwitchExpressionBinder(node, _enclosing);
|
||
|
|
AddToMap((SyntaxNode)(object)node, switchExpressionBinder);
|
||
|
|
Visit(node.GoverningExpression, switchExpressionBinder);
|
||
|
|
Enumerator<SwitchExpressionArmSyntax> enumerator = node.Arms.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
SwitchExpressionArmSyntax current = enumerator.Current;
|
||
|
|
ExpressionVariableBinder armScopeBinder = new ExpressionVariableBinder((SyntaxNode)(object)current, switchExpressionBinder);
|
||
|
|
SwitchExpressionArmBinder switchExpressionArmBinder = new SwitchExpressionArmBinder(current, armScopeBinder, switchExpressionBinder);
|
||
|
|
AddToMap((SyntaxNode)(object)current, switchExpressionArmBinder);
|
||
|
|
Visit(current.Pattern, switchExpressionArmBinder);
|
||
|
|
if (current.WhenClause != null)
|
||
|
|
{
|
||
|
|
Visit(current.WhenClause, switchExpressionArmBinder);
|
||
|
|
}
|
||
|
|
Visit(current.Expression, switchExpressionArmBinder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitIfStatement(IfStatementSyntax node)
|
||
|
|
{
|
||
|
|
Visit(node.Condition, _enclosing);
|
||
|
|
VisitPossibleEmbeddedStatement(node.Statement, _enclosing);
|
||
|
|
Visit(node.Else, _enclosing);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitElseClause(ElseClauseSyntax node)
|
||
|
|
{
|
||
|
|
VisitPossibleEmbeddedStatement(node.Statement, _enclosing);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitLabeledStatement(LabeledStatementSyntax node)
|
||
|
|
{
|
||
|
|
Visit(node.Statement, _enclosing);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitTryStatement(TryStatementSyntax node)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if (node.Catches.Any())
|
||
|
|
{
|
||
|
|
Visit(node.Block, _enclosing.WithAdditionalFlags(BinderFlags.InTryBlockOfTryCatch));
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
Visit(node.Block, _enclosing);
|
||
|
|
}
|
||
|
|
Enumerator<CatchClauseSyntax> enumerator = node.Catches.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
CatchClauseSyntax current = enumerator.Current;
|
||
|
|
Visit(current, _enclosing);
|
||
|
|
}
|
||
|
|
if (node.Finally != null)
|
||
|
|
{
|
||
|
|
Visit(node.Finally, _enclosing);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitCatchClause(CatchClauseSyntax node)
|
||
|
|
{
|
||
|
|
CatchClauseBinder catchClauseBinder = new CatchClauseBinder(_enclosing, node);
|
||
|
|
AddToMap((SyntaxNode)(object)node, catchClauseBinder);
|
||
|
|
if (node.Filter != null)
|
||
|
|
{
|
||
|
|
Binder binder = catchClauseBinder.WithAdditionalFlags(BinderFlags.InCatchFilter);
|
||
|
|
AddToMap((SyntaxNode)(object)node.Filter, binder);
|
||
|
|
Visit(node.Filter, binder);
|
||
|
|
}
|
||
|
|
Visit(node.Block, catchClauseBinder);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitCatchFilterClause(CatchFilterClauseSyntax node)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)node.FilterExpression);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitFinallyClause(FinallyClauseSyntax node)
|
||
|
|
{
|
||
|
|
BinderFlags binderFlags = BinderFlags.InFinallyBlock;
|
||
|
|
if (_enclosing.Flags.Includes(BinderFlags.InCatchBlock))
|
||
|
|
{
|
||
|
|
binderFlags |= BinderFlags.InNestedFinallyBlock;
|
||
|
|
}
|
||
|
|
Visit(node.Block, _enclosing.WithAdditionalFlags(binderFlags));
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitYieldStatement(YieldStatementSyntax node)
|
||
|
|
{
|
||
|
|
if (node.Expression != null)
|
||
|
|
{
|
||
|
|
Visit(node.Expression, _enclosing);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitExpressionStatement(ExpressionStatementSyntax node)
|
||
|
|
{
|
||
|
|
Visit(node.Expression, _enclosing);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node)
|
||
|
|
{
|
||
|
|
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
VisitRankSpecifiers(node.Declaration.Type, _enclosing);
|
||
|
|
Enumerator<VariableDeclaratorSyntax> enumerator = node.Declaration.Variables.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
VariableDeclaratorSyntax current = enumerator.Current;
|
||
|
|
Visit((SyntaxNode?)(object)current);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitVariableDeclarator(VariableDeclaratorSyntax node)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)node.ArgumentList);
|
||
|
|
Visit((SyntaxNode?)(object)node.Initializer?.Value);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitReturnStatement(ReturnStatementSyntax node)
|
||
|
|
{
|
||
|
|
if (node.Expression != null)
|
||
|
|
{
|
||
|
|
Visit(node.Expression, _enclosing);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitThrowStatement(ThrowStatementSyntax node)
|
||
|
|
{
|
||
|
|
if (node.Expression != null)
|
||
|
|
{
|
||
|
|
Visit(node.Expression, _enclosing);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitBinaryExpression(BinaryExpressionSyntax node)
|
||
|
|
{
|
||
|
|
while (true)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)node.Right);
|
||
|
|
if (!(node.Left is BinaryExpressionSyntax binaryExpressionSyntax))
|
||
|
|
{
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
node = binaryExpressionSyntax;
|
||
|
|
}
|
||
|
|
Visit((SyntaxNode?)(object)node.Left);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void DefaultVisit(SyntaxNode node)
|
||
|
|
{
|
||
|
|
base.DefaultVisit(node);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void AddToMap(SyntaxNode node, Binder binder)
|
||
|
|
{
|
||
|
|
_map[node] = binder;
|
||
|
|
}
|
||
|
|
|
||
|
|
private Binder GetBinderForPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing, out CSharpSyntaxNode embeddedScopeDesignator)
|
||
|
|
{
|
||
|
|
switch (statement.Kind())
|
||
|
|
{
|
||
|
|
case SyntaxKind.LocalDeclarationStatement:
|
||
|
|
case SyntaxKind.ExpressionStatement:
|
||
|
|
case SyntaxKind.LabeledStatement:
|
||
|
|
case SyntaxKind.ReturnStatement:
|
||
|
|
case SyntaxKind.YieldReturnStatement:
|
||
|
|
case SyntaxKind.ThrowStatement:
|
||
|
|
case SyntaxKind.LockStatement:
|
||
|
|
case SyntaxKind.IfStatement:
|
||
|
|
case SyntaxKind.LocalFunctionStatement:
|
||
|
|
embeddedScopeDesignator = statement;
|
||
|
|
return new EmbeddedStatementBinder(enclosing, statement);
|
||
|
|
case SyntaxKind.SwitchStatement:
|
||
|
|
{
|
||
|
|
SwitchStatementSyntax switchStatementSyntax = (SwitchStatementSyntax)statement;
|
||
|
|
embeddedScopeDesignator = switchStatementSyntax.Expression;
|
||
|
|
return new ExpressionVariableBinder((SyntaxNode)(object)switchStatementSyntax.Expression, enclosing);
|
||
|
|
}
|
||
|
|
default:
|
||
|
|
embeddedScopeDesignator = null;
|
||
|
|
return enclosing;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void VisitPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing)
|
||
|
|
{
|
||
|
|
if (statement != null)
|
||
|
|
{
|
||
|
|
enclosing = GetBinderForPossibleEmbeddedStatement(statement, enclosing, out var embeddedScopeDesignator);
|
||
|
|
if (embeddedScopeDesignator != null)
|
||
|
|
{
|
||
|
|
AddToMap((SyntaxNode)(object)embeddedScopeDesignator, enclosing);
|
||
|
|
}
|
||
|
|
Visit(statement, enclosing);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitQueryExpression(QueryExpressionSyntax node)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)node.FromClause.Expression);
|
||
|
|
Visit((SyntaxNode?)(object)node.Body);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void VisitQueryBody(QueryBodySyntax node)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
Enumerator<QueryClauseSyntax> enumerator = node.Clauses.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
QueryClauseSyntax current = enumerator.Current;
|
||
|
|
if (current.Kind() == SyntaxKind.JoinClause)
|
||
|
|
{
|
||
|
|
Visit((SyntaxNode?)(object)((JoinClauseSyntax)current).InExpression);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
Visit((SyntaxNode?)(object)node.Continuation);
|
||
|
|
}
|
||
|
|
}
|