| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 leg_apiimpl; | 5 library leg_apiimpl; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:package_config/packages.dart'; | 10 import 'package:package_config/packages.dart'; |
| 11 import 'package:package_config/packages_file.dart' as pkgs; | 11 import 'package:package_config/packages_file.dart' as pkgs; |
| 12 import 'package:package_config/src/packages_impl.dart' show | 12 import 'package:package_config/src/packages_impl.dart' show |
| 13 MapPackages, | 13 MapPackages, |
| 14 NonFilePackagesDirectoryPackages; | 14 NonFilePackagesDirectoryPackages; |
| 15 import 'package:package_config/src/util.dart' show | 15 import 'package:package_config/src/util.dart' show |
| 16 checkValidPackageUri; | 16 checkValidPackageUri; |
| 17 import 'package:sdk_library_metadata/libraries.dart' as library_info; | 17 import 'package:sdk_library_metadata/libraries.dart' as library_info; |
| 18 | 18 |
| 19 import '../compiler_new.dart' as api; | 19 import '../compiler_new.dart' as api; |
| 20 import 'commandline_options.dart'; | 20 import 'commandline_options.dart'; |
| 21 import 'common.dart'; | 21 import 'common.dart'; |
| 22 import 'common/tasks.dart' show | 22 import 'common/tasks.dart' show |
| 23 GenericTask; | 23 GenericTask; |
| 24 import 'compiler.dart' as leg; | 24 import 'compiler.dart'; |
| 25 import 'diagnostics/diagnostic_listener.dart' show | 25 import 'diagnostics/diagnostic_listener.dart' show |
| 26 DiagnosticOptions; | 26 DiagnosticOptions; |
| 27 import 'diagnostics/messages.dart' show | 27 import 'diagnostics/messages.dart' show |
| 28 Message; | 28 Message; |
| 29 import 'elements/elements.dart' as elements; | 29 import 'elements/elements.dart' as elements; |
| 30 import 'io/source_file.dart'; | 30 import 'io/source_file.dart'; |
| 31 import 'script.dart'; | 31 import 'script.dart'; |
| 32 | 32 |
| 33 const bool forceIncrementalSupport = | 33 const bool forceIncrementalSupport = |
| 34 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); | 34 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); |
| 35 | 35 |
| 36 class Compiler extends leg.Compiler { | 36 /// Implements the [Compiler] using a [api.CompilerInput] for supplying the |
| 37 /// sources. |
| 38 class CompilerImpl extends Compiler { |
| 37 api.CompilerInput provider; | 39 api.CompilerInput provider; |
| 38 api.CompilerDiagnostics handler; | 40 api.CompilerDiagnostics handler; |
| 39 final Uri libraryRoot; | 41 final Uri libraryRoot; |
| 40 final Uri packageConfig; | 42 final Uri packageConfig; |
| 41 final Uri packageRoot; | 43 final Uri packageRoot; |
| 42 final api.PackagesDiscoveryProvider packagesDiscoveryProvider; | 44 final api.PackagesDiscoveryProvider packagesDiscoveryProvider; |
| 43 Packages packages; | 45 Packages packages; |
| 44 List<String> options; | 46 List<String> options; |
| 45 Map<String, dynamic> environment; | 47 Map<String, dynamic> environment; |
| 46 bool mockableLibraryUsed = false; | 48 bool mockableLibraryUsed = false; |
| 47 final Set<library_info.Category> allowedLibraryCategories; | 49 final Set<library_info.Category> allowedLibraryCategories; |
| 48 | 50 |
| 49 GenericTask userHandlerTask; | 51 GenericTask userHandlerTask; |
| 50 GenericTask userProviderTask; | 52 GenericTask userProviderTask; |
| 51 GenericTask userPackagesDiscoveryTask; | 53 GenericTask userPackagesDiscoveryTask; |
| 52 | 54 |
| 53 Compiler(this.provider, | 55 CompilerImpl(this.provider, |
| 54 api.CompilerOutput outputProvider, | 56 api.CompilerOutput outputProvider, |
| 55 this.handler, | 57 this.handler, |
| 56 this.libraryRoot, | 58 this.libraryRoot, |
| 57 this.packageRoot, | 59 this.packageRoot, |
| 58 List<String> options, | 60 List<String> options, |
| 59 this.environment, | 61 this.environment, |
| 60 [this.packageConfig, | 62 [this.packageConfig, |
| 61 this.packagesDiscoveryProvider]) | 63 this.packagesDiscoveryProvider]) |
| 62 : this.options = options, | 64 : this.options = options, |
| 63 this.allowedLibraryCategories = getAllowedLibraryCategories(options), | 65 this.allowedLibraryCategories = getAllowedLibraryCategories(options), |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 String path = info.dart2jsPatchPath; | 198 String path = info.dart2jsPatchPath; |
| 197 if (path == null) return null; | 199 if (path == null) return null; |
| 198 return "lib/$path"; | 200 return "lib/$path"; |
| 199 } | 201 } |
| 200 | 202 |
| 201 void log(message) { | 203 void log(message) { |
| 202 callUserHandler( | 204 callUserHandler( |
| 203 null, null, null, null, message, api.Diagnostic.VERBOSE_INFO); | 205 null, null, null, null, message, api.Diagnostic.VERBOSE_INFO); |
| 204 } | 206 } |
| 205 | 207 |
| 206 /// See [leg.Compiler.translateResolvedUri]. | 208 /// See [Compiler.translateResolvedUri]. |
| 207 Uri translateResolvedUri(elements.LibraryElement importingLibrary, | 209 Uri translateResolvedUri(elements.LibraryElement importingLibrary, |
| 208 Uri resolvedUri, Spannable spannable) { | 210 Uri resolvedUri, Spannable spannable) { |
| 209 if (resolvedUri.scheme == 'dart') { | 211 if (resolvedUri.scheme == 'dart') { |
| 210 return translateDartUri(importingLibrary, resolvedUri, spannable); | 212 return translateDartUri(importingLibrary, resolvedUri, spannable); |
| 211 } | 213 } |
| 212 return resolvedUri; | 214 return resolvedUri; |
| 213 } | 215 } |
| 214 | 216 |
| 215 /** | 217 /** |
| 216 * Reads the script designated by [readableUri]. | 218 * Reads the script designated by [readableUri]. |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 } | 559 } |
| 558 } | 560 } |
| 559 | 561 |
| 560 | 562 |
| 561 fromEnvironment(String name) => environment[name]; | 563 fromEnvironment(String name) => environment[name]; |
| 562 | 564 |
| 563 library_info.LibraryInfo lookupLibraryInfo(String libraryName) { | 565 library_info.LibraryInfo lookupLibraryInfo(String libraryName) { |
| 564 return library_info.libraries[libraryName]; | 566 return library_info.libraries[libraryName]; |
| 565 } | 567 } |
| 566 } | 568 } |
| OLD | NEW |