Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(988)

Side by Side Diff: tests/compiler/dart2js/memory_compiler.dart

Issue 1803303002: Move all flags to CompilerOptions (first step to stop passing the compiler to (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.test.memory_compiler; 5 library dart2js.test.memory_compiler;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:compiler/compiler.dart' show 9 import 'package:compiler/compiler.dart' show
10 DiagnosticHandler; 10 DiagnosticHandler;
11 import 'package:compiler/compiler_new.dart' show 11 import 'package:compiler/compiler_new.dart' show
12 CompilationResult, 12 CompilationResult,
13 CompilerDiagnostics, 13 CompilerDiagnostics,
14 CompilerOptions,
14 CompilerOutput, 15 CompilerOutput,
15 Diagnostic, 16 Diagnostic,
16 PackagesDiscoveryProvider; 17 PackagesDiscoveryProvider;
17 import 'package:compiler/src/diagnostics/messages.dart' show 18 import 'package:compiler/src/diagnostics/messages.dart' show
18 Message; 19 Message;
19 import 'package:compiler/src/null_compiler_output.dart' show 20 import 'package:compiler/src/null_compiler_output.dart' show
20 NullCompilerOutput; 21 NullCompilerOutput;
21 import 'package:compiler/src/library_loader.dart' show 22 import 'package:compiler/src/library_loader.dart' show
22 LoadedLibraries; 23 LoadedLibraries;
23 24
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 68
68 Future<CompilationResult> runCompiler( 69 Future<CompilationResult> runCompiler(
69 {Map<String, String> memorySourceFiles: const <String, String>{}, 70 {Map<String, String> memorySourceFiles: const <String, String>{},
70 Uri entryPoint, 71 Uri entryPoint,
71 List<Uri> entryPoints, 72 List<Uri> entryPoints,
72 CompilerDiagnostics diagnosticHandler, 73 CompilerDiagnostics diagnosticHandler,
73 CompilerOutput outputProvider, 74 CompilerOutput outputProvider,
74 List<String> options: const <String>[], 75 List<String> options: const <String>[],
75 CompilerImpl cachedCompiler, 76 CompilerImpl cachedCompiler,
76 bool showDiagnostics: true, 77 bool showDiagnostics: true,
78 bool disableInlining: false,
77 Uri packageRoot, 79 Uri packageRoot,
78 Uri packageConfig, 80 Uri packageConfig,
79 PackagesDiscoveryProvider packagesDiscoveryProvider, 81 PackagesDiscoveryProvider packagesDiscoveryProvider,
80 void beforeRun(CompilerImpl compiler)}) async { 82 void beforeRun(CompilerImpl compiler)}) async {
81 if (entryPoint == null) { 83 if (entryPoint == null) {
82 entryPoint = Uri.parse('memory:main.dart'); 84 entryPoint = Uri.parse('memory:main.dart');
83 } 85 }
84 CompilerImpl compiler = compilerFor( 86 CompilerImpl compiler = compilerFor(
87 entryPoint: entryPoint,
85 memorySourceFiles: memorySourceFiles, 88 memorySourceFiles: memorySourceFiles,
86 diagnosticHandler: diagnosticHandler, 89 diagnosticHandler: diagnosticHandler,
87 outputProvider: outputProvider, 90 outputProvider: outputProvider,
91 disableInlining: disableInlining,
88 options: options, 92 options: options,
89 cachedCompiler: cachedCompiler, 93 cachedCompiler: cachedCompiler,
90 showDiagnostics: showDiagnostics, 94 showDiagnostics: showDiagnostics,
91 packageRoot: packageRoot, 95 packageRoot: packageRoot,
92 packageConfig: packageConfig, 96 packageConfig: packageConfig,
93 packagesDiscoveryProvider: packagesDiscoveryProvider); 97 packagesDiscoveryProvider: packagesDiscoveryProvider);
94 compiler.librariesToAnalyzeWhenRun = entryPoints; 98 compiler.librariesToAnalyzeWhenRun = entryPoints;
95 if (beforeRun != null) { 99 if (beforeRun != null) {
96 beforeRun(compiler); 100 beforeRun(compiler);
97 } 101 }
98 bool isSuccess = await compiler.run(entryPoint); 102 bool isSuccess = await compiler.run(entryPoint);
99 return new CompilationResult(compiler, isSuccess: isSuccess); 103 return new CompilationResult(compiler, isSuccess: isSuccess);
100 } 104 }
101 105
102 CompilerImpl compilerFor( 106 CompilerImpl compilerFor(
103 {Map<String, String> memorySourceFiles: const <String, String>{}, 107 {Uri entryPoint,
108 Map<String, String> memorySourceFiles: const <String, String>{},
104 CompilerDiagnostics diagnosticHandler, 109 CompilerDiagnostics diagnosticHandler,
105 CompilerOutput outputProvider, 110 CompilerOutput outputProvider,
106 List<String> options: const <String>[], 111 List<String> options: const <String>[],
107 CompilerImpl cachedCompiler, 112 CompilerImpl cachedCompiler,
108 bool showDiagnostics: true, 113 bool showDiagnostics: true,
114 bool disableInlining: false,
109 Uri packageRoot, 115 Uri packageRoot,
110 Uri packageConfig, 116 Uri packageConfig,
111 PackagesDiscoveryProvider packagesDiscoveryProvider}) { 117 PackagesDiscoveryProvider packagesDiscoveryProvider}) {
112 Uri libraryRoot = Uri.base.resolve('sdk/'); 118 Uri libraryRoot = Uri.base.resolve('sdk/');
113 if (packageRoot == null && 119 if (packageRoot == null &&
114 packageConfig == null && 120 packageConfig == null &&
115 packagesDiscoveryProvider == null) { 121 packagesDiscoveryProvider == null) {
116 packageRoot = Uri.base.resolve(Platform.packageRoot); 122 packageRoot = Uri.base.resolve(Platform.packageRoot);
117 } 123 }
118 124
(...skipping 15 matching lines...) Expand all
134 verbose: options.contains('-v') || options.contains('--verbose')); 140 verbose: options.contains('-v') || options.contains('--verbose'));
135 141
136 if (outputProvider == null) { 142 if (outputProvider == null) {
137 outputProvider = const NullCompilerOutput(); 143 outputProvider = const NullCompilerOutput();
138 } 144 }
139 145
140 CompilerImpl compiler = new CompilerImpl( 146 CompilerImpl compiler = new CompilerImpl(
141 provider, 147 provider,
142 outputProvider, 148 outputProvider,
143 diagnosticHandler, 149 diagnosticHandler,
144 libraryRoot, 150 new CompilerOptions.parse(
145 packageRoot, 151 entryPoint: entryPoint,
146 options, 152 libraryRoot: libraryRoot,
147 {}, 153 packageRoot: packageRoot,
148 packageConfig, 154 disableInlining: disableInlining,
149 packagesDiscoveryProvider); 155 options: options,
156 environment: {},
157 packageConfig: packageConfig,
158 packagesDiscoveryProvider: packagesDiscoveryProvider));
150 159
151 if (cachedCompiler != null) { 160 if (cachedCompiler != null) {
152 compiler.coreLibrary = 161 compiler.coreLibrary =
153 cachedCompiler.libraryLoader.lookupLibrary(Uri.parse('dart:core')); 162 cachedCompiler.libraryLoader.lookupLibrary(Uri.parse('dart:core'));
154 compiler.types = cachedCompiler.types.copy(compiler.resolution); 163 compiler.types = cachedCompiler.types.copy(compiler.resolution);
155 Map copiedLibraries = {}; 164 Map copiedLibraries = {};
156 cachedCompiler.libraryLoader.libraries.forEach((library) { 165 cachedCompiler.libraryLoader.libraries.forEach((library) {
157 if (library.isPlatformLibrary) { 166 if (library.isPlatformLibrary) {
158 var libraryLoader = compiler.libraryLoader; 167 var libraryLoader = compiler.libraryLoader;
159 libraryLoader.mapLibrary(library); 168 libraryLoader.mapLibrary(library);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 cachedCompiler.resolver = null; 213 cachedCompiler.resolver = null;
205 cachedCompiler.closureToClassMapper = null; 214 cachedCompiler.closureToClassMapper = null;
206 cachedCompiler.checker = null; 215 cachedCompiler.checker = null;
207 cachedCompiler.typesTask = null; 216 cachedCompiler.typesTask = null;
208 cachedCompiler.backend = null; 217 cachedCompiler.backend = null;
209 // Don't null out the enqueuer as it prevents us from using cachedCompiler 218 // Don't null out the enqueuer as it prevents us from using cachedCompiler
210 // more than once. 219 // more than once.
211 cachedCompiler.deferredLoadTask = null; 220 cachedCompiler.deferredLoadTask = null;
212 cachedCompiler.mirrorUsageAnalyzerTask = null; 221 cachedCompiler.mirrorUsageAnalyzerTask = null;
213 cachedCompiler.dumpInfoTask = null; 222 cachedCompiler.dumpInfoTask = null;
214 cachedCompiler.buildId = null;
215 } 223 }
216 return compiler; 224 return compiler;
217 } 225 }
218 226
219 class MemoryLoadedLibraries implements LoadedLibraries { 227 class MemoryLoadedLibraries implements LoadedLibraries {
220 final Map copiedLibraries; 228 final Map copiedLibraries;
221 229
222 MemoryLoadedLibraries(this.copiedLibraries); 230 MemoryLoadedLibraries(this.copiedLibraries);
223 231
224 @override 232 @override
(...skipping 25 matching lines...) Expand all
250 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) { 258 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) {
251 diagnosticHandler(uri, begin, end, message, kind); 259 diagnosticHandler(uri, begin, end, message, kind);
252 formattingHandler(uri, begin, end, message, kind); 260 formattingHandler(uri, begin, end, message, kind);
253 }; 261 };
254 } 262 }
255 } else if (diagnosticHandler == null) { 263 } else if (diagnosticHandler == null) {
256 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) {}; 264 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) {};
257 } 265 }
258 return handler; 266 return handler;
259 } 267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698