Exemplo n.º 1
0
        internal IteratorConstructor(StateMachineTypeSymbol container)
            : base(container)
        {
            var intType = container.DeclaringCompilation.GetSpecialType(SpecialType.System_Int32);

            _parameters = ImmutableArray.Create <ParameterSymbol>(
                SynthesizedParameterSymbol.Create(this, TypeWithAnnotations.Create(intType), 0, RefKind.None, GeneratedNames.MakeStateMachineStateFieldName()));
        }
Exemplo n.º 2
0
        public EECompilationContextMethod(CSharpCompilation compilation, MethodSymbol underlyingMethod)
        {
            Debug.Assert(underlyingMethod.IsDefinition);

            _compilation = compilation;

            var typeMap = underlyingMethod.ContainingType.TypeSubstitution ?? TypeMap.Empty;

            typeMap.WithAlphaRename(underlyingMethod, this, out _typeParameters);

            _underlyingMethod = underlyingMethod.ConstructIfGeneric(TypeArgumentsWithAnnotations);
            _parameters       = SynthesizedParameterSymbol.DeriveParameters(_underlyingMethod, this);
        }
Exemplo n.º 3
0
 private ParameterSymbol MakeParameterSymbol(
     int ordinal,
     string name,
     ParameterSymbol sourceParameter
     )
 {
     return(SynthesizedParameterSymbol.Create(
                this,
                sourceParameter.TypeWithAnnotations,
                ordinal,
                sourceParameter.RefKind,
                name,
                sourceParameter.RefCustomModifiers
                ));
 }
Exemplo n.º 4
0
        private static ImmutableArray <MethodSymbol> GetAdditionalNullableAttributeConstructors(
            CSharpCompilation compilation,
            NamedTypeSymbol containingType,
            DiagnosticBag diagnostics)
        {
            var boolType = compilation.GetSpecialType(SpecialType.System_Boolean);

            Binder.ReportUseSiteDiagnostics(boolType, diagnostics, Location.None);
            var boolArray = TypeSymbolWithAnnotations.Create(
                ArrayTypeSymbol.CreateSZArray(
                    boolType.ContainingAssembly,
                    TypeSymbolWithAnnotations.Create(boolType)));

            return(ImmutableArray.Create <MethodSymbol>(
                       new SynthesizedEmbeddedAttributeConstructorSymbol(
                           containingType,
                           m => ImmutableArray.Create(SynthesizedParameterSymbol.Create(m, boolArray, 0, RefKind.None)))));
        }
Exemplo n.º 5
0
            internal override BoundExpression GetAddress(BoundPseudoVariable variable)
            {
                var method = GetIntrinsicMethod(
                    _compilation,
                    ExpressionCompilerConstants.GetVariableAddressMethodName
                    );

                // Currently the MetadataDecoder does not support byref return types
                // so the return type of GetVariableAddress(Of T)(name As String)
                // is an error type. Since the method is only used for emit, an
                // updated placeholder method is used instead.

                // TODO: refs are available
                // Debug.Assert(method.ReturnType.TypeKind == TypeKind.Error); // If byref return types are supported in the future, use method as is.
                method = new PlaceholderMethodSymbol(
                    method.ContainingType,
                    method.Name,
                    m =>
                    method.TypeParameters.SelectAsArray(
                        t =>
                        (TypeParameterSymbol) new SimpleTypeParameterSymbol(
                            m,
                            t.Ordinal,
                            t.Name
                            )
                        ),
                    m => m.TypeParameters[0], // return type is <>T&
                    m =>
                    method.Parameters.SelectAsArray(
                        p =>
                        (ParameterSymbol)SynthesizedParameterSymbol.Create(
                            m,
                            p.TypeWithAnnotations,
                            p.Ordinal,
                            p.RefKind,
                            p.Name,
                            p.RefCustomModifiers
                            )
                        )
                    );
                var local = variable.LocalSymbol;

                return(InvokeGetMethod(method.Construct(local.Type), variable.Syntax, local.Name));
            }
Exemplo n.º 6
0
        /// <summary>
        /// Creates ghost stub that calls method.
        /// </summary>
        public static void CreateGhostOverload(this MethodSymbol method, NamedTypeSymbol containingtype, PEModuleBuilder module, DiagnosticBag diagnostic,
                                               TypeSymbol ghostreturn, IEnumerable <ParameterSymbol> ghostparams,
                                               MethodSymbol explicitOverride = null)
        {
            string prefix = (explicitOverride != null && explicitOverride.ContainingType.IsInterface)
                ? (explicitOverride.ContainingType.GetFullName() + ".")   // explicit interface override
                : null;

            var ghost = new SynthesizedMethodSymbol(
                containingtype, prefix + method.Name, method.IsStatic, explicitOverride != null, ghostreturn, method.DeclaredAccessibility)
            {
                ExplicitOverride = explicitOverride,
                ForwardedCall    = method,
            };

            ghost.SetParameters(ghostparams.Select(p => SynthesizedParameterSymbol.Create(ghost, p)).ToArray());

            // save method symbol to module
            module.SynthesizedManager.AddMethod(containingtype, ghost);

            // generate method body
            GenerateGhostBody(module, diagnostic, method, ghost);
        }