| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library dart2js.test.memory_compiler; |
| 6 |
| 7 import 'package:expect/expect.dart'; |
| 8 import 'memory_source_file_helper.dart'; |
| 9 |
| 10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' |
| 11 show NullSink; |
| 12 |
| 13 import '../../../sdk/lib/_internal/compiler/compiler.dart' |
| 14 show DiagnosticHandler; |
| 15 |
| 16 import 'dart:async'; |
| 17 |
| 18 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'
; |
| 19 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro
r.dart'; |
| 20 |
| 21 Compiler compilerFor(Map<String,String> memorySourceFiles, |
| 22 {DiagnosticHandler diagnosticHandler, |
| 23 List<String> options: const []}) { |
| 24 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); |
| 25 Uri libraryRoot = script.resolve('../../../sdk/'); |
| 26 Uri packageRoot = script.resolve('./packages/'); |
| 27 |
| 28 MemorySourceFileProvider.MEMORY_SOURCE_FILES = memorySourceFiles; |
| 29 var provider = new MemorySourceFileProvider(); |
| 30 if (diagnosticHandler == null) { |
| 31 diagnosticHandler = new FormattingDiagnosticHandler(provider); |
| 32 } |
| 33 |
| 34 EventSink<String> outputProvider(String name, String extension) { |
| 35 if (name != '') throw 'Attempt to output file "$name.$extension"'; |
| 36 return new NullSink('$name.$extension'); |
| 37 } |
| 38 |
| 39 Compiler compiler = new Compiler(provider.readStringFromUri, |
| 40 outputProvider, |
| 41 diagnosticHandler, |
| 42 libraryRoot, |
| 43 packageRoot, |
| 44 options); |
| 45 return compiler; |
| 46 } |
| 47 |
| 48 Future<MirrorSystem> mirrorSystemFor(Map<String,String> memorySourceFiles, |
| 49 {DiagnosticHandler diagnosticHandler, |
| 50 List<String> options: const []}) { |
| 51 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); |
| 52 Uri libraryRoot = script.resolve('../../../sdk/'); |
| 53 Uri packageRoot = script.resolve('./packages/'); |
| 54 |
| 55 MemorySourceFileProvider.MEMORY_SOURCE_FILES = memorySourceFiles; |
| 56 var provider = new MemorySourceFileProvider(); |
| 57 if (diagnosticHandler == null) { |
| 58 diagnosticHandler = new FormattingDiagnosticHandler(provider); |
| 59 } |
| 60 |
| 61 List<Uri> libraries = <Uri>[]; |
| 62 memorySourceFiles.forEach((String path, _) { |
| 63 libraries.add(new Uri(scheme: 'memory', path: path)); |
| 64 }); |
| 65 |
| 66 return analyze(libraries, libraryRoot, packageRoot, |
| 67 provider, diagnosticHandler, options); |
| 68 } |
| OLD | NEW |