コード例 #1
0
ファイル: PEModuleBuilder.cs プロジェクト: CSRedRat/roslyn
        /// <summary>
        /// Returns null if there are no synthesized fields.
        /// </summary>
        public IEnumerable <Cci.IFieldDefinition> GetSynthesizedFields(TNamedTypeSymbol container)
        {
            SynthesizedDefinitions defs = GetCacheOfSynthesizedDefinitions(container, addIfNotFound: false);

            if (defs != null)
            {
                return(defs.Fields);
            }

            return(null);
        }
コード例 #2
0
        public ImmutableArray <Cci.ITypeDefinitionMember> GetSynthesizedMembers(Cci.ITypeDefinition container)
        {
            SynthesizedDefinitions defs = GetCacheOfSynthesizedDefinitions((TNamedTypeSymbol)container, addIfNotFound: false);

            if (defs == null)
            {
                return(ImmutableArray <Cci.ITypeDefinitionMember> .Empty);
            }

            return(defs.GetAllMembers());
        }
コード例 #3
0
        public ITypeDefinitionMember[] GetSynthesizedMembers(ITypeDefinition container)
        {
            SynthesizedDefinitions defs = GetCacheOfSynthesizedDefinitions((TNamedTypeSymbol)container, addIfNotFound: false);

            if (defs == null)
            {
                return(new ITypeDefinitionMember[0]);
            }

            return(defs.GetAllMembers());
        }
コード例 #4
0
        public void AddSynthesizedDefinition(TNamedTypeSymbol container, Cci.IFieldDefinition field)
        {
            Debug.Assert(field != null);

            SynthesizedDefinitions defs = GetCacheOfSynthesizedDefinitions(container);

            if (defs.Fields == null)
            {
                Interlocked.CompareExchange(ref defs.Fields, new ConcurrentQueue <Cci.IFieldDefinition>(), null);
            }

            defs.Fields.Enqueue(field);
        }
コード例 #5
0
        public void AddSynthesizedDefinition(TNamedTypeSymbol container, Cci.IPropertyDefinition property)
        {
            Debug.Assert(property != null);

            SynthesizedDefinitions defs = GetCacheOfSynthesizedDefinitions(container);

            if (defs.Properties == null)
            {
                Interlocked.CompareExchange(ref defs.Properties, new ConcurrentQueue <Cci.IPropertyDefinition>(), null);
            }

            defs.Properties.Enqueue(property);
        }
コード例 #6
0
        public void AddSynthesizedDefinition(TNamedTypeSymbol container, Cci.INestedTypeDefinition nestedType)
        {
            Debug.Assert(nestedType != null);

            SynthesizedDefinitions defs = GetOrAddSynthesizedDefinitions(container);

            if (defs.NestedTypes == null)
            {
                Interlocked.CompareExchange(ref defs.NestedTypes, new ConcurrentQueue <Cci.INestedTypeDefinition>(), null);
            }

            defs.NestedTypes.Enqueue(nestedType);
        }
コード例 #7
0
        public void AddSynthesizedDefinition(TNamedTypeSymbol container, Cci.IMethodDefinition method)
        {
            Debug.Assert(method != null);

            SynthesizedDefinitions defs = GetOrAddSynthesizedDefinitions(container);

            if (defs.Methods == null)
            {
                Interlocked.CompareExchange(ref defs.Methods, new ConcurrentQueue <Cci.IMethodDefinition>(), null);
            }

            defs.Methods.Enqueue(method);
        }
コード例 #8
0
        private SynthesizedDefinitions GetCacheOfSynthesizedDefinitions(TNamedTypeSymbol container, bool addIfNotFound = true)
        {
            Debug.Assert(((INamedTypeSymbol)container).IsDefinition);
            if (addIfNotFound)
            {
                SynthesizedDefinitions result;
                if (!_synthesizedDefs.TryGetValue(container, out result))
                {
                    result = new SynthesizedDefinitions();
                    _synthesizedDefs.Add(container, result);
                }
                return(result);
            }

            SynthesizedDefinitions defs;

            _synthesizedDefs.TryGetValue(container, out defs);
            return(defs);
        }
コード例 #9
0
        /// <summary>
        /// Returns null if there are no compiler generated types.
        /// </summary>
        public IEnumerable <Cci.INestedTypeDefinition> GetSynthesizedTypes(TNamedTypeSymbol container)
        {
            IEnumerable <Cci.INestedTypeDefinition> declareTypes     = GetSynthesizedNestedTypes(container);
            IEnumerable <Cci.INestedTypeDefinition> compileEmitTypes = null;

            SynthesizedDefinitions defs = GetCacheOfSynthesizedDefinitions(container, addIfNotFound: false);

            if (defs != null)
            {
                compileEmitTypes = defs.NestedTypes;
            }

            if (declareTypes == null)
            {
                return(compileEmitTypes);
            }

            if (compileEmitTypes == null)
            {
                return(declareTypes);
            }

            return(declareTypes.Concat(compileEmitTypes));
        }