| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 Compiler compilerFor(Map<String,String> memorySourceFiles, | 77 Compiler compilerFor(Map<String,String> memorySourceFiles, |
| 78 {DiagnosticHandler diagnosticHandler, | 78 {DiagnosticHandler diagnosticHandler, |
| 79 List<String> options: const [], | 79 List<String> options: const [], |
| 80 Compiler cachedCompiler, | 80 Compiler cachedCompiler, |
| 81 bool showDiagnostics: true}) { | 81 bool showDiagnostics: true}) { |
| 82 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); | 82 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); |
| 83 Uri libraryRoot = script.resolve('../../../sdk/'); | 83 Uri libraryRoot = script.resolve('../../../sdk/'); |
| 84 Uri packageRoot = script.resolve('./packages/'); | 84 Uri packageRoot = script.resolve('./packages/'); |
| 85 | 85 |
| 86 MemorySourceFileProvider.MEMORY_SOURCE_FILES = memorySourceFiles; | 86 var provider = new MemorySourceFileProvider(memorySourceFiles); |
| 87 var provider = new MemorySourceFileProvider(); | |
| 88 var handler = | 87 var handler = |
| 89 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); | 88 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); |
| 90 | 89 |
| 91 EventSink<String> outputProvider(String name, String extension) { | 90 EventSink<String> outputProvider(String name, String extension) { |
| 92 if (name != '') throw 'Attempt to output file "$name.$extension"'; | 91 if (name != '') throw 'Attempt to output file "$name.$extension"'; |
| 93 return new NullSink('$name.$extension'); | 92 return new NullSink('$name.$extension'); |
| 94 } | 93 } |
| 95 | 94 |
| 96 Compiler compiler = new Compiler(provider, | 95 Compiler compiler = new Compiler(provider.readStringFromUri, |
| 97 outputProvider, | 96 outputProvider, |
| 98 handler, | 97 handler, |
| 99 libraryRoot, | 98 libraryRoot, |
| 100 packageRoot, | 99 packageRoot, |
| 101 options); | 100 options); |
| 102 if (cachedCompiler != null) { | 101 if (cachedCompiler != null) { |
| 103 compiler.coreLibrary = cachedCompiler.libraries['dart:core']; | 102 compiler.coreLibrary = cachedCompiler.libraries['dart:core']; |
| 104 compiler.types = cachedCompiler.types; | 103 compiler.types = cachedCompiler.types; |
| 105 cachedCompiler.libraries.forEach((String uri, library) { | 104 cachedCompiler.libraries.forEach((String uri, library) { |
| 106 if (library.isPlatformLibrary) { | 105 if (library.isPlatformLibrary) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 134 } | 133 } |
| 135 | 134 |
| 136 Future<MirrorSystem> mirrorSystemFor(Map<String,String> memorySourceFiles, | 135 Future<MirrorSystem> mirrorSystemFor(Map<String,String> memorySourceFiles, |
| 137 {DiagnosticHandler diagnosticHandler, | 136 {DiagnosticHandler diagnosticHandler, |
| 138 List<String> options: const [], | 137 List<String> options: const [], |
| 139 bool showDiagnostics: true}) { | 138 bool showDiagnostics: true}) { |
| 140 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); | 139 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); |
| 141 Uri libraryRoot = script.resolve('../../../sdk/'); | 140 Uri libraryRoot = script.resolve('../../../sdk/'); |
| 142 Uri packageRoot = script.resolve('./packages/'); | 141 Uri packageRoot = script.resolve('./packages/'); |
| 143 | 142 |
| 144 MemorySourceFileProvider.MEMORY_SOURCE_FILES = memorySourceFiles; | 143 var provider = new MemorySourceFileProvider(memorySourceFiles); |
| 145 var provider = new MemorySourceFileProvider(); | |
| 146 var handler = | 144 var handler = |
| 147 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); | 145 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); |
| 148 | 146 |
| 149 List<Uri> libraries = <Uri>[]; | 147 List<Uri> libraries = <Uri>[]; |
| 150 memorySourceFiles.forEach((String path, _) { | 148 memorySourceFiles.forEach((String path, _) { |
| 151 libraries.add(new Uri(scheme: 'memory', path: path)); | 149 libraries.add(new Uri(scheme: 'memory', path: path)); |
| 152 }); | 150 }); |
| 153 | 151 |
| 154 return analyze(libraries, libraryRoot, packageRoot, | 152 return analyze(libraries, libraryRoot, packageRoot, |
| 155 provider, handler, options); | 153 provider, handler, options); |
| 156 } | 154 } |
| OLD | NEW |