Skip to content

API for IFunctionPointerInvocationOperation #57195

@bernd5

Description

@bernd5

Background and Motivation

As described in #48082 the Operations-API is not usable today for function pointer invocations. This should be changed.

Proposed API

namespace Microsoft.CodeAnalysis.Operations
{
+    public interface IFunctionPointerInvocationOperation : IOperation
+    {
+        IOperation InvokedPointer { get; }
+        ImmutableArray<IArgumentOperation> Arguments { get; }
+    }
}

namespace Microsoft.CodeAnalysis
{
    public enum OperationKind
    {
+        FunctionPointerInvocation = 0x72,
    }
}

Usage Examples

See #48082

Alternative Designs

It would be possible to reuse the IInvocationOperation to represent the function pointer operation. But the usage of this interface has some drawbacks.
For example IsVirtual does not apply to function pointer invocations. In addition we can not model the invoked pointer appropriate.
Therefore we propose the new API.

We could add a property to the interface for retrieving the function pointer method signature as well, rather than requiring the user to do ((IFunctionPointerTypeSymbol)invPointerOperation.InvokedPointer.Type).Signature to get access to the pointer type signature. In addition we could add a property for the function pointer type. But both features could be implemented via extension method, too.

Risks

No knwon risk.

Metadata

Metadata

Assignees

Labels

Area-CompilersConcept-APIThis issue involves adding, removing, clarification, or modification of an API.Feature Requestapi-approvedAPI was approved in API review, it can be implemented

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions