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

179 lines
12 KiB
C#

using System;
using System.Collections.Immutable;
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.Operations;
using Microsoft.CodeAnalysis.PooledObjects;
namespace Microsoft.CodeAnalysis.CSharp;
internal sealed class BoundCall : BoundExpression, IBoundInvalidNode
{
public override Symbol ExpressionSymbol => Method;
ImmutableArray<BoundNode> IBoundInvalidNode.InvalidNodeChildren => CSharpOperationFactory.CreateInvalidChildrenFromArgumentsExpression(ReceiverOpt, Arguments);
public new TypeSymbol Type => base.Type;
public BoundExpression? ReceiverOpt { get; }
public ThreeState InitialBindingReceiverIsSubjectToCloning { get; }
public MethodSymbol Method { get; }
public ImmutableArray<BoundExpression> Arguments { get; }
public ImmutableArray<string> ArgumentNamesOpt { get; }
public ImmutableArray<RefKind> ArgumentRefKindsOpt { get; }
public bool IsDelegateCall { get; }
public bool Expanded { get; }
public bool InvokedAsExtensionMethod { get; }
public ImmutableArray<int> ArgsToParamsOpt { get; }
public BitVector DefaultArguments { get; }
public override LookupResultKind ResultKind { get; }
public ImmutableArray<MethodSymbol> OriginalMethodsOpt { get; }
public BoundCall(SyntaxNode syntax, BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method, ImmutableArray<BoundExpression> arguments, ImmutableArray<string> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, bool isDelegateCall, bool expanded, bool invokedAsExtensionMethod, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false)
: this(syntax, receiverOpt, initialBindingReceiverIsSubjectToCloning, method, arguments, argumentNamesOpt, argumentRefKindsOpt, isDelegateCall, expanded, invokedAsExtensionMethod, argsToParamsOpt, defaultArguments, resultKind, default(ImmutableArray<MethodSymbol>), type, hasErrors)
{
}//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
public BoundCall Update(BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method, ImmutableArray<BoundExpression> arguments, ImmutableArray<string> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, bool isDelegateCall, bool expanded, bool invokedAsExtensionMethod, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, LookupResultKind resultKind, TypeSymbol type)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
return Update(receiverOpt, initialBindingReceiverIsSubjectToCloning, method, arguments, argumentNamesOpt, argumentRefKindsOpt, isDelegateCall, expanded, invokedAsExtensionMethod, argsToParamsOpt, defaultArguments, resultKind, OriginalMethodsOpt, type);
}
public static BoundCall ErrorCall(SyntaxNode node, BoundExpression receiverOpt, MethodSymbol method, ImmutableArray<BoundExpression> arguments, ImmutableArray<string> namedArguments, ImmutableArray<RefKind> refKinds, bool isDelegateCall, bool invokedAsExtensionMethod, ImmutableArray<MethodSymbol> originalMethods, LookupResultKind resultKind, Binder binder)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
if (!originalMethods.IsEmpty)
{
resultKind = resultKind.WorseResultKind(LookupResultKind.OverloadResolutionFailure);
}
return new BoundCall(node, binder.BindToTypeForErrorRecovery(receiverOpt), (ThreeState)1, method, ImmutableArrayExtensions.SelectAsArray<BoundExpression, Binder, BoundExpression>(arguments, (Func<BoundExpression, Binder, BoundExpression>)((BoundExpression e, Binder binder2) => binder2.BindToTypeForErrorRecovery(e)), binder), namedArguments, refKinds, isDelegateCall, expanded: false, invokedAsExtensionMethod, default(ImmutableArray<int>), default(BitVector), resultKind, originalMethods, method.ReturnType, hasErrors: true);
}
public BoundCall Update(ImmutableArray<BoundExpression> arguments)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
return Update(ReceiverOpt, InitialBindingReceiverIsSubjectToCloning, Method, arguments, ArgumentNamesOpt, ArgumentRefKindsOpt, IsDelegateCall, Expanded, InvokedAsExtensionMethod, ArgsToParamsOpt, DefaultArguments, ResultKind, OriginalMethodsOpt, Type);
}
public BoundCall Update(BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method, ImmutableArray<BoundExpression> arguments)
{
//IL_0002: 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)
return Update(receiverOpt, initialBindingReceiverIsSubjectToCloning, method, arguments, ArgumentNamesOpt, ArgumentRefKindsOpt, IsDelegateCall, Expanded, InvokedAsExtensionMethod, ArgsToParamsOpt, DefaultArguments, ResultKind, OriginalMethodsOpt, Type);
}
public static BoundCall Synthesized(SyntaxNode syntax, BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return Synthesized(syntax, receiverOpt, initialBindingReceiverIsSubjectToCloning, method, ImmutableArray<BoundExpression>.Empty);
}
public static BoundCall Synthesized(SyntaxNode syntax, BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method, BoundExpression arg0)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return Synthesized(syntax, receiverOpt, initialBindingReceiverIsSubjectToCloning, method, ImmutableArray.Create(arg0));
}
public static BoundCall Synthesized(SyntaxNode syntax, BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method, BoundExpression arg0, BoundExpression arg1)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return Synthesized(syntax, receiverOpt, initialBindingReceiverIsSubjectToCloning, method, ImmutableArray.Create(arg0, arg1));
}
public static BoundCall Synthesized(SyntaxNode syntax, BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method, ImmutableArray<BoundExpression> arguments, ImmutableArray<RefKind> argumentRefKindsOpt = default(ImmutableArray<RefKind>))
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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)
argumentRefKindsOpt = (argumentRefKindsOpt.IsDefault ? getArgumentRefKinds(method) : argumentRefKindsOpt);
return new BoundCall(syntax, receiverOpt, initialBindingReceiverIsSubjectToCloning, method, arguments, default(ImmutableArray<string>), argumentRefKindsOpt, isDelegateCall: false, expanded: false, invokedAsExtensionMethod: false, default(ImmutableArray<int>), default(BitVector), LookupResultKind.Viable, default(ImmutableArray<MethodSymbol>), method.ReturnType, method.OriginalDefinition is ErrorMethodSymbol)
{
WasCompilerGenerated = true
};
static ImmutableArray<RefKind> getArgumentRefKinds(MethodSymbol methodSymbol)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_003c: Invalid comparison between Unknown and I4
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
ImmutableArray<RefKind> parameterRefKinds = methodSymbol.ParameterRefKinds;
if (!parameterRefKinds.IsDefaultOrEmpty && parameterRefKinds.Contains((RefKind)4))
{
ArrayBuilder<RefKind> instance = ArrayBuilder<RefKind>.GetInstance(parameterRefKinds.Length);
ImmutableArray<RefKind>.Enumerator enumerator = parameterRefKinds.GetEnumerator();
while (enumerator.MoveNext())
{
RefKind current = enumerator.Current;
instance.Add((RefKind)(((int)current == 4) ? 3 : ((int)current)));
}
return instance.ToImmutableAndFree();
}
return parameterRefKinds;
}
}
public BoundCall(SyntaxNode syntax, BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method, ImmutableArray<BoundExpression> arguments, ImmutableArray<string> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, bool isDelegateCall, bool expanded, bool invokedAsExtensionMethod, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalMethodsOpt, TypeSymbol type, bool hasErrors = false)
: base(BoundKind.Call, syntax, type, hasErrors || receiverOpt.HasErrors() || arguments.HasErrors())
{
//IL_002c: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
ReceiverOpt = receiverOpt;
InitialBindingReceiverIsSubjectToCloning = initialBindingReceiverIsSubjectToCloning;
Method = method;
Arguments = arguments;
ArgumentNamesOpt = argumentNamesOpt;
ArgumentRefKindsOpt = argumentRefKindsOpt;
IsDelegateCall = isDelegateCall;
Expanded = expanded;
InvokedAsExtensionMethod = invokedAsExtensionMethod;
ArgsToParamsOpt = argsToParamsOpt;
DefaultArguments = defaultArguments;
ResultKind = resultKind;
OriginalMethodsOpt = originalMethodsOpt;
}
[DebuggerStepThrough]
public override BoundNode? Accept(BoundTreeVisitor visitor)
{
return visitor.VisitCall(this);
}
public BoundCall Update(BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method, ImmutableArray<BoundExpression> arguments, ImmutableArray<string> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, bool isDelegateCall, bool expanded, bool invokedAsExtensionMethod, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalMethodsOpt, TypeSymbol type)
{
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
if (receiverOpt != ReceiverOpt || initialBindingReceiverIsSubjectToCloning != InitialBindingReceiverIsSubjectToCloning || !SymbolEqualityComparer.ConsiderEverything.Equals(method, Method) || arguments != Arguments || argumentNamesOpt != ArgumentNamesOpt || argumentRefKindsOpt != ArgumentRefKindsOpt || isDelegateCall != IsDelegateCall || expanded != Expanded || invokedAsExtensionMethod != InvokedAsExtensionMethod || argsToParamsOpt != ArgsToParamsOpt || defaultArguments != DefaultArguments || resultKind != ResultKind || originalMethodsOpt != OriginalMethodsOpt || !TypeSymbol.Equals(type, Type, (TypeCompareKind)0))
{
BoundCall boundCall = new BoundCall(Syntax, receiverOpt, initialBindingReceiverIsSubjectToCloning, method, arguments, argumentNamesOpt, argumentRefKindsOpt, isDelegateCall, expanded, invokedAsExtensionMethod, argsToParamsOpt, defaultArguments, resultKind, originalMethodsOpt, type, base.HasErrors);
boundCall.CopyAttributes(this);
return boundCall;
}
return this;
}
}