| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 return handler; | 64 return handler; |
| 65 } | 65 } |
| 66 | 66 |
| 67 Expando<MemorySourceFileProvider> expando = | 67 Expando<MemorySourceFileProvider> expando = |
| 68 new Expando<MemorySourceFileProvider>(); | 68 new Expando<MemorySourceFileProvider>(); |
| 69 | 69 |
| 70 Future<CompilationResult> runCompiler( | 70 Future<CompilationResult> runCompiler( |
| 71 {Map<String, String> memorySourceFiles: const <String, String>{}, | 71 {Map<String, String> memorySourceFiles: const <String, String>{}, |
| 72 Uri entryPoint, | 72 Uri entryPoint, |
| 73 List<Uri> entryPoints, | 73 List<Uri> entryPoints, |
| 74 List<Uri> resolutionInputs, |
| 74 CompilerDiagnostics diagnosticHandler, | 75 CompilerDiagnostics diagnosticHandler, |
| 75 CompilerOutput outputProvider, | 76 CompilerOutput outputProvider, |
| 76 List<String> options: const <String>[], | 77 List<String> options: const <String>[], |
| 77 CompilerImpl cachedCompiler, | 78 CompilerImpl cachedCompiler, |
| 78 bool showDiagnostics: true, | 79 bool showDiagnostics: true, |
| 79 Uri packageRoot, | 80 Uri packageRoot, |
| 80 Uri packageConfig, | 81 Uri packageConfig, |
| 81 PackagesDiscoveryProvider packagesDiscoveryProvider, | 82 PackagesDiscoveryProvider packagesDiscoveryProvider, |
| 82 void beforeRun(CompilerImpl compiler)}) async { | 83 void beforeRun(CompilerImpl compiler)}) async { |
| 83 if (entryPoint == null) { | 84 if (entryPoint == null) { |
| 84 entryPoint = Uri.parse('memory:main.dart'); | 85 entryPoint = Uri.parse('memory:main.dart'); |
| 85 } | 86 } |
| 86 CompilerImpl compiler = compilerFor( | 87 CompilerImpl compiler = compilerFor( |
| 87 entryPoint: entryPoint, | 88 entryPoint: entryPoint, |
| 89 resolutionInputs: resolutionInputs, |
| 88 memorySourceFiles: memorySourceFiles, | 90 memorySourceFiles: memorySourceFiles, |
| 89 diagnosticHandler: diagnosticHandler, | 91 diagnosticHandler: diagnosticHandler, |
| 90 outputProvider: outputProvider, | 92 outputProvider: outputProvider, |
| 91 options: options, | 93 options: options, |
| 92 cachedCompiler: cachedCompiler, | 94 cachedCompiler: cachedCompiler, |
| 93 showDiagnostics: showDiagnostics, | 95 showDiagnostics: showDiagnostics, |
| 94 packageRoot: packageRoot, | 96 packageRoot: packageRoot, |
| 95 packageConfig: packageConfig, | 97 packageConfig: packageConfig, |
| 96 packagesDiscoveryProvider: packagesDiscoveryProvider); | 98 packagesDiscoveryProvider: packagesDiscoveryProvider); |
| 97 compiler.librariesToAnalyzeWhenRun = entryPoints; | 99 compiler.librariesToAnalyzeWhenRun = entryPoints; |
| 98 if (beforeRun != null) { | 100 if (beforeRun != null) { |
| 99 beforeRun(compiler); | 101 beforeRun(compiler); |
| 100 } | 102 } |
| 101 bool isSuccess = await compiler.run(entryPoint); | 103 bool isSuccess = await compiler.run(entryPoint); |
| 102 return new CompilationResult(compiler, isSuccess: isSuccess); | 104 return new CompilationResult(compiler, isSuccess: isSuccess); |
| 103 } | 105 } |
| 104 | 106 |
| 105 CompilerImpl compilerFor( | 107 CompilerImpl compilerFor( |
| 106 {Uri entryPoint, | 108 {Uri entryPoint, |
| 109 List<Uri> resolutionInputs, |
| 107 Map<String, String> memorySourceFiles: const <String, String>{}, | 110 Map<String, String> memorySourceFiles: const <String, String>{}, |
| 108 CompilerDiagnostics diagnosticHandler, | 111 CompilerDiagnostics diagnosticHandler, |
| 109 CompilerOutput outputProvider, | 112 CompilerOutput outputProvider, |
| 110 List<String> options: const <String>[], | 113 List<String> options: const <String>[], |
| 111 CompilerImpl cachedCompiler, | 114 CompilerImpl cachedCompiler, |
| 112 bool showDiagnostics: true, | 115 bool showDiagnostics: true, |
| 113 Uri packageRoot, | 116 Uri packageRoot, |
| 114 Uri packageConfig, | 117 Uri packageConfig, |
| 115 PackagesDiscoveryProvider packagesDiscoveryProvider}) { | 118 PackagesDiscoveryProvider packagesDiscoveryProvider}) { |
| 116 Uri libraryRoot = Uri.base.resolve('sdk/'); | 119 Uri libraryRoot = Uri.base.resolve('sdk/'); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 140 if (outputProvider == null) { | 143 if (outputProvider == null) { |
| 141 outputProvider = const NullCompilerOutput(); | 144 outputProvider = const NullCompilerOutput(); |
| 142 } | 145 } |
| 143 | 146 |
| 144 CompilerImpl compiler = new CompilerImpl( | 147 CompilerImpl compiler = new CompilerImpl( |
| 145 provider, | 148 provider, |
| 146 outputProvider, | 149 outputProvider, |
| 147 diagnosticHandler, | 150 diagnosticHandler, |
| 148 new CompilerOptions.parse( | 151 new CompilerOptions.parse( |
| 149 entryPoint: entryPoint, | 152 entryPoint: entryPoint, |
| 153 resolutionInputs: resolutionInputs, |
| 150 libraryRoot: libraryRoot, | 154 libraryRoot: libraryRoot, |
| 151 packageRoot: packageRoot, | 155 packageRoot: packageRoot, |
| 152 options: options, | 156 options: options, |
| 153 environment: {}, | 157 environment: {}, |
| 154 packageConfig: packageConfig, | 158 packageConfig: packageConfig, |
| 155 packagesDiscoveryProvider: packagesDiscoveryProvider)); | 159 packagesDiscoveryProvider: packagesDiscoveryProvider)); |
| 156 | 160 |
| 157 if (cachedCompiler != null) { | 161 if (cachedCompiler != null) { |
| 158 compiler.coreLibrary = | 162 compiler.coreLibrary = |
| 159 cachedCompiler.libraryLoader.lookupLibrary(Uri.parse('dart:core')); | 163 cachedCompiler.libraryLoader.lookupLibrary(Uri.parse('dart:core')); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) { | 254 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) { |
| 251 diagnosticHandler(uri, begin, end, message, kind); | 255 diagnosticHandler(uri, begin, end, message, kind); |
| 252 formattingHandler(uri, begin, end, message, kind); | 256 formattingHandler(uri, begin, end, message, kind); |
| 253 }; | 257 }; |
| 254 } | 258 } |
| 255 } else if (diagnosticHandler == null) { | 259 } else if (diagnosticHandler == null) { |
| 256 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) {}; | 260 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) {}; |
| 257 } | 261 } |
| 258 return handler; | 262 return handler; |
| 259 } | 263 } |
| OLD | NEW |