using System.Collections.Immutable; using System.Diagnostics; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.Operations; namespace Microsoft.CodeAnalysis.CSharp; internal sealed class BoundFunctionPointerInvocation : BoundExpression, IBoundInvalidNode { public FunctionPointerTypeSymbol FunctionPointer => (FunctionPointerTypeSymbol)InvokedExpression.Type; ImmutableArray IBoundInvalidNode.InvalidNodeChildren => CSharpOperationFactory.CreateInvalidChildrenFromArgumentsExpression(InvokedExpression, Arguments); protected override ImmutableArray Children => StaticCast.From(((IBoundInvalidNode)this).InvalidNodeChildren); public new TypeSymbol Type => base.Type; public BoundExpression InvokedExpression { get; } public ImmutableArray Arguments { get; } public ImmutableArray ArgumentRefKindsOpt { get; } public override LookupResultKind ResultKind { get; } public BoundFunctionPointerInvocation(SyntaxNode syntax, BoundExpression invokedExpression, ImmutableArray arguments, ImmutableArray argumentRefKindsOpt, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false) : base(BoundKind.FunctionPointerInvocation, syntax, type, hasErrors || invokedExpression.HasErrors() || arguments.HasErrors()) { InvokedExpression = invokedExpression; Arguments = arguments; ArgumentRefKindsOpt = argumentRefKindsOpt; ResultKind = resultKind; } [DebuggerStepThrough] public override BoundNode? Accept(BoundTreeVisitor visitor) { return visitor.VisitFunctionPointerInvocation(this); } public BoundFunctionPointerInvocation Update(BoundExpression invokedExpression, ImmutableArray arguments, ImmutableArray argumentRefKindsOpt, LookupResultKind resultKind, TypeSymbol type) { if (invokedExpression != InvokedExpression || arguments != Arguments || argumentRefKindsOpt != ArgumentRefKindsOpt || resultKind != ResultKind || !TypeSymbol.Equals(type, Type, (TypeCompareKind)0)) { BoundFunctionPointerInvocation boundFunctionPointerInvocation = new BoundFunctionPointerInvocation(Syntax, invokedExpression, arguments, argumentRefKindsOpt, resultKind, type, base.HasErrors); boundFunctionPointerInvocation.CopyAttributes(this); return boundFunctionPointerInvocation; } return this; } }