| 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 // TODO(ahe): Long term, it would probably be better if we do not use | 5 // TODO(ahe): Long term, it would probably be better if we do not use |
| 6 // executable code to define the locations of libraries. | 6 // executable code to define the locations of libraries. |
| 7 | 7 |
| 8 #library('library_map'); | 8 #library('library_map'); |
| 9 #import('../../../lib/_internal/libraries.dart', prefix: "libs"); |
| 10 |
| 9 /** | 11 /** |
| 10 * Simple struct holding the path to a library and an optional path | 12 * Simple structure providing the path to a library and an optional path |
| 11 * to a patch file for the library. | 13 * to a patch file for the library. |
| 12 */ | 14 */ |
| 13 class LibraryInfo { | 15 class LibraryInfo { |
| 14 final String libraryPath; | 16 final libs.LibraryInfo info; |
| 15 final String patchPath; | 17 const LibraryInfo(this.info); |
| 16 | 18 |
| 17 /** If [:true:], the library is not part of the public API. */ | 19 String get libraryPath() { |
| 18 final bool isInternal; | 20 String libPath = info.dart2jsPath; |
| 21 if (libPath === null) libPath = info.path; |
| 22 return "lib/$libPath"; |
| 23 } |
| 19 | 24 |
| 20 const LibraryInfo(this.libraryPath, | 25 String get patchPath() { |
| 21 [this.patchPath = null, this.isInternal = false]); | 26 if (info.dart2jsPatchPath === null) return null; |
| 27 return "lib/${info.dart2jsPatchPath}"; |
| 28 } |
| 29 |
| 30 bool get isInternal => info.category === "Internal"; |
| 22 } | 31 } |
| 23 | 32 |
| 24 /** | 33 class Dart2JSLibraryMap { |
| 25 * Specifies the location of Dart platform libraries. | 34 const Dart2JSLibraryMap(); |
| 26 */ | 35 |
| 27 final Map<String, LibraryInfo> DART2JS_LIBRARY_MAP | 36 LibraryInfo operator[](String dartName) { |
| 28 = const <String, LibraryInfo> { | 37 libs.LibraryInfo info = libs.LIBRARIES[dartName]; |
| 29 "core": const LibraryInfo( | 38 if (info === null) return null; |
| 30 "lib/compiler/implementation/lib/core.dart"), | 39 if (info.internalFor !== null && info.internalFor !== "dart2js") { |
| 31 "coreimpl": const LibraryInfo( | 40 // Dart2js can't handle internal libraries for other backends. |
| 32 "lib/compiler/implementation/lib/coreimpl.dart", | 41 return null; |
| 33 "lib/compiler/implementation/lib/coreimpl_patch.dart"), | 42 } |
| 34 "_js_helper": const LibraryInfo( | 43 return new LibraryInfo(info); |
| 35 "lib/compiler/implementation/lib/js_helper.dart", isInternal: true), | 44 } |
| 36 "_interceptors": const LibraryInfo( | 45 } |
| 37 "lib/compiler/implementation/lib/interceptors.dart", isInternal: true), | 46 |
| 38 "crypto": const LibraryInfo( | 47 final Dart2JSLibraryMap DART2JS_LIBRARY_MAP = const Dart2JSLibraryMap(); |
| 39 "lib/crypto/crypto.dart"), | |
| 40 "dom_deprecated": const LibraryInfo( | |
| 41 "lib/dom/dart2js/dom_dart2js.dart", isInternal: true), | |
| 42 "html": const LibraryInfo( | |
| 43 "lib/html/dart2js/html_dart2js.dart"), | |
| 44 "io": const LibraryInfo( | |
| 45 "lib/compiler/implementation/lib/io.dart"), | |
| 46 "isolate": const LibraryInfo( | |
| 47 "lib/isolate/isolate.dart", | |
| 48 "lib/compiler/implementation/lib/isolate_patch.dart"), | |
| 49 "json": const LibraryInfo("lib/json/json.dart"), | |
| 50 "math": const LibraryInfo( | |
| 51 "lib/math/math.dart", | |
| 52 "lib/compiler/implementation/lib/math_patch.dart", isInternal: true), | |
| 53 "uri": const LibraryInfo("lib/uri/uri.dart"), | |
| 54 "utf": const LibraryInfo("lib/utf/utf.dart"), | |
| 55 "web": const LibraryInfo("lib/web/web.dart"), | |
| 56 }; | |
| OLD | NEW |