| 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'; | |
| 8 import 'memory_source_file_helper.dart'; | 7 import 'memory_source_file_helper.dart'; |
| 9 | 8 |
| 10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' | 9 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' |
| 11 show NullSink; | 10 show NullSink; |
| 11 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; |
| 12 | 12 |
| 13 import '../../../sdk/lib/_internal/compiler/compiler.dart' | 13 import '../../../sdk/lib/_internal/compiler/compiler.dart' |
| 14 show Diagnostic, DiagnosticHandler; | 14 show Diagnostic, DiagnosticHandler; |
| 15 | 15 |
| 16 import 'dart:async'; | 16 import 'dart:async'; |
| 17 | 17 |
| 18 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'
; | 18 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'
; |
| 19 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro
r.dart'; | 19 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro
r.dart'; |
| 20 | 20 |
| 21 class DiagnosticMessage { | 21 class DiagnosticMessage { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return handler; | 74 return handler; |
| 75 } | 75 } |
| 76 | 76 |
| 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 packageRoot}) { |
| 85 Uri script = currentDirectory.resolveUri(Platform.script); | 86 Uri script = currentDirectory.resolveUri(Platform.script); |
| 86 Uri libraryRoot = script.resolve('../../../sdk/'); | 87 Uri libraryRoot = script.resolve('../../../sdk/'); |
| 87 Uri packageRoot = currentDirectory.resolve('${Platform.packageRoot}/'); | 88 if (packageRoot == null) { |
| 89 packageRoot = currentDirectory.resolve( |
| 90 appendSlash(nativeToUriPath(Platform.packageRoot))); |
| 91 } |
| 88 | 92 |
| 89 MemorySourceFileProvider provider; | 93 MemorySourceFileProvider provider; |
| 90 var readStringFromUri; | 94 var readStringFromUri; |
| 91 if (cachedCompiler == null) { | 95 if (cachedCompiler == null) { |
| 92 provider = new MemorySourceFileProvider(memorySourceFiles); | 96 provider = new MemorySourceFileProvider(memorySourceFiles); |
| 93 readStringFromUri = provider.readStringFromUri; | 97 readStringFromUri = provider.readStringFromUri; |
| 94 // Saving the provider in case we need it later for a cached compiler. | 98 // Saving the provider in case we need it later for a cached compiler. |
| 95 expando[readStringFromUri] = provider; | 99 expando[readStringFromUri] = provider; |
| 96 } else { | 100 } else { |
| 97 // When using a cached compiler, it has read a number of files from disk | 101 // 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); | 170 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); |
| 167 | 171 |
| 168 List<Uri> libraries = <Uri>[]; | 172 List<Uri> libraries = <Uri>[]; |
| 169 memorySourceFiles.forEach((String path, _) { | 173 memorySourceFiles.forEach((String path, _) { |
| 170 libraries.add(new Uri(scheme: 'memory', path: path)); | 174 libraries.add(new Uri(scheme: 'memory', path: path)); |
| 171 }); | 175 }); |
| 172 | 176 |
| 173 return analyze(libraries, libraryRoot, packageRoot, | 177 return analyze(libraries, libraryRoot, packageRoot, |
| 174 provider, handler, options); | 178 provider, handler, options); |
| 175 } | 179 } |
| OLD | NEW |