コード例 #1
0
        /// <summary>
        /// This callback gets called whenever a module gets registered. It adds the metadata reader
        /// for the new module to the available scopes. The lock in ExecutionEnvironmentImplementation ensures
        /// that this function may never be called concurrently so that we can assume that two threads
        /// never update the reader and scope list at the same time.
        /// </summary>
        /// <param name="moduleHandle">Module handle to register</param>
        private void RegisterModule(IntPtr moduleHandle)
        {
            MetadataReader newReader = _executionEnvironment.GetMetadataReaderForModule(moduleHandle);

            if (newReader == null)
            {
                return;
            }

            // Build new reader list
            LowLevelListWithIList <MetadataReader> readers = new LowLevelListWithIList <MetadataReader>(_readers.Count + 1);

            foreach (MetadataReader oldReader in _readers)
            {
                readers.Add(oldReader);
            }
            readers.Add(newReader);

            LowLevelDictionaryWithIEnumerable <string, ScopeDefinitionGroup> scopeGroups = new LowLevelDictionaryWithIEnumerable <string, ScopeDefinitionGroup>();

            foreach (KeyValuePair <string, ScopeDefinitionGroup> oldGroup in _scopeGroups)
            {
                scopeGroups.Add(oldGroup.Key, oldGroup.Value);
            }
            AddScopesFromReaderToGroups(scopeGroups, newReader);

            // Update reader and scope list
            _readers     = readers;
            _scopeGroups = scopeGroups;
        }
コード例 #2
0
        public unsafe ExecutionEnvironmentImplementation()
        {
            _moduleToMetadataReader = new LowLevelDictionaryWithIEnumerable <IntPtr, MetadataReader>();

            // Metadata reader must be creater first as other callbacks might need it
            AddModuleRegistrationCallback(CreateMetadataReader);
            AddModuleRegistrationCallback(ModuleList.RegisterModule);
        }
コード例 #3
0
 public unsafe ExecutionEnvironmentImplementation()
 {
     _moduleToMetadataReader = new LowLevelDictionaryWithIEnumerable<IntPtr, MetadataReader>();
     
     // Metadata reader must be creater first as other callbacks might need it
     AddModuleRegistrationCallback(CreateMetadataReader);
     AddModuleRegistrationCallback(ModuleList.RegisterModule);
 }
コード例 #4
0
        private ExecutionContext(ExecutionContext other)
        {
            m_localValues = new LowLevelDictionaryWithIEnumerable <IAsyncLocal, object>();
            foreach (KeyValuePair <IAsyncLocal, object> kvp in other.m_localValues)
            {
                m_localValues.Add(kvp.Key, kvp.Value);
            }

            m_localChangeNotifications = new LowLevelListWithIList <IAsyncLocal>(other.m_localChangeNotifications);
        }
コード例 #5
0
ファイル: ExecutionContext.cs プロジェクト: justinvp/corert
        private ExecutionContext(ExecutionContext other)
        {
            m_localValues = new LowLevelDictionaryWithIEnumerable<IAsyncLocal, object>();
            foreach (KeyValuePair<IAsyncLocal, object> kvp in other.m_localValues)
            {
                m_localValues.Add(kvp.Key, kvp.Value);
            }

            m_localChangeNotifications = new LowLevelListWithIList<IAsyncLocal>(other.m_localChangeNotifications);
        }
コード例 #6
0
 private static void AddScopesFromReaderToGroups(LowLevelDictionaryWithIEnumerable <RuntimeAssemblyName, ScopeDefinitionGroup> groups, MetadataReader reader)
 {
     foreach (ScopeDefinitionHandle scopeDefinitionHandle in reader.ScopeDefinitions)
     {
         RuntimeAssemblyName  defName = scopeDefinitionHandle.ToRuntimeAssemblyName(reader);
         ScopeDefinitionGroup scopeDefinitionGroup;
         if (groups.TryGetValue(defName, out scopeDefinitionGroup))
         {
             scopeDefinitionGroup.AddOverflowScope(new QScopeDefinition(reader, scopeDefinitionHandle));
         }
         else
         {
             scopeDefinitionGroup = new ScopeDefinitionGroup(new QScopeDefinition(reader, scopeDefinitionHandle));
             groups.Add(defName, scopeDefinitionGroup);
         }
     }
 }
コード例 #7
0
        private void AddScopesFromReaderToGroups(LowLevelDictionaryWithIEnumerable <string, ScopeDefinitionGroup> groups, MetadataReader reader)
        {
            foreach (ScopeDefinitionHandle scopeDefinitionHandle in reader.ScopeDefinitions)
            {
                AssemblyName defName     = this.CreateAssemblyNameFromMetadata(reader, scopeDefinitionHandle);
                string       defFullName = defName.FullName;

                ScopeDefinitionGroup scopeDefinitionGroup;
                if (groups.TryGetValue(defFullName, out scopeDefinitionGroup))
                {
                    scopeDefinitionGroup.AddOverflowScope(new QScopeDefinition(reader, scopeDefinitionHandle));
                }
                else
                {
                    scopeDefinitionGroup = new ScopeDefinitionGroup(new QScopeDefinition(reader, scopeDefinitionHandle));
                    groups.Add(defFullName, scopeDefinitionGroup);
                }
            }
        }
コード例 #8
0
 private ExecutionContext()
 {
     m_localValues = new LowLevelDictionaryWithIEnumerable <IAsyncLocal, object>();
     m_localChangeNotifications = new LowLevelListWithIList <IAsyncLocal>();
 }
コード例 #9
0
        /// <summary>
        /// This callback gets called whenever a module gets registered. It adds the metadata reader
        /// for the new module to the available scopes. The lock in ExecutionEnvironmentImplementation ensures
        /// that this function may never be called concurrently so that we can assume that two threads
        /// never update the reader and scope list at the same time.
        /// </summary>
        /// <param name="moduleInfo">Module to register</param>
        private void RegisterModule(ModuleInfo moduleInfo)
        {
            if (moduleInfo.MetadataReader == null)
            {
                return;
            }

            LowLevelDictionaryWithIEnumerable <AssemblyNameKey, ScopeDefinitionGroup> scopeGroups = new LowLevelDictionaryWithIEnumerable <AssemblyNameKey, ScopeDefinitionGroup>();

            foreach (KeyValuePair <AssemblyNameKey, ScopeDefinitionGroup> oldGroup in _scopeGroups)
            {
                scopeGroups.Add(oldGroup.Key, oldGroup.Value);
            }
            AddScopesFromReaderToGroups(scopeGroups, moduleInfo.MetadataReader);

            // Update reader and scope list
            KeyValuePair <AssemblyNameKey, ScopeDefinitionGroup>[] scopeGroupsArray = new KeyValuePair <AssemblyNameKey, ScopeDefinitionGroup> [scopeGroups.Count];
            int i = 0;

            foreach (KeyValuePair <AssemblyNameKey, ScopeDefinitionGroup> data in scopeGroups)
            {
                scopeGroupsArray[i] = data;
                i++;
            }

            _scopeGroups = scopeGroupsArray;
        }
コード例 #10
0
 public AssemblyBinderImplementation(ExecutionEnvironmentImplementation executionEnvironment)
 {
     _executionEnvironment = executionEnvironment;
     _readers = new LowLevelListWithIList<MetadataReader>();
     _scopeGroups = new LowLevelDictionaryWithIEnumerable<string, ScopeDefinitionGroup>();
 }
コード例 #11
0
        private void AddScopesFromReaderToGroups(LowLevelDictionaryWithIEnumerable<string, ScopeDefinitionGroup> groups, MetadataReader reader)
        {
            foreach (ScopeDefinitionHandle scopeDefinitionHandle in reader.ScopeDefinitions)
            {
                AssemblyName defName = this.CreateAssemblyNameFromMetadata(reader, scopeDefinitionHandle);
                string defFullName = defName.FullName;

                ScopeDefinitionGroup scopeDefinitionGroup;
                if (groups.TryGetValue(defFullName, out scopeDefinitionGroup))
                {
                    scopeDefinitionGroup.AddOverflowScope(new QScopeDefinition(reader, scopeDefinitionHandle));
                }
                else
                {
                    scopeDefinitionGroup = new ScopeDefinitionGroup(new QScopeDefinition(reader, scopeDefinitionHandle));
                    groups.Add(defFullName, scopeDefinitionGroup);
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// This callback gets called whenever a module gets registered. It adds the metadata reader
        /// for the new module to the available scopes. The lock in ExecutionEnvironmentImplementation ensures
        /// that this function may never be called concurrently so that we can assume that two threads
        /// never update the reader and scope list at the same time.
        /// </summary>
        /// <param name="moduleHandle">Module handle to register</param>
        private void RegisterModule(IntPtr moduleHandle)
        {
            MetadataReader newReader = _executionEnvironment.GetMetadataReaderForModule(moduleHandle);
            if (newReader == null)
            {
                return;
            }

            // Build new reader list
            LowLevelListWithIList<MetadataReader> readers = new LowLevelListWithIList<MetadataReader>(_readers.Count + 1);
            foreach (MetadataReader oldReader in _readers)
            {
                readers.Add(oldReader);
            }
            readers.Add(newReader);

            LowLevelDictionaryWithIEnumerable<string, ScopeDefinitionGroup> scopeGroups = new LowLevelDictionaryWithIEnumerable<string, ScopeDefinitionGroup>();
            foreach (KeyValuePair<string, ScopeDefinitionGroup> oldGroup in _scopeGroups)
            {
                scopeGroups.Add(oldGroup.Key, oldGroup.Value);
            }
            AddScopesFromReaderToGroups(scopeGroups, newReader);

            // Update reader and scope list
            _readers = readers;
            _scopeGroups = scopeGroups;
        }
コード例 #13
0
 public AssemblyBinderImplementation(ExecutionEnvironmentImplementation executionEnvironment)
 {
     _executionEnvironment = executionEnvironment;
     _readers     = new LowLevelListWithIList <MetadataReader>();
     _scopeGroups = new LowLevelDictionaryWithIEnumerable <string, ScopeDefinitionGroup>();
 }
コード例 #14
0
ファイル: ExecutionContext.cs プロジェクト: justinvp/corert
 private ExecutionContext()
 {
     m_localValues = new LowLevelDictionaryWithIEnumerable<IAsyncLocal, object>();
     m_localChangeNotifications = new LowLevelListWithIList<IAsyncLocal>();
 }