public static FunctionPointerTypeSymbol CreateFromSource(FunctionPointerTypeSyntax syntax, Binder typeBinder, DiagnosticBag diagnostics, ConsList <TypeSymbol> basesBeingResolved, bool suppressUseSiteDiagnostics)
 => new FunctionPointerTypeSymbol(
     FunctionPointerMethodSymbol.CreateFromSource(
         syntax,
         typeBinder,
         diagnostics,
         basesBeingResolved,
         suppressUseSiteDiagnostics));
 public FunctionPointerParameterSymbol(TypeWithAnnotations typeWithAnnotations, RefKind refKind, int ordinal, FunctionPointerMethodSymbol containingSymbol, ImmutableArray <CustomModifier> refCustomModifiers)
 {
     TypeWithAnnotations = typeWithAnnotations;
     RefKind             = refKind;
     Ordinal             = ordinal;
     _containingSymbol   = containingSymbol;
     RefCustomModifiers  = refCustomModifiers;
 }
 /// <summary>
 /// Creates a function pointer from individual parts. This method should only be used when diagnostics are not needed.
 /// </summary>
 public static FunctionPointerTypeSymbol CreateFromParts(
     CallingConvention callingConvention,
     ImmutableArray <CustomModifier> callingConventionModifiers,
     TypeWithAnnotations returnType,
     RefKind returnRefKind,
     ImmutableArray <TypeWithAnnotations> parameterTypes,
     ImmutableArray <RefKind> parameterRefKinds,
     CSharpCompilation compilation)
 => new FunctionPointerTypeSymbol(FunctionPointerMethodSymbol.CreateFromParts(callingConvention, callingConventionModifiers, returnType, returnRefKind, parameterTypes, parameterRefKinds, compilation));
Ejemplo n.º 4
0
        public static ImmutableArray <FunctionPointerParameterSymbol> MakeFunctionPointerParameters(
            Binder binder,
            FunctionPointerMethodSymbol owner,
            SeparatedSyntaxList <FunctionPointerParameterSyntax> parametersList,
            BindingDiagnosticBag diagnostics,
            bool suppressUseSiteDiagnostics)
        {
            return(MakeParameters <FunctionPointerParameterSyntax, FunctionPointerParameterSymbol, FunctionPointerMethodSymbol>(
                       binder,
                       owner,
                       parametersList,
                       out _,
                       diagnostics,
                       allowRefOrOut: true,
                       allowThis: false,
                       addRefReadOnlyModifier: true,
                       suppressUseSiteDiagnostics,
                       parametersList.Count - 2,
                       parameterCreationFunc: (Binder binder, FunctionPointerMethodSymbol owner, TypeWithAnnotations parameterType,
                                               FunctionPointerParameterSyntax syntax, RefKind refKind, int ordinal,
                                               SyntaxToken paramsKeyword, SyntaxToken thisKeyword, bool addRefReadOnlyModifier,
                                               DeclarationScope scope,
                                               BindingDiagnosticBag diagnostics) =>
            {
                // Non-function pointer locations have other locations to encode in/ref readonly/outness. For function pointers,
                // these modreqs are the only locations where this can be encoded. If that changes, we should update this.
                Debug.Assert(addRefReadOnlyModifier, "If addReadonlyRef isn't true, we must have found a different location to encode the readonlyness of a function pointer");
                ImmutableArray <CustomModifier> customModifiers = refKind switch
                {
                    RefKind.In => CreateInModifiers(binder, diagnostics, syntax),
                    RefKind.Out => CreateOutModifiers(binder, diagnostics, syntax),
                    _ => ImmutableArray <CustomModifier> .Empty
                };

                if (parameterType.IsVoidType())
                {
                    diagnostics.Add(ErrorCode.ERR_NoVoidParameter, syntax.Type.Location);
                }

                return new FunctionPointerParameterSymbol(
                    parameterType,
                    refKind,
                    ordinal,
                    owner,
                    customModifiers);
            },
 private FunctionPointerTypeSymbol(FunctionPointerMethodSymbol signature)
 {
     Signature = signature;
 }
 public static FunctionPointerTypeSymbol CreateFromMetadata(Cci.CallingConvention callingConvention, ImmutableArray <ParamInfo <TypeSymbol> > retAndParamTypes)
 => new FunctionPointerTypeSymbol(
     FunctionPointerMethodSymbol.CreateFromMetadata(callingConvention, retAndParamTypes));
 internal FunctionPointerMethodSignature(FunctionPointerMethodSymbol underlying)
 {
     _underlying = underlying;
 }