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 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 import 'memory_source_file_helper.dart'; | 8 import 'memory_source_file_helper.dart'; |
9 | 9 |
10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' | 10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 Expando<MemorySourceFileProvider> expando = | 77 Expando<MemorySourceFileProvider> expando = |
78 new Expando<MemorySourceFileProvider>(); | 78 new Expando<MemorySourceFileProvider>(); |
79 | 79 |
80 Compiler compilerFor(Map<String,String> memorySourceFiles, | 80 Compiler compilerFor(Map<String,String> memorySourceFiles, |
81 {DiagnosticHandler diagnosticHandler, | 81 {DiagnosticHandler diagnosticHandler, |
82 List<String> options: const [], | 82 List<String> options: const [], |
83 Compiler cachedCompiler, | 83 Compiler cachedCompiler, |
84 bool showDiagnostics: true}) { | 84 bool showDiagnostics: true}) { |
85 Uri script = currentDirectory.resolveUri(Platform.script); | 85 Uri script = currentDirectory.resolveUri(Platform.script); |
86 Uri libraryRoot = script.resolve('../../../sdk/'); | 86 Uri libraryRoot = script.resolve('../../../sdk/'); |
87 Uri packageRoot = script.resolve('./packages/'); | 87 Uri packageRoot = currentDirectory.resolve('${Platform.packageRoot}/'); |
88 | 88 |
89 MemorySourceFileProvider provider; | 89 MemorySourceFileProvider provider; |
90 var readStringFromUri; | 90 var readStringFromUri; |
91 if (cachedCompiler == null) { | 91 if (cachedCompiler == null) { |
92 provider = new MemorySourceFileProvider(memorySourceFiles); | 92 provider = new MemorySourceFileProvider(memorySourceFiles); |
93 readStringFromUri = provider.readStringFromUri; | 93 readStringFromUri = provider.readStringFromUri; |
94 // Saving the provider in case we need it later for a cached compiler. | 94 // Saving the provider in case we need it later for a cached compiler. |
95 expando[readStringFromUri] = provider; | 95 expando[readStringFromUri] = provider; |
96 } else { | 96 } else { |
97 // When using a cached compiler, it has read a number of files from disk | 97 // When using a cached compiler, it has read a number of files from disk |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); | 166 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); |
167 | 167 |
168 List<Uri> libraries = <Uri>[]; | 168 List<Uri> libraries = <Uri>[]; |
169 memorySourceFiles.forEach((String path, _) { | 169 memorySourceFiles.forEach((String path, _) { |
170 libraries.add(new Uri(scheme: 'memory', path: path)); | 170 libraries.add(new Uri(scheme: 'memory', path: path)); |
171 }); | 171 }); |
172 | 172 |
173 return analyze(libraries, libraryRoot, packageRoot, | 173 return analyze(libraries, libraryRoot, packageRoot, |
174 provider, handler, options); | 174 provider, handler, options); |
175 } | 175 } |
OLD | NEW |