diff options
author | Michal Strehovský <michals@microsoft.com> | 2017-05-19 21:17:59 +0300 |
---|---|---|
committer | Michal Strehovský <michals@microsoft.com> | 2017-05-19 21:17:59 +0300 |
commit | 3a1bba7a4a13346ba3b73a21e795e32d2fe33e4e (patch) | |
tree | 6ac3f03a29cc7046009cf4210964af446fc0438b /src | |
parent | 37e220b1182629eb0100a79b67735c5341712f6d (diff) |
Move MetadataManager creation out of the builder
We'll want to allow compiler driver users to pick and configure the
metadata manager to their liking.
Diffstat (limited to 'src')
4 files changed, 13 insertions, 18 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/CompilationBuilder.cs b/src/ILCompiler.Compiler/src/Compiler/CompilationBuilder.cs index 698d7a46f..838606a9d 100644 --- a/src/ILCompiler.Compiler/src/Compiler/CompilationBuilder.cs +++ b/src/ILCompiler.Compiler/src/Compiler/CompilationBuilder.cs @@ -23,13 +23,14 @@ namespace ILCompiler protected IEnumerable<ICompilationRootProvider> _compilationRoots = Array.Empty<ICompilationRootProvider>(); protected OptimizationMode _optimizationMode = OptimizationMode.None; protected bool _generateDebugInfo = false; - private string _metadataLogFile = null; + protected MetadataManager _metadataManager; public CompilationBuilder(CompilerTypeSystemContext context, CompilationModuleGroup compilationGroup, NameMangler nameMangler) { _context = context; _compilationGroup = compilationGroup; _nameMangler = nameMangler; + _metadataManager = new EmptyMetadataManager(compilationGroup, context); } public CompilationBuilder UseLogger(Logger logger) @@ -44,21 +45,21 @@ namespace ILCompiler return this; } - public CompilationBuilder UseCompilationRoots(IEnumerable<ICompilationRootProvider> compilationRoots) + public CompilationBuilder UseMetadataManager(MetadataManager metadataManager) { - _compilationRoots = compilationRoots; + _metadataManager = metadataManager; return this; } - public CompilationBuilder UseOptimizationMode(OptimizationMode mode) + public CompilationBuilder UseCompilationRoots(IEnumerable<ICompilationRootProvider> compilationRoots) { - _optimizationMode = mode; + _compilationRoots = compilationRoots; return this; } - public CompilationBuilder UseMetadataLogFile(string fileName) + public CompilationBuilder UseOptimizationMode(OptimizationMode mode) { - _metadataLogFile = fileName; + _optimizationMode = mode; return this; } @@ -76,11 +77,6 @@ namespace ILCompiler return _dependencyTrackingLevel.CreateDependencyGraph(factory); } - protected MetadataManager CreateMetadataManager() - { - return new CompilerGeneratedMetadataManager(_compilationGroup, _context, _metadataLogFile); - } - public ILScannerBuilder GetILScannerBuilder(CompilationModuleGroup compilationGroup = null) { return new ILScannerBuilder(_context, compilationGroup ?? _compilationGroup, _nameMangler); diff --git a/src/ILCompiler.Compiler/src/Compiler/RyuJitCompilationBuilder.cs b/src/ILCompiler.Compiler/src/Compiler/RyuJitCompilationBuilder.cs index 58850e22c..20d9b497f 100644 --- a/src/ILCompiler.Compiler/src/Compiler/RyuJitCompilationBuilder.cs +++ b/src/ILCompiler.Compiler/src/Compiler/RyuJitCompilationBuilder.cs @@ -74,9 +74,7 @@ namespace ILCompiler if (_generateDebugInfo) jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_DEBUG_INFO); - MetadataManager metadataManager = CreateMetadataManager(); - - var factory = new RyuJitNodeFactory(_context, _compilationGroup, metadataManager, _nameMangler); + var factory = new RyuJitNodeFactory(_context, _compilationGroup, _metadataManager, _nameMangler); var jitConfig = new JitConfigProvider(jitFlagBuilder.ToArray(), _ryujitOptions); DependencyAnalyzerBase<NodeFactory> graph = CreateDependencyGraph(factory); diff --git a/src/ILCompiler.CppCodeGen/src/Compiler/CppCodegenCompilationBuilder.cs b/src/ILCompiler.CppCodeGen/src/Compiler/CppCodegenCompilationBuilder.cs index 0ad6851c0..7ea68e212 100644 --- a/src/ILCompiler.CppCodeGen/src/Compiler/CppCodegenCompilationBuilder.cs +++ b/src/ILCompiler.CppCodeGen/src/Compiler/CppCodegenCompilationBuilder.cs @@ -29,8 +29,7 @@ namespace ILCompiler public override ICompilation ToCompilation() { - MetadataManager metadataManager = CreateMetadataManager(); - CppCodegenNodeFactory factory = new CppCodegenNodeFactory(_context, _compilationGroup, metadataManager, _nameMangler); + CppCodegenNodeFactory factory = new CppCodegenNodeFactory(_context, _compilationGroup, _metadataManager, _nameMangler); DependencyAnalyzerBase<NodeFactory> graph = CreateDependencyGraph(factory); return new CppCodegenCompilation(graph, factory, _compilationRoots, _logger, _config); diff --git a/src/ILCompiler/src/Program.cs b/src/ILCompiler/src/Program.cs index ccb52f9c4..28d02f8be 100644 --- a/src/ILCompiler/src/Program.cs +++ b/src/ILCompiler/src/Program.cs @@ -335,14 +335,16 @@ namespace ILCompiler DependencyTrackingLevel trackingLevel = _dgmlLogFileName == null ? DependencyTrackingLevel.None : (_generateFullDgmlLog ? DependencyTrackingLevel.All : DependencyTrackingLevel.First); + CompilerGeneratedMetadataManager metadataManager = new CompilerGeneratedMetadataManager(compilationGroup, typeSystemContext, _metadataLogFileName); + ICompilation compilation = builder .UseBackendOptions(_codegenOptions) + .UseMetadataManager(metadataManager) .UseLogger(logger) .UseDependencyTracking(trackingLevel) .UseCompilationRoots(compilationRoots) .UseOptimizationMode(_optimizationMode) .UseDebugInfo(_enableDebugInfo) - .UseMetadataLogFile(_metadataLogFileName) .ToCompilation(); ObjectDumper dumper = _mapFileName != null ? new ObjectDumper(_mapFileName) : null; |