OLD | NEW |
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; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 Expando<MemorySourceFileProvider> expando = | 124 Expando<MemorySourceFileProvider> expando = |
125 new Expando<MemorySourceFileProvider>(); | 125 new Expando<MemorySourceFileProvider>(); |
126 | 126 |
127 Future<CompilationResult> runCompiler( | 127 Future<CompilationResult> runCompiler( |
128 {Map<String, String> memorySourceFiles: const <String, String>{}, | 128 {Map<String, String> memorySourceFiles: const <String, String>{}, |
129 Uri entryPoint, | 129 Uri entryPoint, |
130 List<Uri> entryPoints, | 130 List<Uri> entryPoints, |
131 CompilerDiagnostics diagnosticHandler, | 131 CompilerDiagnostics diagnosticHandler, |
132 CompilerOutput outputProvider, | 132 CompilerOutput outputProvider, |
133 List<String> options: const <String>[], | 133 List<String> options: const <String>[], |
134 Compiler cachedCompiler, | 134 CompilerImpl cachedCompiler, |
135 bool showDiagnostics: true, | 135 bool showDiagnostics: true, |
136 Uri packageRoot, | 136 Uri packageRoot, |
137 Uri packageConfig, | 137 Uri packageConfig, |
138 PackagesDiscoveryProvider packagesDiscoveryProvider, | 138 PackagesDiscoveryProvider packagesDiscoveryProvider, |
139 void beforeRun(Compiler compiler)}) async { | 139 void beforeRun(CompilerImpl compiler)}) async { |
140 if (entryPoint == null) { | 140 if (entryPoint == null) { |
141 entryPoint = Uri.parse('memory:main.dart'); | 141 entryPoint = Uri.parse('memory:main.dart'); |
142 } | 142 } |
143 Compiler compiler = compilerFor( | 143 CompilerImpl compiler = compilerFor( |
144 memorySourceFiles: memorySourceFiles, | 144 memorySourceFiles: memorySourceFiles, |
145 diagnosticHandler: diagnosticHandler, | 145 diagnosticHandler: diagnosticHandler, |
146 outputProvider: outputProvider, | 146 outputProvider: outputProvider, |
147 options: options, | 147 options: options, |
148 cachedCompiler: cachedCompiler, | 148 cachedCompiler: cachedCompiler, |
149 showDiagnostics: showDiagnostics, | 149 showDiagnostics: showDiagnostics, |
150 packageRoot: packageRoot, | 150 packageRoot: packageRoot, |
151 packageConfig: packageConfig, | 151 packageConfig: packageConfig, |
152 packagesDiscoveryProvider: packagesDiscoveryProvider); | 152 packagesDiscoveryProvider: packagesDiscoveryProvider); |
153 compiler.librariesToAnalyzeWhenRun = entryPoints; | 153 compiler.librariesToAnalyzeWhenRun = entryPoints; |
154 if (beforeRun != null) { | 154 if (beforeRun != null) { |
155 beforeRun(compiler); | 155 beforeRun(compiler); |
156 } | 156 } |
157 bool isSuccess = await compiler.run(entryPoint); | 157 bool isSuccess = await compiler.run(entryPoint); |
158 return new CompilationResult(compiler, isSuccess: isSuccess); | 158 return new CompilationResult(compiler, isSuccess: isSuccess); |
159 } | 159 } |
160 | 160 |
161 Compiler compilerFor( | 161 CompilerImpl compilerFor( |
162 {Map<String, String> memorySourceFiles: const <String, String>{}, | 162 {Map<String, String> memorySourceFiles: const <String, String>{}, |
163 CompilerDiagnostics diagnosticHandler, | 163 CompilerDiagnostics diagnosticHandler, |
164 CompilerOutput outputProvider, | 164 CompilerOutput outputProvider, |
165 List<String> options: const <String>[], | 165 List<String> options: const <String>[], |
166 Compiler cachedCompiler, | 166 CompilerImpl cachedCompiler, |
167 bool showDiagnostics: true, | 167 bool showDiagnostics: true, |
168 Uri packageRoot, | 168 Uri packageRoot, |
169 Uri packageConfig, | 169 Uri packageConfig, |
170 PackagesDiscoveryProvider packagesDiscoveryProvider}) { | 170 PackagesDiscoveryProvider packagesDiscoveryProvider}) { |
171 Uri libraryRoot = Uri.base.resolve('sdk/'); | 171 Uri libraryRoot = Uri.base.resolve('sdk/'); |
172 if (packageRoot == null && | 172 if (packageRoot == null && |
173 packageConfig == null && | 173 packageConfig == null && |
174 packagesDiscoveryProvider == null) { | 174 packagesDiscoveryProvider == null) { |
175 packageRoot = Uri.base.resolveUri(new Uri.file('${Platform.packageRoot}/')); | 175 packageRoot = Uri.base.resolveUri(new Uri.file('${Platform.packageRoot}/')); |
176 } | 176 } |
(...skipping 12 matching lines...) Expand all Loading... |
189 } | 189 } |
190 diagnosticHandler = createCompilerDiagnostics( | 190 diagnosticHandler = createCompilerDiagnostics( |
191 diagnosticHandler, provider, | 191 diagnosticHandler, provider, |
192 showDiagnostics: showDiagnostics, | 192 showDiagnostics: showDiagnostics, |
193 verbose: options.contains('-v') || options.contains('--verbose')); | 193 verbose: options.contains('-v') || options.contains('--verbose')); |
194 | 194 |
195 if (outputProvider == null) { | 195 if (outputProvider == null) { |
196 outputProvider = const NullCompilerOutput(); | 196 outputProvider = const NullCompilerOutput(); |
197 } | 197 } |
198 | 198 |
199 Compiler compiler = new Compiler( | 199 CompilerImpl compiler = new CompilerImpl( |
200 provider, | 200 provider, |
201 outputProvider, | 201 outputProvider, |
202 diagnosticHandler, | 202 diagnosticHandler, |
203 libraryRoot, | 203 libraryRoot, |
204 packageRoot, | 204 packageRoot, |
205 options, | 205 options, |
206 {}, | 206 {}, |
207 packageConfig, | 207 packageConfig, |
208 packagesDiscoveryProvider); | 208 packagesDiscoveryProvider); |
209 | 209 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); | 330 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); |
331 | 331 |
332 List<Uri> libraries = <Uri>[]; | 332 List<Uri> libraries = <Uri>[]; |
333 memorySourceFiles.forEach((String path, _) { | 333 memorySourceFiles.forEach((String path, _) { |
334 libraries.add(new Uri(scheme: 'memory', path: path)); | 334 libraries.add(new Uri(scheme: 'memory', path: path)); |
335 }); | 335 }); |
336 | 336 |
337 return analyze(libraries, libraryRoot, packageRoot, | 337 return analyze(libraries, libraryRoot, packageRoot, |
338 provider, handler, options); | 338 provider, handler, options); |
339 } | 339 } |
OLD | NEW |