Ejemplo n.º 1
0
 private void EnsurePrivateImplementationDetailsStaticConstructor(PrivateImplementationDetails details, TSyntaxNode syntaxOpt, DiagnosticBag diagnostics)
 {
     if (details.GetMethod(WellKnownMemberNames.StaticConstructorName) == null)
     {
         details.TryAddSynthesizedMethod(CreatePrivateImplementationDetailsStaticConstructor(details, syntaxOpt, diagnostics));
     }
 }
Ejemplo n.º 2
0
        internal PrivateImplementationDetails GetPrivateImplClass(TSyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
        {
            var result = _privateImplementationDetails;

            if ((result == null) && this.SupportsPrivateImplClass)
            {
                result = new PrivateImplementationDetails(
                    this,
                    this.SourceModule.Name,
                    _compilation.GetSubmissionSlotIndex(),
                    this.GetSpecialType(SpecialType.System_Object, syntaxNodeOpt, diagnostics),
                    this.GetSpecialType(SpecialType.System_ValueType, syntaxNodeOpt, diagnostics),
                    this.GetSpecialType(SpecialType.System_Byte, syntaxNodeOpt, diagnostics),
                    this.GetSpecialType(SpecialType.System_Int16, syntaxNodeOpt, diagnostics),
                    this.GetSpecialType(SpecialType.System_Int32, syntaxNodeOpt, diagnostics),
                    this.GetSpecialType(SpecialType.System_Int64, syntaxNodeOpt, diagnostics),
                    SynthesizeAttribute(WellKnownMember.System_Runtime_CompilerServices_CompilerGeneratedAttribute__ctor));

                if (Interlocked.CompareExchange(ref _privateImplementationDetails, result, null) != null)
                {
                    result = _privateImplementationDetails;
                }
            }

            return(result);
        }
 internal SynthesizedStringSwitchHashMethod(
     SourceModuleSymbol containingModule,
     PrivateImplementationDetails privateImplType,
     TypeSymbol returnType,
     TypeSymbol paramType
     )
     : base(
         containingModule,
         privateImplType,
         returnType,
         PrivateImplementationDetails.SynthesizedStringHashFunctionName
         )
 {
     this.SetParameters(
         ImmutableArray.Create <ParameterSymbol>(
             SynthesizedParameterSymbol.Create(
                 this,
                 TypeWithAnnotations.Create(paramType),
                 0,
                 RefKind.None,
                 "s"
                 )
             )
         );
 }
Ejemplo n.º 4
0
        internal Cci.IFieldReference GetInstrumentationPayloadRoot(int analysisKind, Cci.ITypeReference payloadType, TSyntaxNode syntaxOpt, DiagnosticBag diagnostics)
        {
            PrivateImplementationDetails details = GetPrivateImplClass(syntaxOpt, diagnostics);

            EnsurePrivateImplementationDetailsStaticConstructor(details, syntaxOpt, diagnostics);

            return(details.GetOrAddInstrumentationPayloadRoot(analysisKind, payloadType));
        }
Ejemplo n.º 5
0
        internal Cci.IFieldReference GetModuleVersionId(Cci.ITypeReference mvidType, TSyntaxNode syntaxOpt, DiagnosticBag diagnostics)
        {
            PrivateImplementationDetails details = GetPrivateImplClass(syntaxOpt, diagnostics);

            EnsurePrivateImplementationDetailsStaticConstructor(details, syntaxOpt, diagnostics);

            return(details.GetModuleVersionId(mvidType));
        }
Ejemplo n.º 6
0
        Cci.IFieldReference ITokenDeferral.GetFieldForData(ImmutableArray <byte> data, SyntaxNode syntaxNode, DiagnosticBag diagnostics)
        {
            Debug.Assert(this.SupportsPrivateImplClass);

            PrivateImplementationDetails privateImpl = this.GetPrivateImplClass((TSyntaxNode)syntaxNode, diagnostics);

            // map a field to the block (that makes it addressable via a token)
            return(privateImpl.CreateDataField(data));
        }
Ejemplo n.º 7
0
        internal SynthesizedThrowIfNullMethod(SourceModuleSymbol containingModule, PrivateImplementationDetails privateImplType, MethodSymbol throwMethod, TypeSymbol returnType, TypeSymbol argumentParamType, TypeSymbol paramNameParamType)
            : base(containingModule, privateImplType, returnType, PrivateImplementationDetails.SynthesizedThrowIfNullFunctionName)
        {
            ThrowMethod = throwMethod;

            this.SetParameters(ImmutableArray.Create <ParameterSymbol>(
                                   SynthesizedParameterSymbol.Create(this, TypeWithAnnotations.Create(argumentParamType), ordinal: 0, RefKind.None, "argument"),
                                   SynthesizedParameterSymbol.Create(this, TypeWithAnnotations.Create(paramNameParamType), ordinal: 1, RefKind.None, "paramName")));
        }
        internal SynthesizedGlobalMethodSymbol(ModuleSymbol containingModule, PrivateImplementationDetails privateImplType, TypeSymbol returnType, string name)
        {
            Debug.Assert((object)containingModule != null);
            Debug.Assert(privateImplType != null);
            Debug.Assert((object)returnType != null);
            Debug.Assert(name != null);

            _containingModule = containingModule;
            _privateImplType  = privateImplType;
            _returnType       = returnType;
            _name             = name;
        }
Ejemplo n.º 9
0
        private void CompileGeneratedMethods(PrivateImplementationDetails privateImplClass, DiagnosticBag diagnostics)
        {
            TypeCompilationState compilationState = new TypeCompilationState(null, moduleBeingBuilt);

            foreach (MethodSymbol method in privateImplClass.GetMethods(new Microsoft.CodeAnalysis.Emit.Context(moduleBeingBuilt, null, diagnostics)))
            {
                Debug.Assert(method.SynthesizesLoweredBoundBody);
                method.GenerateMethodBody(compilationState, diagnostics);
            }

            CompileGeneratedMethods(compilationState);
            compilationState.Free();
        }
Ejemplo n.º 10
0
 internal SynthesizedPrivateImplementationDetailsStaticConstructor(
     SourceModuleSymbol containingModule,
     PrivateImplementationDetails privateImplementationType,
     NamedTypeSymbol voidType
     )
     : base(
         containingModule,
         privateImplementationType,
         voidType,
         WellKnownMemberNames.StaticConstructorName
         )
 {
     this.SetParameters(ImmutableArray <ParameterSymbol> .Empty);
 }
 internal SynthesizedThrowSwitchExpressionExceptionMethod(SourceModuleSymbol containingModule, PrivateImplementationDetails privateImplType, TypeSymbol returnType, TypeSymbol paramType)
     : base(containingModule, privateImplType, returnType, PrivateImplementationDetails.SynthesizedThrowSwitchExpressionExceptionFunctionName)
 {
     this.SetParameters(ImmutableArray.Create(SynthesizedParameterSymbol.Create(this, TypeWithAnnotations.Create(paramType), 0, RefKind.None, "unmatchedValue")));
 }
Ejemplo n.º 12
0
 protected abstract Cci.IMethodDefinition CreatePrivateImplementationDetailsStaticConstructor(PrivateImplementationDetails details, TSyntaxNode syntaxOpt, DiagnosticBag diagnostics);
Ejemplo n.º 13
0
        /// <summary>
        /// Returns all top-level (not nested) types defined in the module.
        /// </summary>
        public override IEnumerable <Cci.INamespaceTypeDefinition> GetTopLevelTypes(EmitContext context)
        {
            Cci.NoPiaReferenceIndexer noPiaIndexer = null;
            HashSet <string>          names;

            // First time through, we need to collect emitted names of all top level types.
            if (_namesOfTopLevelTypes == null)
            {
                names = new HashSet <string>();
            }
            else
            {
                names = null;
            }

            // First time through, we need to push things through NoPiaReferenceIndexer
            // to make sure we collect all to be embedded NoPia types and members.
            if (EmbeddedTypesManagerOpt != null && !EmbeddedTypesManagerOpt.IsFrozen)
            {
                noPiaIndexer = new Cci.NoPiaReferenceIndexer(context);
                Debug.Assert(names != null);
                this.Dispatch(noPiaIndexer);
            }

            AddTopLevelType(names, _rootModuleType);
            VisitTopLevelType(noPiaIndexer, _rootModuleType);
            yield return(_rootModuleType);

            foreach (Cci.INamespaceTypeDefinition type in this.GetAnonymousTypes())
            {
                AddTopLevelType(names, type);
                VisitTopLevelType(noPiaIndexer, type);
                yield return(type);
            }

            foreach (Cci.INamespaceTypeDefinition type in this.GetTopLevelTypesCore(context))
            {
                AddTopLevelType(names, type);
                VisitTopLevelType(noPiaIndexer, type);
                yield return(type);
            }

            PrivateImplementationDetails privateImpl = this.PrivateImplClass;

            if (privateImpl != null)
            {
                AddTopLevelType(names, privateImpl);
                VisitTopLevelType(noPiaIndexer, privateImpl);
                yield return(privateImpl);
            }

            if (EmbeddedTypesManagerOpt != null)
            {
                foreach (Cci.INamespaceTypeDefinition embedded in EmbeddedTypesManagerOpt.GetTypes(context.Diagnostics, names))
                {
                    AddTopLevelType(names, embedded);
                    yield return(embedded);
                }
            }

            if (names != null)
            {
                Debug.Assert(_namesOfTopLevelTypes == null);
                _namesOfTopLevelTypes = names;
            }
        }
 internal SynthesizedParameterlessThrowMethod(SourceModuleSymbol containingModule, PrivateImplementationDetails privateImplType, TypeSymbol returnType, string synthesizedMethodName, MethodSymbol exceptionConstructor)
     : base(containingModule, privateImplType, returnType, synthesizedMethodName)
 {
     _exceptionConstructor = exceptionConstructor;
     this.SetParameters(ImmutableArray <ParameterSymbol> .Empty);
 }
Ejemplo n.º 15
0
        public static string GetMimeTypeFromFile(string pFile)
        {
            string result = "image/jpeg";
            string text   = Path.GetExtension(pFile).ToLower();
            uint   num    = PrivateImplementationDetails.ComputeStringHash(text);

            if (num <= 1388056268u)
            {
                if (num <= 850093434u)
                {
                    if (num != 175576948u)
                    {
                        if (num != 850093434u)
                        {
                            return(result);
                        }
                        if (!(text == ".ico"))
                        {
                            return(result);
                        }
                        return("image/x-icon");
                    }
                    else
                    {
                        if (!(text == ".bmp"))
                        {
                            return(result);
                        }
                        return("image/bmp");
                    }
                }
                else if (num != 1128223456u)
                {
                    if (num != 1384894805u)
                    {
                        if (num != 1388056268u)
                        {
                            return(result);
                        }
                        if (!(text == ".jpg"))
                        {
                            return(result);
                        }
                    }
                    else
                    {
                        if (!(text == ".gif"))
                        {
                            return(result);
                        }
                        return("image/gif");
                    }
                }
                else
                {
                    if (!(text == ".png"))
                    {
                        return(result);
                    }
                    return("image/png");
                }
            }
            else
            {
                if (num > 1928100785u)
                {
                    if (num != 3560597182u)
                    {
                        if (num != 4100894060u)
                        {
                            if (num != 4178554255u)
                            {
                                return(result);
                            }
                            if (!(text == ".jpeg"))
                            {
                                return(result);
                            }
                            goto IL_152;
                        }
                        else if (!(text == ".tif"))
                        {
                            return(result);
                        }
                    }
                    else if (!(text == ".tiff"))
                    {
                        return(result);
                    }
                    return("image/tiff");
                }
                if (num != 1464784447u)
                {
                    if (num != 1928100785u)
                    {
                        return(result);
                    }
                    if (!(text == ".wmf"))
                    {
                        return(result);
                    }
                    return("image/x-wmf");
                }
                else
                {
                    if (!(text == ".emf"))
                    {
                        return(result);
                    }
                    return("image/x-emf");
                }
            }
IL_152:
            result = "image/jpeg";
            return(result);
        }
Ejemplo n.º 16
0
        public static PBXCapabilityType StringToPBXCapabilityType(string cap)
        {
            string s = cap;
            // ISSUE: reference to a compiler-generated method
            uint stringHash = PrivateImplementationDetails.ComputeStringHash(s);

            if (stringHash <= 1795649615U)
            {
                if (stringHash <= 380370087U)
                {
                    if (stringHash <= 12939752U)
                    {
                        if ((int)stringHash != 623369)
                        {
                            if ((int)stringHash == 12939752 && s == "com.apple.ApplePay")
                            {
                                return(PBXCapabilityType.ApplePay);
                            }
                        }
                        else if (s == "com.apple.DataProtection")
                        {
                            return(PBXCapabilityType.DataProtection);
                        }
                    }
                    else if ((int)stringHash != 200988660)
                    {
                        if ((int)stringHash != 290035059)
                        {
                            if ((int)stringHash == 380370087 && s == "com.apple.InterAppAudio")
                            {
                                return(PBXCapabilityType.InterAppAudio);
                            }
                        }
                        else if (s == "com.apple.Wallet")
                        {
                            return(PBXCapabilityType.Wallet);
                        }
                    }
                    else if (s == "com.apple.developer.applesignin")
                    {
                        return(PBXCapabilityType.SignInWithApple);
                    }
                }
                else if (stringHash <= 634469633U)
                {
                    if ((int)stringHash != 399517150)
                    {
                        if ((int)stringHash == 634469633 && s == "com.apple.GameCenter")
                        {
                            return(PBXCapabilityType.GameCenter);
                        }
                    }
                    else if (s == "com.apple.SafariKeychain")
                    {
                        return(PBXCapabilityType.AssociatedDomains);
                    }
                }
                else if ((int)stringHash != 981567319)
                {
                    if ((int)stringHash != 1727671163)
                    {
                        if ((int)stringHash == 1795649615 && s == "com.apple.Siri")
                        {
                            return(PBXCapabilityType.Siri);
                        }
                    }
                    else if (s == "com.apple.ApplicationGroups.iOS")
                    {
                        return(PBXCapabilityType.AppGroups);
                    }
                }
                else if (s == "com.apple.HomeKit")
                {
                    return(PBXCapabilityType.HomeKit);
                }
            }
            else if (stringHash <= 2742965566U)
            {
                if (stringHash <= 2418183063U)
                {
                    if ((int)stringHash != -1966183118)
                    {
                        if ((int)stringHash == -1876784233 && s == "com.apple.InAppPurchase")
                        {
                            return(PBXCapabilityType.InAppPurchase);
                        }
                    }
                    else if (s == "com.apple.VPNLite")
                    {
                        return(PBXCapabilityType.PersonalVPN);
                    }
                }
                else if ((int)stringHash != -1868372490)
                {
                    if ((int)stringHash != -1807207318)
                    {
                        if ((int)stringHash == -1552001730 && s == "com.apple.networking.wifi-info")
                        {
                            return(PBXCapabilityType.AccessWiFiInformation);
                        }
                    }
                    else if (s == "com.apple.iCloud")
                    {
                        return(PBXCapabilityType.iCloud);
                    }
                }
                else if (s == "com.apple.BackgroundModes")
                {
                    return(PBXCapabilityType.BackgroundModes);
                }
            }
            else if (stringHash <= 3326784170U)
            {
                if ((int)stringHash != -1457551806)
                {
                    if ((int)stringHash == -968183126 && s == "com.apple.Push")
                    {
                        return(PBXCapabilityType.PushNotifications);
                    }
                }
                else if (s == "WAC")
                {
                    return(PBXCapabilityType.WirelessAccessoryConfiguration);
                }
            }
            else if ((int)stringHash != -588709462)
            {
                if ((int)stringHash != -422186908)
                {
                    if ((int)stringHash == -34751118 && s == "com.apple.Maps.iOS")
                    {
                        return(PBXCapabilityType.Maps);
                    }
                }
                else if (s == "com.apple.HealthKit")
                {
                    return(PBXCapabilityType.HealthKit);
                }
            }
            else if (s == "com.apple.KeychainSharing")
            {
                return(PBXCapabilityType.KeychainSharing);
            }
            return((PBXCapabilityType)null);
        }