Skip to content

Commit f987a3a

Browse files
update library mapping
Review URL: https://chromiumcodereview.appspot.com//10876045 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11339 260f80e4-7a28-3924-810f-c04153c831b5
1 parent 562860c commit f987a3a

File tree

1 file changed

+47
-15
lines changed

1 file changed

+47
-15
lines changed

lib/_internal/libraries.dart

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
#library('libraries');
66

7+
/**
8+
* A bit flag used by [LibraryInfo] indicating that a library is used by dart2js
9+
*/
10+
final int DART2JS_PLATFORM = 1;
11+
12+
/**
13+
* A bit flag used by [LibraryInfo] indicating that a library is used by the VM
14+
*/
15+
final int VM_PLATFORM = 2;
16+
717
/**
818
* Mapping of "dart:" library name (e.g. "core") to information about that library.
919
* This information is structured such that Dart Editor can parse this file
@@ -15,11 +25,14 @@ final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> {
1525
// Used by VM applications
1626
"builtin": const LibraryInfo(
1727
"builtin/builtin_runtime.dart",
18-
category: "Server"),
28+
category: "Server",
29+
platforms: VM_PLATFORM),
1930

31+
// Is moving to pkg directory
2032
"compiler": const LibraryInfo(
2133
"compiler/compiler.dart",
22-
category: "Tools"),
34+
category: "Tools",
35+
platforms: 0),
2336

2437
"core": const LibraryInfo(
2538
"core/core_runtime.dart",
@@ -37,8 +50,9 @@ final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> {
3750
// dom/dom_frog.dart is a placeholder for dartium dom
3851
"dom_deprecated": const LibraryInfo(
3952
"dom/dom_dart2js.dart",
53+
implementation: true,
4054
dart2jsPath: "dom/dart2js/dom_dart2js.dart",
41-
internal: true),
55+
documented: false),
4256

4357
"html": const LibraryInfo(
4458
"html/html_dartium.dart",
@@ -67,11 +81,9 @@ final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> {
6781
"nativewrappers": const LibraryInfo(
6882
"html/nativewrappers.dart",
6983
category: "Client",
70-
implementation: true),
71-
72-
"unittest": const LibraryInfo(
73-
"unittest/unittest.dart",
74-
category: "Tools"),
84+
implementation: true,
85+
documented: false,
86+
platforms: VM_PLATFORM),
7587

7688
"uri": const LibraryInfo(
7789
"uri/uri.dart"),
@@ -86,13 +98,15 @@ final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> {
8698
"_js_helper": const LibraryInfo(
8799
"compiler/implementation/lib/js_helper.dart",
88100
category: "Internal",
89-
internal: true),
101+
documented: false,
102+
platforms: DART2JS_PLATFORM),
90103

91104
// Used by dart2js
92105
"_interceptors": const LibraryInfo(
93106
"compiler/implementation/lib/interceptors.dart",
94107
category: "Internal",
95-
internal: true),
108+
documented: false,
109+
platforms: DART2JS_PLATFORM),
96110
};
97111

98112
/**
@@ -114,19 +128,27 @@ class LibraryInfo {
114128
/**
115129
* Path to the dart2js library's *.dart file relative to this file
116130
* or null if dart2js uses the common library path defined above.
131+
* Access using the [#getDart2JsPath()] method.
117132
*/
118133
final String dart2jsPath;
119134

120135
/**
121136
* Path to the dart2js library's patch file relative to this file
122137
* or null if no dart2js patch file associated with this library.
138+
* Access using the [#getDart2JsPatchPath()] method.
123139
*/
124140
final String dart2jsPatchPath;
125141

126142
/**
127-
* True if this library is internal and should not be shown to the user
143+
* True if this library is documented and should be shown to the user
128144
*/
129-
final bool internal;
145+
final bool documented;
146+
147+
/**
148+
* Bit flags indicating which platforms consume this library
149+
* See [DART2JS_LIBRARY] and [VM_LIBRARY]
150+
*/
151+
final int platforms;
130152

131153
/**
132154
* True if the library contains implementation details for another library.
@@ -137,7 +159,17 @@ class LibraryInfo {
137159
*/
138160
final bool implementation;
139161

140-
const LibraryInfo(this.path, [this.category = "Shared",
141-
this.dart2jsPath, this.dart2jsPatchPath,
142-
this.implementation = false, this.internal = false]);
162+
const LibraryInfo(this.path, [
163+
this.category = "Shared",
164+
this.dart2jsPath,
165+
this.dart2jsPatchPath,
166+
this.implementation = false,
167+
this.documented = true,
168+
this.platforms = DART2JS_PLATFORM | VM_PLATFORM]);
169+
170+
bool isDart2JsLibrary() => (platforms & DART2JS_PLATFORM) != 0;
171+
bool isVmLibrary() => (platforms & VM_PLATFORM) != 0;
172+
173+
String getDart2JsPath() => dart2jsPath != null ? "lib/$dart2jsPath" : "lib/$path";
174+
String getDart2jsPatchPath() => dart2jsPatchPath != null ? "lib/$dart2jsPatchPath" : null;
143175
}

0 commit comments

Comments
 (0)