Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs')
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs49
1 files changed, 5 insertions, 44 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs b/src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs
index cf9222cb8..e970fdd76 100644
--- a/src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs
@@ -2,12 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Collections.Generic;
using Internal.TypeSystem;
-using AssemblyName = System.Reflection.AssemblyName;
using Debug = System.Diagnostics.Debug;
namespace ILCompiler
@@ -17,37 +15,22 @@ namespace ILCompiler
/// </summary>
public sealed class LibraryInitializers
{
- private const string ClassLibraryPlaceHolderString = "*ClassLibrary*";
private const string LibraryInitializerContainerNamespaceName = "Internal.Runtime.CompilerHelpers";
private const string LibraryInitializerContainerTypeName = "LibraryInitializer";
private const string LibraryInitializerMethodName = "InitializeLibrary";
- private static readonly LibraryInitializerInfo[] s_assembliesWithLibraryInitializers =
- {
- new LibraryInitializerInfo(ClassLibraryPlaceHolderString),
- new LibraryInitializerInfo("System.Private.TypeLoader"),
- new LibraryInitializerInfo("System.Private.Reflection.Execution"),
- new LibraryInitializerInfo("System.Private.DeveloperExperience.Console"),
- new LibraryInitializerInfo("System.Private.Interop"),
- new LibraryInitializerInfo("System.Private.StackTraceMetadata"),
- };
-
private List<MethodDesc> _libraryInitializerMethods;
private readonly TypeSystemContext _context;
- private readonly bool _isCppCodeGen;
+ private IReadOnlyCollection<ModuleDesc> _librariesWithInitializers;
- public LibraryInitializers(TypeSystemContext context, bool isCppCodeGen)
+ public LibraryInitializers(TypeSystemContext context, IEnumerable<ModuleDesc> librariesWithInitalizers)
{
_context = context;
- //
- // We should not care which code-gen is being used but for the time being
- // this can be useful to workaround CppCodeGen bugs.
- //
- _isCppCodeGen = isCppCodeGen;
+ _librariesWithInitializers = new List<ModuleDesc>(librariesWithInitalizers);
}
- public IList<MethodDesc> LibraryInitializerMethods
+ public IReadOnlyCollection<MethodDesc> LibraryInitializerMethods
{
get
{
@@ -64,18 +47,8 @@ namespace ILCompiler
_libraryInitializerMethods = new List<MethodDesc>();
- foreach (var entry in s_assembliesWithLibraryInitializers)
+ foreach (var assembly in _librariesWithInitializers)
{
- if (_isCppCodeGen && !entry.UseWithCppCodeGen)
- continue;
-
- ModuleDesc assembly = entry.Assembly == ClassLibraryPlaceHolderString
- ? _context.SystemModule
- : _context.ResolveAssembly(new AssemblyName(entry.Assembly), false);
-
- if (assembly == null)
- continue;
-
TypeDesc containingType = assembly.GetType(LibraryInitializerContainerNamespaceName, LibraryInitializerContainerTypeName, false);
if (containingType == null)
continue;
@@ -87,17 +60,5 @@ namespace ILCompiler
_libraryInitializerMethods.Add(initializerMethod);
}
}
-
- private sealed class LibraryInitializerInfo
- {
- public string Assembly { get; }
- public bool UseWithCppCodeGen { get; }
-
- public LibraryInitializerInfo(string assembly, bool useWithCppCodeGen = true)
- {
- Assembly = assembly;
- UseWithCppCodeGen = useWithCppCodeGen;
- }
- }
}
}