| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 return handler; | 66 return handler; |
| 67 } | 67 } |
| 68 | 68 |
| 69 Expando<MemorySourceFileProvider> expando = | 69 Expando<MemorySourceFileProvider> expando = |
| 70 new Expando<MemorySourceFileProvider>(); | 70 new Expando<MemorySourceFileProvider>(); |
| 71 | 71 |
| 72 Future<CompilationResult> runCompiler( | 72 Future<CompilationResult> runCompiler( |
| 73 {Map<String, String> memorySourceFiles: const <String, String>{}, | 73 {Map<String, String> memorySourceFiles: const <String, String>{}, |
| 74 Uri entryPoint, | 74 Uri entryPoint, |
| 75 List<Uri> entryPoints, | 75 List<Uri> entryPoints, |
| 76 List<Uri> resolutionInputs, |
| 76 CompilerDiagnostics diagnosticHandler, | 77 CompilerDiagnostics diagnosticHandler, |
| 77 CompilerOutput outputProvider, | 78 CompilerOutput outputProvider, |
| 78 List<String> options: const <String>[], | 79 List<String> options: const <String>[], |
| 79 CompilerImpl cachedCompiler, | 80 CompilerImpl cachedCompiler, |
| 80 bool showDiagnostics: true, | 81 bool showDiagnostics: true, |
| 81 Uri packageRoot, | 82 Uri packageRoot, |
| 82 Uri packageConfig, | 83 Uri packageConfig, |
| 83 PackagesDiscoveryProvider packagesDiscoveryProvider, | 84 PackagesDiscoveryProvider packagesDiscoveryProvider, |
| 84 void beforeRun(CompilerImpl compiler)}) async { | 85 void beforeRun(CompilerImpl compiler)}) async { |
| 85 if (entryPoint == null) { | 86 if (entryPoint == null) { |
| 86 entryPoint = Uri.parse('memory:main.dart'); | 87 entryPoint = Uri.parse('memory:main.dart'); |
| 87 } | 88 } |
| 88 CompilerImpl compiler = compilerFor( | 89 CompilerImpl compiler = compilerFor( |
| 89 entryPoint: entryPoint, | 90 entryPoint: entryPoint, |
| 91 resolutionInputs: resolutionInputs, |
| 90 memorySourceFiles: memorySourceFiles, | 92 memorySourceFiles: memorySourceFiles, |
| 91 diagnosticHandler: diagnosticHandler, | 93 diagnosticHandler: diagnosticHandler, |
| 92 outputProvider: outputProvider, | 94 outputProvider: outputProvider, |
| 93 options: options, | 95 options: options, |
| 94 cachedCompiler: cachedCompiler, | 96 cachedCompiler: cachedCompiler, |
| 95 showDiagnostics: showDiagnostics, | 97 showDiagnostics: showDiagnostics, |
| 96 packageRoot: packageRoot, | 98 packageRoot: packageRoot, |
| 97 packageConfig: packageConfig, | 99 packageConfig: packageConfig, |
| 98 packagesDiscoveryProvider: packagesDiscoveryProvider); | 100 packagesDiscoveryProvider: packagesDiscoveryProvider); |
| 99 compiler.librariesToAnalyzeWhenRun = entryPoints; | 101 compiler.librariesToAnalyzeWhenRun = entryPoints; |
| 100 if (beforeRun != null) { | 102 if (beforeRun != null) { |
| 101 beforeRun(compiler); | 103 beforeRun(compiler); |
| 102 } | 104 } |
| 103 bool isSuccess = await compiler.run(entryPoint); | 105 bool isSuccess = await compiler.run(entryPoint); |
| 104 return new CompilationResult(compiler, isSuccess: isSuccess); | 106 return new CompilationResult(compiler, isSuccess: isSuccess); |
| 105 } | 107 } |
| 106 | 108 |
| 107 CompilerImpl compilerFor( | 109 CompilerImpl compilerFor( |
| 108 {Uri entryPoint, | 110 {Uri entryPoint, |
| 111 List<Uri> resolutionInputs, |
| 109 Map<String, String> memorySourceFiles: const <String, String>{}, | 112 Map<String, String> memorySourceFiles: const <String, String>{}, |
| 110 CompilerDiagnostics diagnosticHandler, | 113 CompilerDiagnostics diagnosticHandler, |
| 111 CompilerOutput outputProvider, | 114 CompilerOutput outputProvider, |
| 112 List<String> options: const <String>[], | 115 List<String> options: const <String>[], |
| 113 CompilerImpl cachedCompiler, | 116 CompilerImpl cachedCompiler, |
| 114 bool showDiagnostics: true, | 117 bool showDiagnostics: true, |
| 115 Uri packageRoot, | 118 Uri packageRoot, |
| 116 Uri packageConfig, | 119 Uri packageConfig, |
| 117 PackagesDiscoveryProvider packagesDiscoveryProvider}) { | 120 PackagesDiscoveryProvider packagesDiscoveryProvider}) { |
| 118 Uri libraryRoot = Uri.base.resolve('sdk/'); | 121 Uri libraryRoot = Uri.base.resolve('sdk/'); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 142 if (outputProvider == null) { | 145 if (outputProvider == null) { |
| 143 outputProvider = const NullCompilerOutput(); | 146 outputProvider = const NullCompilerOutput(); |
| 144 } | 147 } |
| 145 | 148 |
| 146 CompilerImpl compiler = new CompilerImpl( | 149 CompilerImpl compiler = new CompilerImpl( |
| 147 provider, | 150 provider, |
| 148 outputProvider, | 151 outputProvider, |
| 149 diagnosticHandler, | 152 diagnosticHandler, |
| 150 new CompilerOptions.parse( | 153 new CompilerOptions.parse( |
| 151 entryPoint: entryPoint, | 154 entryPoint: entryPoint, |
| 155 resolutionInputs: resolutionInputs, |
| 152 libraryRoot: libraryRoot, | 156 libraryRoot: libraryRoot, |
| 153 packageRoot: packageRoot, | 157 packageRoot: packageRoot, |
| 154 options: options, | 158 options: options, |
| 155 environment: {}, | 159 environment: {}, |
| 156 packageConfig: packageConfig, | 160 packageConfig: packageConfig, |
| 157 packagesDiscoveryProvider: packagesDiscoveryProvider)); | 161 packagesDiscoveryProvider: packagesDiscoveryProvider)); |
| 158 | 162 |
| 159 if (cachedCompiler != null) { | 163 if (cachedCompiler != null) { |
| 160 compiler.coreLibrary = | 164 compiler.coreLibrary = |
| 161 cachedCompiler.libraryLoader.lookupLibrary(Uri.parse('dart:core')); | 165 cachedCompiler.libraryLoader.lookupLibrary(Uri.parse('dart:core')); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); | 276 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); |
| 273 | 277 |
| 274 List<Uri> libraries = <Uri>[]; | 278 List<Uri> libraries = <Uri>[]; |
| 275 memorySourceFiles.forEach((String path, _) { | 279 memorySourceFiles.forEach((String path, _) { |
| 276 libraries.add(new Uri(scheme: 'memory', path: path)); | 280 libraries.add(new Uri(scheme: 'memory', path: path)); |
| 277 }); | 281 }); |
| 278 | 282 |
| 279 return analyze(libraries, libraryRoot, packageRoot, | 283 return analyze(libraries, libraryRoot, packageRoot, |
| 280 provider, handler, options); | 284 provider, handler, options); |
| 281 } | 285 } |
| OLD | NEW |