示例#1
0
            public override Accessibility VisitFunctionPointerType(
                IFunctionPointerTypeSymbol symbol
                )
            {
                var accessibility = symbol.DeclaredAccessibility;

                accessibility = AccessibilityUtilities.Minimum(
                    accessibility,
                    symbol.Signature.ReturnType.Accept(this)
                    );

                foreach (var parameter in symbol.Signature.Parameters)
                {
                    accessibility = AccessibilityUtilities.Minimum(
                        accessibility,
                        parameter.Type.Accept(this)
                        );
                }

                // CallingConvention types are currently specced to always be public, but if that spec ever changes
                // or the runtime creates special private types for it's own use, we'll be ready.
                foreach (
                    var callingConventionType in symbol.Signature.UnmanagedCallingConventionTypes
                    )
                {
                    accessibility = AccessibilityUtilities.Minimum(
                        accessibility,
                        callingConventionType.Accept(this)
                        );
                }

                return(accessibility);
            }
示例#2
0
 public override ITypeSymbol VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
 {
     // TODO(https://github.com/dotnet/roslyn/issues/43890): function pointers could theoretically
     // have a parameter of an anonymous type if you have a generic function that returns function
     // pointers, and that was called with an anonymous type.
     return(symbol);
 }
示例#3
0
 public static void Create(IFunctionPointerTypeSymbol symbol, SymbolKeyWriter visitor)
 {
     visitor.WriteRefKind(symbol.Signature.RefKind);
     visitor.WriteSymbolKey(symbol.Signature.ReturnType);
     visitor.WriteRefKindArray(symbol.Signature.Parameters);
     visitor.WriteParameterTypesArray(symbol.Signature.Parameters);
 }
示例#4
0
 public override void VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
 {
     symbol.Signature.ReturnType.Accept(this);
     foreach (var param in symbol.Signature.Parameters)
     {
         param.Type.Accept(this);
     }
 }
            public override bool VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
            {
                if (!_visited.Add(symbol))
                {
                    return(false);
                }

                return(true);
            }
            public override TypeSyntax VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
            {
                // TODO(https://github.com/dotnet/roslyn/issues/39865): generate the calling convention once exposed through the API
                var parameters = symbol.Signature.Parameters.Select(p => (p.Type, RefKindModifiers: CSharpSyntaxGenerator.GetParameterModifiers(p.RefKind)))
                                 .Concat(SpecializedCollections.SingletonEnumerable((
                                                                                        Type: symbol.Signature.ReturnType,
                                                                                        RefKindModifiers: CSharpSyntaxGenerator.GetParameterModifiers(symbol.Signature.RefKind, forFunctionPointerReturnParameter: true))))
                                 .SelectAsArray(t => SyntaxFactory.Parameter(SyntaxFactory.MissingToken(SyntaxKind.IdentifierToken)).WithModifiers(t.RefKindModifiers).WithType(t.Type.GenerateTypeSyntax()));

                return(AddInformationTo(
                           SyntaxFactory.FunctionPointerType(SyntaxFactory.SeparatedList(parameters)), symbol));
            }
示例#7
0
            public override void VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
            {
                if (!_visited.Add(symbol))
                {
                    return;
                }

                foreach (var parameter in symbol.Signature.Parameters)
                {
                    parameter.Type.Accept(this);
                }

                symbol.Signature.ReturnType.Accept(this);
            }
            public static void Create(IFunctionPointerTypeSymbol symbol, SymbolKeyWriter visitor)
            {
                var callingConvention = symbol.Signature.CallingConvention;

                visitor.WriteInteger((int)callingConvention);

                if (callingConvention == SignatureCallingConvention.Unmanaged)
                {
                    visitor.WriteSymbolKeyArray(symbol.Signature.UnmanagedCallingConventionTypes);
                }

                visitor.WriteRefKind(symbol.Signature.RefKind);
                visitor.WriteSymbolKey(symbol.Signature.ReturnType);
                visitor.WriteRefKindArray(symbol.Signature.Parameters);
                visitor.WriteParameterTypesArray(symbol.Signature.Parameters);
            }
示例#9
0
        public override void VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
        {
            Append("delegate*");

            var signature = symbol.Signature;

            if (signature.CallingConvention != SignatureCallingConvention.Default)
            {
                Append(" unmanaged");

                if ((signature.CallingConvention != SignatureCallingConvention.Unmanaged) || (signature.UnmanagedCallingConventionTypes.Length != 0))
                {
                    Append("[");

                    if (signature.UnmanagedCallingConventionTypes.Length != 0)
                    {
                        WriteUnmanagedCallConv(signature.UnmanagedCallingConventionTypes[0]);

                        for (int i = 1; i < signature.UnmanagedCallingConventionTypes.Length; i++)
                        {
                            Append(", ");
                            WriteUnmanagedCallConv(signature.UnmanagedCallingConventionTypes[i]);
                        }
                    }
                    else
                    {
                        WriteUnmanagedCallConv(signature.CallingConvention);
                    }

                    Append("]");
                }
            }

            Append("<");

            foreach (var parameter in signature.Parameters)
            {
                WriteRefKind(parameter.RefKind, isReturn: false);
                parameter.Type.Accept(this);
                Append(", ");
            }

            WriteRefKind(signature.RefKind, isReturn: true);
            signature.ReturnType.Accept(this);

            Append(">");
        }
 private static IList <SignatureHelpItem> GetFunctionPointerInvokeItems(
     InvocationExpressionSyntax invocationExpression,
     SemanticModel semanticModel,
     IAnonymousTypeDisplayService anonymousTypeDisplayService,
     IDocumentationCommentFormattingService documentationCommentFormattingService,
     IFunctionPointerTypeSymbol functionPointerType,
     out int?selectedItem,
     CancellationToken cancellationToken
     )
 {
     return(GetDelegateOrFunctionPointerInvokeItems(
                invocationExpression,
                functionPointerType.Signature,
                semanticModel,
                anonymousTypeDisplayService,
                documentationCommentFormattingService,
                out selectedItem,
                cancellationToken
                ));
 }
示例#11
0
 public override IEntity VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol) => FunctionPointerType.Create(cx, symbol);
示例#12
0
 public virtual TResult?VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
 {
     return(DefaultVisit(symbol));
 }
示例#13
0
 public virtual void VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
 {
     DefaultVisit(symbol);
 }
示例#14
0
 public override ITypeSymbol VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
 {
     // TODO(https://github.com/dotnet/roslyn/issues/43890): implement this
     return(symbol);
 }
示例#15
0
 public override void VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
 {
     base.VisitFunctionPointerType(symbol);
 }
 public override INamedTypeSymbol?VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
 => null;
示例#17
0
 public override int VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol, StringBuilder argument)
 {
     return(base.VisitFunctionPointerType(symbol, argument));
 }
 public override ITypeSymbol VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
 {
     // TODO(https://github.com/dotnet/roslyn/issues/43890): also visit the underlying types of
     // the parameters and return value
     return(VisitType(symbol));
 }
示例#19
0
 public override void VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
 {
     VisitMethod(symbol.Signature);
 }
示例#20
0
 public virtual TResult VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol, TArgument argument)
 {
     return(DefaultVisit(symbol, argument));
 }
示例#21
0
        public override void VisitFunctionPointerType(IFunctionPointerTypeSymbol symbol)
        {
            ReferenceItem.Parts[SyntaxLanguage.VB].Add(new LinkItem
            {
                DisplayName           = "delegate*",
                DisplayNamesWithType  = "delegate*",
                DisplayQualifiedNames = "delegate*",
            });

            var signature = symbol.Signature;

            if (signature.CallingConvention != SignatureCallingConvention.Default)
            {
                ReferenceItem.Parts[SyntaxLanguage.VB].Add(new LinkItem
                {
                    DisplayName           = "unmanaged",
                    DisplayNamesWithType  = "unmanaged",
                    DisplayQualifiedNames = "unmanaged",
                });

                if ((signature.CallingConvention != SignatureCallingConvention.Unmanaged) || (signature.UnmanagedCallingConventionTypes.Length != 0))
                {
                    ReferenceItem.Parts[SyntaxLanguage.VB].Add(new LinkItem
                    {
                        DisplayName           = " [",
                        DisplayNamesWithType  = " [",
                        DisplayQualifiedNames = " [",
                    });

                    if (signature.UnmanagedCallingConventionTypes.Length != 0)
                    {
                        for (int i = 0; i < signature.UnmanagedCallingConventionTypes.Length; i++)
                        {
                            if (i > 0)
                            {
                                ReferenceItem.Parts[SyntaxLanguage.VB].Add(new LinkItem
                                {
                                    DisplayName           = ", ",
                                    DisplayNamesWithType  = ", ",
                                    DisplayQualifiedNames = ", ",
                                });
                            }
                            signature.UnmanagedCallingConventionTypes[i].Accept(this);
                        }
                    }
                    else
                    {
                        ReferenceItem.Parts[SyntaxLanguage.VB].Add(new LinkItem
                        {
                            DisplayName           = signature.CallingConvention.ToString(),
                            DisplayNamesWithType  = signature.CallingConvention.ToString(),
                            DisplayQualifiedNames = signature.CallingConvention.ToString(),
                        });
                    }

                    ReferenceItem.Parts[SyntaxLanguage.VB].Add(new LinkItem
                    {
                        DisplayName           = "]",
                        DisplayNamesWithType  = "]",
                        DisplayQualifiedNames = "]",
                    });
                }
            }

            ReferenceItem.Parts[SyntaxLanguage.VB].Add(new LinkItem
            {
                DisplayName           = "<",
                DisplayNamesWithType  = "<",
                DisplayQualifiedNames = "<",
            });

            foreach (var parameter in signature.Parameters)
            {
                parameter.Type.Accept(this);

                ReferenceItem.Parts[SyntaxLanguage.VB].Add(new LinkItem
                {
                    DisplayName           = ", ",
                    DisplayNamesWithType  = ", ",
                    DisplayQualifiedNames = ", ",
                });
            }

            signature.ReturnType.Accept(this);

            ReferenceItem.Parts[SyntaxLanguage.VB].Add(new LinkItem
            {
                DisplayName           = ">",
                DisplayNamesWithType  = ">",
                DisplayQualifiedNames = ">",
            });
        }