| 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' |
| 11 show NullSink; | 11 show NullSink; |
| 12 | 12 |
| 13 import '../../../sdk/lib/_internal/compiler/compiler.dart' | 13 import '../../../sdk/lib/_internal/compiler/compiler.dart' |
| 14 show DiagnosticHandler; | 14 show 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 Compiler compilerFor(Map<String,String> memorySourceFiles, | 21 Compiler compilerFor(Map<String,String> memorySourceFiles, |
| 22 {DiagnosticHandler diagnosticHandler, | 22 {DiagnosticHandler diagnosticHandler, |
| 23 List<String> options: const []}) { | 23 List<String> options: const []}) { |
| 24 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); | 24 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); |
| 25 Uri libraryRoot = script.resolve('../../../sdk/'); | 25 Uri libraryRoot = script.resolve('../../../sdk/'); |
| 26 Uri packageRoot = script.resolve('./packages/'); | 26 Uri packageRoot = script.resolve('./packages/'); |
| 27 | 27 |
| 28 MemorySourceFileProvider.MEMORY_SOURCE_FILES = memorySourceFiles; | 28 MemorySourceFileProvider.MEMORY_SOURCE_FILES = memorySourceFiles; |
| 29 var provider = new MemorySourceFileProvider(); | 29 var provider = new MemorySourceFileProvider(); |
| 30 if (diagnosticHandler == null) { | 30 if (diagnosticHandler == null) { |
| 31 diagnosticHandler = new FormattingDiagnosticHandler(provider); | 31 diagnosticHandler = new FormattingDiagnosticHandler(provider); |
| 32 } | 32 } |
| 33 | 33 |
| 34 EventSink<String> outputProvider(String name, String extension) { | 34 EventSink<String> outputProvider(String name, String extension) { |
| 35 if (name != '') throw 'Attempt to output file "$name.$extension"'; | 35 if (name != '') throw 'Attempt to output file "$name.$extension"'; |
| 36 return new NullSink('$name.$extension'); | 36 return new NullSink('$name.$extension'); |
| 37 } | 37 } |
| 38 | 38 |
| 39 Compiler compiler = new Compiler(provider.readStringFromUri, | 39 Compiler compiler = new Compiler(provider.readStringFromUri, |
| 40 outputProvider, | 40 outputProvider, |
| 41 diagnosticHandler, | 41 diagnosticHandler, |
| 42 libraryRoot, | 42 libraryRoot, |
| 43 packageRoot, | 43 packageRoot, |
| 44 options); | 44 options); |
| 45 return compiler; | 45 return compiler; |
| 46 } | 46 } |
| 47 | 47 |
| 48 Future<MirrorSystem> mirrorSystemFor(Map<String,String> memorySourceFiles, | 48 Future<MirrorSystem> mirrorSystemFor(Map<String,String> memorySourceFiles, |
| 49 {DiagnosticHandler diagnosticHandler, | 49 {DiagnosticHandler diagnosticHandler, |
| 50 List<String> options: const []}) { | 50 List<String> options: const []}) { |
| 51 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); | 51 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); |
| 52 Uri libraryRoot = script.resolve('../../../sdk/'); | 52 Uri libraryRoot = script.resolve('../../../sdk/'); |
| 53 Uri packageRoot = script.resolve('./packages/'); | 53 Uri packageRoot = script.resolve('./packages/'); |
| 54 | 54 |
| 55 MemorySourceFileProvider.MEMORY_SOURCE_FILES = memorySourceFiles; | 55 MemorySourceFileProvider.MEMORY_SOURCE_FILES = memorySourceFiles; |
| 56 var provider = new MemorySourceFileProvider(); | 56 var provider = new MemorySourceFileProvider(); |
| 57 if (diagnosticHandler == null) { | 57 if (diagnosticHandler == null) { |
| 58 diagnosticHandler = new FormattingDiagnosticHandler(provider); | 58 diagnosticHandler = new FormattingDiagnosticHandler(provider); |
| 59 } | 59 } |
| 60 | 60 |
| 61 List<Uri> libraries = <Uri>[]; | 61 List<Uri> libraries = <Uri>[]; |
| 62 memorySourceFiles.forEach((String path, _) { | 62 memorySourceFiles.forEach((String path, _) { |
| 63 libraries.add(new Uri(scheme: 'memory', path: path)); | 63 libraries.add(new Uri(scheme: 'memory', path: path)); |
| 64 }); | 64 }); |
| 65 | 65 |
| 66 return analyze(libraries, libraryRoot, packageRoot, | 66 return analyze(libraries, libraryRoot, packageRoot, |
| 67 provider, diagnosticHandler, options); | 67 provider, diagnosticHandler, options); |
| 68 } | 68 } |
| OLD | NEW |