555 lines
23 KiB
C#
555 lines
23 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections.Immutable;
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
|
using Microsoft.CodeAnalysis.Text;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
|
|
|
internal class LocalScopeBinder : Binder
|
|
{
|
|
protected const int DefaultLocalSymbolArrayCapacity = 16;
|
|
|
|
private ImmutableArray<LocalSymbol> _locals;
|
|
|
|
private ImmutableArray<LocalFunctionSymbol> _localFunctions;
|
|
|
|
private ImmutableArray<LabelSymbol> _labels;
|
|
|
|
private SmallDictionary<string, LocalSymbol> _lazyLocalsMap;
|
|
|
|
private SmallDictionary<string, LocalFunctionSymbol> _lazyLocalFunctionsMap;
|
|
|
|
private SmallDictionary<string, LabelSymbol> _lazyLabelsMap;
|
|
|
|
internal sealed override ImmutableArray<LocalSymbol> Locals
|
|
{
|
|
get
|
|
{
|
|
if (_locals.IsDefault)
|
|
{
|
|
ImmutableInterlocked.InterlockedCompareExchange(ref _locals, BuildLocals(), default(ImmutableArray<LocalSymbol>));
|
|
}
|
|
return _locals;
|
|
}
|
|
}
|
|
|
|
internal sealed override ImmutableArray<LocalFunctionSymbol> LocalFunctions
|
|
{
|
|
get
|
|
{
|
|
if (_localFunctions.IsDefault)
|
|
{
|
|
ImmutableInterlocked.InterlockedCompareExchange(ref _localFunctions, BuildLocalFunctions(), default(ImmutableArray<LocalFunctionSymbol>));
|
|
}
|
|
return _localFunctions;
|
|
}
|
|
}
|
|
|
|
internal sealed override ImmutableArray<LabelSymbol> Labels
|
|
{
|
|
get
|
|
{
|
|
if (_labels.IsDefault)
|
|
{
|
|
ImmutableInterlocked.InterlockedCompareExchange(ref _labels, BuildLabels(), default(ImmutableArray<LabelSymbol>));
|
|
}
|
|
return _labels;
|
|
}
|
|
}
|
|
|
|
private SmallDictionary<string, LocalSymbol> LocalsMap
|
|
{
|
|
get
|
|
{
|
|
if (_lazyLocalsMap == null && Locals.Length > 0)
|
|
{
|
|
_lazyLocalsMap = BuildMap(Locals);
|
|
}
|
|
return _lazyLocalsMap;
|
|
}
|
|
}
|
|
|
|
private SmallDictionary<string, LocalFunctionSymbol> LocalFunctionsMap
|
|
{
|
|
get
|
|
{
|
|
if (_lazyLocalFunctionsMap == null && LocalFunctions.Length > 0)
|
|
{
|
|
_lazyLocalFunctionsMap = BuildMap(LocalFunctions);
|
|
}
|
|
return _lazyLocalFunctionsMap;
|
|
}
|
|
}
|
|
|
|
private SmallDictionary<string, LabelSymbol> LabelsMap
|
|
{
|
|
get
|
|
{
|
|
if (_lazyLabelsMap == null && Labels.Length > 0)
|
|
{
|
|
_lazyLabelsMap = BuildMap(Labels);
|
|
}
|
|
return _lazyLabelsMap;
|
|
}
|
|
}
|
|
|
|
internal LocalScopeBinder(Binder next)
|
|
: this(next, next.Flags)
|
|
{
|
|
}
|
|
|
|
internal LocalScopeBinder(Binder next, BinderFlags flags)
|
|
: base(next, flags)
|
|
{
|
|
}
|
|
|
|
protected virtual ImmutableArray<LocalSymbol> BuildLocals()
|
|
{
|
|
return ImmutableArray<LocalSymbol>.Empty;
|
|
}
|
|
|
|
protected virtual ImmutableArray<LocalFunctionSymbol> BuildLocalFunctions()
|
|
{
|
|
return ImmutableArray<LocalFunctionSymbol>.Empty;
|
|
}
|
|
|
|
protected virtual ImmutableArray<LabelSymbol> BuildLabels()
|
|
{
|
|
return ImmutableArray<LabelSymbol>.Empty;
|
|
}
|
|
|
|
private static SmallDictionary<string, TSymbol> BuildMap<TSymbol>(ImmutableArray<TSymbol> array) where TSymbol : Symbol
|
|
{
|
|
SmallDictionary<string, TSymbol> val = new SmallDictionary<string, TSymbol>();
|
|
for (int num = array.Length - 1; num >= 0; num--)
|
|
{
|
|
TSymbol val2 = array[num];
|
|
val[val2.Name] = val2;
|
|
}
|
|
return val;
|
|
}
|
|
|
|
protected ImmutableArray<LocalSymbol> BuildLocals(SyntaxList<StatementSyntax> statements, Binder enclosingBinder)
|
|
{
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
ArrayBuilder<LocalSymbol> instance = ArrayBuilder<LocalSymbol>.GetInstance(16);
|
|
Enumerator<StatementSyntax> enumerator = statements.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
StatementSyntax current = enumerator.Current;
|
|
BuildLocals(enclosingBinder, current, instance);
|
|
}
|
|
return instance.ToImmutableAndFree();
|
|
}
|
|
|
|
internal void BuildLocals(Binder enclosingBinder, StatementSyntax statement, ArrayBuilder<LocalSymbol> locals)
|
|
{
|
|
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
|
|
StatementSyntax statementSyntax = statement;
|
|
while (statementSyntax.Kind() == SyntaxKind.LabeledStatement)
|
|
{
|
|
statementSyntax = ((LabeledStatementSyntax)statementSyntax).Statement;
|
|
}
|
|
switch (statementSyntax.Kind())
|
|
{
|
|
case SyntaxKind.LocalDeclarationStatement:
|
|
{
|
|
Binder binder2 = enclosingBinder.GetBinder((SyntaxNode)(object)statementSyntax) ?? enclosingBinder;
|
|
LocalDeclarationStatementSyntax localDeclarationStatementSyntax = (LocalDeclarationStatementSyntax)statementSyntax;
|
|
localDeclarationStatementSyntax.Declaration.Type.VisitRankSpecifiers(delegate(ArrayRankSpecifierSyntax rankSpecifier, (LocalScopeBinder localScopeBinder, ArrayBuilder<LocalSymbol> locals, Binder localDeclarationBinder) 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> enumerator5 = rankSpecifier.Sizes.GetEnumerator();
|
|
while (enumerator5.MoveNext())
|
|
{
|
|
findExpressionVariablesInRankSpecifier(enumerator5.Current, args);
|
|
}
|
|
}, (this, locals, binder2));
|
|
LocalDeclarationKind kind = (localDeclarationStatementSyntax.IsConst ? LocalDeclarationKind.Constant : ((!(localDeclarationStatementSyntax.UsingKeyword != default(SyntaxToken))) ? LocalDeclarationKind.RegularVariable : LocalDeclarationKind.UsingVariable));
|
|
Enumerator<VariableDeclaratorSyntax> enumerator4 = localDeclarationStatementSyntax.Declaration.Variables.GetEnumerator();
|
|
while (enumerator4.MoveNext())
|
|
{
|
|
VariableDeclaratorSyntax current = enumerator4.Current;
|
|
SourceLocalSymbol sourceLocalSymbol = MakeLocal(localDeclarationStatementSyntax.Declaration, current, kind, allowScoped: true, binder2);
|
|
locals.Add((LocalSymbol)sourceLocalSymbol);
|
|
ExpressionVariableFinder.FindExpressionVariables(this, locals, current, binder2);
|
|
}
|
|
break;
|
|
}
|
|
case SyntaxKind.LocalFunctionStatement:
|
|
{
|
|
Binder item = enclosingBinder.GetBinder((SyntaxNode)(object)statementSyntax) ?? enclosingBinder;
|
|
LocalFunctionStatementSyntax localFunctionStatementSyntax = (LocalFunctionStatementSyntax)statementSyntax;
|
|
Enumerator<ParameterSyntax> enumerator = localFunctionStatementSyntax.ParameterList.Parameters.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
enumerator.Current.Type?.VisitRankSpecifiers(delegate(ArrayRankSpecifierSyntax rankSpecifier, (LocalScopeBinder localScopeBinder, ArrayBuilder<LocalSymbol> locals, Binder localDeclarationBinder) 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> enumerator5 = rankSpecifier.Sizes.GetEnumerator();
|
|
while (enumerator5.MoveNext())
|
|
{
|
|
findExpressionVariablesInRankSpecifier(enumerator5.Current, args);
|
|
}
|
|
}, (this, locals, item));
|
|
}
|
|
Enumerator<TypeParameterConstraintClauseSyntax> enumerator2 = localFunctionStatementSyntax.ConstraintClauses.GetEnumerator();
|
|
while (enumerator2.MoveNext())
|
|
{
|
|
Enumerator<TypeParameterConstraintSyntax> enumerator3 = enumerator2.Current.Constraints.GetEnumerator();
|
|
while (enumerator3.MoveNext())
|
|
{
|
|
if (!(enumerator3.Current is TypeConstraintSyntax typeConstraintSyntax))
|
|
{
|
|
continue;
|
|
}
|
|
typeConstraintSyntax.Type.VisitRankSpecifiers(delegate(ArrayRankSpecifierSyntax rankSpecifier, (LocalScopeBinder localScopeBinder, ArrayBuilder<LocalSymbol> locals, Binder localDeclarationBinder) 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> enumerator5 = rankSpecifier.Sizes.GetEnumerator();
|
|
while (enumerator5.MoveNext())
|
|
{
|
|
findExpressionVariablesInRankSpecifier(enumerator5.Current, args);
|
|
}
|
|
}, (this, locals, item));
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case SyntaxKind.ExpressionStatement:
|
|
case SyntaxKind.GotoCaseStatement:
|
|
case SyntaxKind.ReturnStatement:
|
|
case SyntaxKind.YieldReturnStatement:
|
|
case SyntaxKind.ThrowStatement:
|
|
case SyntaxKind.IfStatement:
|
|
ExpressionVariableFinder.FindExpressionVariables(this, locals, statementSyntax, enclosingBinder.GetBinder((SyntaxNode)(object)statementSyntax) ?? enclosingBinder);
|
|
break;
|
|
case SyntaxKind.SwitchStatement:
|
|
{
|
|
SwitchStatementSyntax switchStatementSyntax = (SwitchStatementSyntax)statementSyntax;
|
|
ExpressionVariableFinder.FindExpressionVariables(this, locals, statementSyntax, enclosingBinder.GetBinder((SyntaxNode)(object)switchStatementSyntax.Expression) ?? enclosingBinder);
|
|
break;
|
|
}
|
|
case SyntaxKind.LockStatement:
|
|
{
|
|
Binder binder = enclosingBinder.GetBinder((SyntaxNode)(object)statementSyntax);
|
|
ExpressionVariableFinder.FindExpressionVariables(this, locals, statementSyntax, binder);
|
|
break;
|
|
}
|
|
}
|
|
static void findExpressionVariablesInRankSpecifier(ExpressionSyntax expression, (LocalScopeBinder localScopeBinder, ArrayBuilder<LocalSymbol> locals, Binder localDeclarationBinder) args)
|
|
{
|
|
if (expression.Kind() != SyntaxKind.OmittedArraySizeExpression)
|
|
{
|
|
ExpressionVariableFinder.FindExpressionVariables(args.localScopeBinder, args.locals, expression, args.localDeclarationBinder);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected ImmutableArray<LocalFunctionSymbol> BuildLocalFunctions(SyntaxList<StatementSyntax> statements)
|
|
{
|
|
//IL_0004: 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)
|
|
ArrayBuilder<LocalFunctionSymbol> locals = null;
|
|
Enumerator<StatementSyntax> enumerator = statements.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
StatementSyntax current = enumerator.Current;
|
|
BuildLocalFunctions(current, ref locals);
|
|
}
|
|
return locals?.ToImmutableAndFree() ?? ImmutableArray<LocalFunctionSymbol>.Empty;
|
|
}
|
|
|
|
internal void BuildLocalFunctions(StatementSyntax statement, ref ArrayBuilder<LocalFunctionSymbol> locals)
|
|
{
|
|
StatementSyntax statementSyntax = statement;
|
|
while (statementSyntax.Kind() == SyntaxKind.LabeledStatement)
|
|
{
|
|
statementSyntax = ((LabeledStatementSyntax)statementSyntax).Statement;
|
|
}
|
|
if (statementSyntax.Kind() == SyntaxKind.LocalFunctionStatement)
|
|
{
|
|
LocalFunctionStatementSyntax declaration = (LocalFunctionStatementSyntax)statementSyntax;
|
|
if (locals == null)
|
|
{
|
|
locals = ArrayBuilder<LocalFunctionSymbol>.GetInstance();
|
|
}
|
|
LocalFunctionSymbol localFunctionSymbol = MakeLocalFunction(declaration);
|
|
locals.Add(localFunctionSymbol);
|
|
}
|
|
}
|
|
|
|
protected SourceLocalSymbol MakeLocal(VariableDeclarationSyntax declaration, VariableDeclaratorSyntax declarator, LocalDeclarationKind kind, bool allowScoped, Binder initializerBinderOpt = null)
|
|
{
|
|
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
|
|
return SourceLocalSymbol.MakeLocal(ContainingMemberOrLambda, this, allowRefKind: true, allowScoped, declaration.Type, declarator.Identifier, kind, declarator.Initializer, initializerBinderOpt);
|
|
}
|
|
|
|
protected LocalFunctionSymbol MakeLocalFunction(LocalFunctionStatementSyntax declaration)
|
|
{
|
|
return new LocalFunctionSymbol(this, ContainingMemberOrLambda, declaration);
|
|
}
|
|
|
|
protected void BuildLabels(SyntaxList<StatementSyntax> statements, ref ArrayBuilder<LabelSymbol> labels)
|
|
{
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
|
|
MethodSymbol containingMethod = (MethodSymbol)ContainingMemberOrLambda;
|
|
Enumerator<StatementSyntax> enumerator = statements.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
StatementSyntax current = enumerator.Current;
|
|
BuildLabels(containingMethod, current, ref labels);
|
|
}
|
|
}
|
|
|
|
internal static void BuildLabels(MethodSymbol containingMethod, StatementSyntax statement, ref ArrayBuilder<LabelSymbol> labels)
|
|
{
|
|
//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)
|
|
while (statement.Kind() == SyntaxKind.LabeledStatement)
|
|
{
|
|
LabeledStatementSyntax labeledStatementSyntax = (LabeledStatementSyntax)statement;
|
|
if (labels == null)
|
|
{
|
|
labels = ArrayBuilder<LabelSymbol>.GetInstance();
|
|
}
|
|
SourceLabelSymbol sourceLabelSymbol = new SourceLabelSymbol(containingMethod, SyntaxNodeOrToken.op_Implicit(labeledStatementSyntax.Identifier));
|
|
labels.Add((LabelSymbol)sourceLabelSymbol);
|
|
statement = labeledStatementSyntax.Statement;
|
|
}
|
|
}
|
|
|
|
protected override SourceLocalSymbol LookupLocal(SyntaxToken nameToken)
|
|
{
|
|
//IL_006d: 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_0026: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
|
|
LocalSymbol localSymbol = null;
|
|
if (LocalsMap != null && LocalsMap.TryGetValue(((SyntaxToken)(ref nameToken)).ValueText, ref localSymbol))
|
|
{
|
|
if (localSymbol.IdentifierToken == nameToken)
|
|
{
|
|
return (SourceLocalSymbol)localSymbol;
|
|
}
|
|
ImmutableArray<LocalSymbol>.Enumerator enumerator = Locals.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
LocalSymbol current = enumerator.Current;
|
|
if (current.IdentifierToken == nameToken)
|
|
{
|
|
return (SourceLocalSymbol)current;
|
|
}
|
|
}
|
|
}
|
|
return base.LookupLocal(nameToken);
|
|
}
|
|
|
|
protected override LocalFunctionSymbol LookupLocalFunction(SyntaxToken nameToken)
|
|
{
|
|
//IL_0063: 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_0026: 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)
|
|
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
|
|
LocalFunctionSymbol localFunctionSymbol = null;
|
|
if (LocalFunctionsMap != null && LocalFunctionsMap.TryGetValue(((SyntaxToken)(ref nameToken)).ValueText, ref localFunctionSymbol))
|
|
{
|
|
if (localFunctionSymbol.NameToken == nameToken)
|
|
{
|
|
return localFunctionSymbol;
|
|
}
|
|
ImmutableArray<LocalFunctionSymbol>.Enumerator enumerator = LocalFunctions.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
LocalFunctionSymbol current = enumerator.Current;
|
|
if (current.NameToken == nameToken)
|
|
{
|
|
return current;
|
|
}
|
|
}
|
|
}
|
|
return base.LookupLocalFunction(nameToken);
|
|
}
|
|
|
|
internal override void LookupSymbolsInSingleBinder(LookupResult result, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
|
|
{
|
|
if ((options & LookupOptions.LabelsOnly) != LookupOptions.Default)
|
|
{
|
|
SmallDictionary<string, LabelSymbol> labelsMap = LabelsMap;
|
|
LabelSymbol symbol = default(LabelSymbol);
|
|
if (labelsMap != null && labelsMap.TryGetValue(name, ref symbol))
|
|
{
|
|
result.MergeEqual(LookupResult.Good(symbol));
|
|
}
|
|
return;
|
|
}
|
|
SmallDictionary<string, LocalSymbol> localsMap = LocalsMap;
|
|
LocalSymbol symbol2 = default(LocalSymbol);
|
|
if (localsMap != null && (options & LookupOptions.NamespaceAliasesOnly) == 0 && localsMap.TryGetValue(name, ref symbol2))
|
|
{
|
|
result.MergeEqual(originalBinder.CheckViability(symbol2, arity, options, null, diagnose, ref useSiteInfo, basesBeingResolved));
|
|
}
|
|
SmallDictionary<string, LocalFunctionSymbol> localFunctionsMap = LocalFunctionsMap;
|
|
LocalFunctionSymbol symbol3 = default(LocalFunctionSymbol);
|
|
if (localFunctionsMap != null && options.CanConsiderLocals() && localFunctionsMap.TryGetValue(name, ref symbol3))
|
|
{
|
|
result.MergeEqual(originalBinder.CheckViability(symbol3, arity, options, null, diagnose, ref useSiteInfo, basesBeingResolved));
|
|
}
|
|
}
|
|
|
|
internal override void AddLookupSymbolsInfoInSingleBinder(LookupSymbolsInfo result, LookupOptions options, Binder originalBinder)
|
|
{
|
|
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0063: 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)
|
|
if ((options & LookupOptions.LabelsOnly) != LookupOptions.Default && LabelsMap != null)
|
|
{
|
|
Enumerator<string, LabelSymbol> enumerator = LabelsMap.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
KeyValuePair<string, LabelSymbol> current = enumerator.Current;
|
|
((AbstractLookupSymbolsInfo<Symbol>)result).AddSymbol((Symbol)current.Value, current.Key, 0);
|
|
}
|
|
}
|
|
if (!options.CanConsiderLocals())
|
|
{
|
|
return;
|
|
}
|
|
if (LocalsMap != null)
|
|
{
|
|
Enumerator<string, LocalSymbol> enumerator2 = LocalsMap.GetEnumerator();
|
|
while (enumerator2.MoveNext())
|
|
{
|
|
KeyValuePair<string, LocalSymbol> current2 = enumerator2.Current;
|
|
if (originalBinder.CanAddLookupSymbolInfo(current2.Value, options, result, null))
|
|
{
|
|
((AbstractLookupSymbolsInfo<Symbol>)result).AddSymbol((Symbol)current2.Value, current2.Key, 0);
|
|
}
|
|
}
|
|
}
|
|
if (LocalFunctionsMap == null)
|
|
{
|
|
return;
|
|
}
|
|
Enumerator<string, LocalFunctionSymbol> enumerator3 = LocalFunctionsMap.GetEnumerator();
|
|
while (enumerator3.MoveNext())
|
|
{
|
|
KeyValuePair<string, LocalFunctionSymbol> current3 = enumerator3.Current;
|
|
if (originalBinder.CanAddLookupSymbolInfo(current3.Value, options, result, null))
|
|
{
|
|
((AbstractLookupSymbolsInfo<Symbol>)result).AddSymbol((Symbol)current3.Value, current3.Key, 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool ReportConflictWithLocal(Symbol local, Symbol newSymbol, string name, Location newLocation, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000d: 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)
|
|
//IL_0010: Invalid comparison between Unknown and I4
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0017: Invalid comparison between Unknown and I4
|
|
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0034: Invalid comparison between Unknown and I4
|
|
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0093: Invalid comparison between Unknown and I4
|
|
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0095: 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)
|
|
//IL_00b2: Expected I4, but got Unknown
|
|
SymbolKind val = (SymbolKind)(((object)newSymbol == null) ? 13 : ((int)newSymbol.Kind));
|
|
if ((int)val == 4)
|
|
{
|
|
return true;
|
|
}
|
|
if ((0u | (((int)val == 8 && Locals.Contains((LocalSymbol)newSymbol)) ? 1u : 0u) | (((int)val == 9 && LocalFunctions.Contains((LocalFunctionSymbol)newSymbol)) ? 1u : 0u)) != 0)
|
|
{
|
|
TextSpan sourceSpan = newLocation.SourceSpan;
|
|
int start = ((TextSpan)(ref sourceSpan)).Start;
|
|
sourceSpan = local.GetFirstLocation().SourceSpan;
|
|
if (start >= ((TextSpan)(ref sourceSpan)).Start)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_LocalDuplicate, newLocation, name);
|
|
return true;
|
|
}
|
|
}
|
|
if (val - 8 > 1)
|
|
{
|
|
switch (val - 13)
|
|
{
|
|
case 0:
|
|
case 4:
|
|
break;
|
|
case 3:
|
|
diagnostics.Add(ErrorCode.ERR_QueryRangeVariableOverrides, newLocation, name);
|
|
return true;
|
|
default:
|
|
diagnostics.Add(ErrorCode.ERR_InternalError, newLocation);
|
|
return false;
|
|
}
|
|
}
|
|
diagnostics.Add(ErrorCode.ERR_LocalIllegallyOverrides, newLocation, name);
|
|
return true;
|
|
}
|
|
|
|
internal virtual bool EnsureSingleDefinition(Symbol symbol, string name, Location location, BindingDiagnosticBag diagnostics)
|
|
{
|
|
LocalSymbol localSymbol = null;
|
|
LocalFunctionSymbol localFunctionSymbol = null;
|
|
SmallDictionary<string, LocalSymbol> localsMap = LocalsMap;
|
|
SmallDictionary<string, LocalFunctionSymbol> localFunctionsMap = LocalFunctionsMap;
|
|
if ((localsMap != null && localsMap.TryGetValue(name, ref localSymbol)) || (localFunctionsMap != null && localFunctionsMap.TryGetValue(name, ref localFunctionSymbol)))
|
|
{
|
|
Symbol symbol2 = (Symbol)(((object)localSymbol) ?? ((object)localFunctionSymbol));
|
|
if (symbol == symbol2)
|
|
{
|
|
return false;
|
|
}
|
|
return ReportConflictWithLocal(symbol2, symbol, name, location, diagnostics);
|
|
}
|
|
return false;
|
|
}
|
|
}
|