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('libraries'); | 5 #library('libraries'); |
6 | 6 |
7 /** | 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 | |
17 /** | |
8 * Mapping of "dart:" library name (e.g. "core") to information about that libra ry. | 18 * Mapping of "dart:" library name (e.g. "core") to information about that libra ry. |
9 * This information is structured such that Dart Editor can parse this file | 19 * This information is structured such that Dart Editor can parse this file |
10 * and extract the necessary information without executing it | 20 * and extract the necessary information without executing it |
11 * while other tools can access via execution. | 21 * while other tools can access via execution. |
12 */ | 22 */ |
13 final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> { | 23 final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> { |
14 | 24 |
15 // Used by VM applications | 25 // Used by VM applications |
16 "builtin": const LibraryInfo( | 26 "builtin": const LibraryInfo( |
17 "builtin/builtin_runtime.dart", | 27 "builtin/builtin_runtime.dart", |
18 category: "Server"), | 28 category: "Server", |
29 platforms: VM_PLATFORM), | |
19 | 30 |
31 // Is moving to pkg directory | |
20 "compiler": const LibraryInfo( | 32 "compiler": const LibraryInfo( |
21 "compiler/compiler.dart", | 33 "compiler/compiler.dart", |
22 category: "Tools"), | 34 category: "Tools", |
35 platforms: 0), | |
Lasse Reichstein Nielsen
2012/09/12 10:19:54
drive-by-after-the-fact-comment: Consider making N
| |
23 | 36 |
24 "core": const LibraryInfo( | 37 "core": const LibraryInfo( |
25 "core/core_runtime.dart", | 38 "core/core_runtime.dart", |
26 dart2jsPath: "compiler/implementation/lib/core.dart"), | 39 dart2jsPath: "compiler/implementation/lib/core.dart"), |
27 | 40 |
28 "coreimpl": const LibraryInfo( | 41 "coreimpl": const LibraryInfo( |
29 "coreimpl/coreimpl_runtime.dart", | 42 "coreimpl/coreimpl_runtime.dart", |
30 implementation: true, | 43 implementation: true, |
31 dart2jsPath: "compiler/implementation/lib/coreimpl.dart", | 44 dart2jsPath: "compiler/implementation/lib/coreimpl.dart", |
32 dart2jsPatchPath: "compiler/implementation/lib/coreimpl.dartp"), | 45 dart2jsPatchPath: "compiler/implementation/lib/coreimpl.dartp"), |
33 | 46 |
34 "crypto": const LibraryInfo( | 47 "crypto": const LibraryInfo( |
35 "crypto/crypto.dart"), | 48 "crypto/crypto.dart"), |
36 | 49 |
37 // dom/dom_frog.dart is a placeholder for dartium dom | 50 // dom/dom_frog.dart is a placeholder for dartium dom |
38 "dom_deprecated": const LibraryInfo( | 51 "dom_deprecated": const LibraryInfo( |
39 "dom/dom_dart2js.dart", | 52 "dom/dom_dart2js.dart", |
53 implementation: true, | |
40 dart2jsPath: "dom/dart2js/dom_dart2js.dart", | 54 dart2jsPath: "dom/dart2js/dom_dart2js.dart", |
41 internal: true), | 55 documented: false), |
42 | 56 |
43 "html": const LibraryInfo( | 57 "html": const LibraryInfo( |
44 "html/html_dartium.dart", | 58 "html/html_dartium.dart", |
45 category: "Client", | 59 category: "Client", |
46 dart2jsPath: "html/dart2js/html_dart2js.dart"), | 60 dart2jsPath: "html/dart2js/html_dart2js.dart"), |
47 | 61 |
48 "io": const LibraryInfo( | 62 "io": const LibraryInfo( |
49 "io/io_runtime.dart", | 63 "io/io_runtime.dart", |
50 category: "Server", | 64 category: "Server", |
51 dart2jsPath: "compiler/implementation/lib/io.dart"), | 65 dart2jsPath: "compiler/implementation/lib/io.dart"), |
52 | 66 |
53 "isolate": const LibraryInfo( | 67 "isolate": const LibraryInfo( |
54 "isolate/isolate.dart"), | 68 "isolate/isolate.dart"), |
55 | 69 |
56 "json": const LibraryInfo( | 70 "json": const LibraryInfo( |
57 "json/json.dart"), | 71 "json/json.dart"), |
58 | 72 |
59 "math": const LibraryInfo( | 73 "math": const LibraryInfo( |
60 "math/math.dart", | 74 "math/math.dart", |
61 dart2jsPatchPath: "compiler/implementation/lib/math.dartp"), | 75 dart2jsPatchPath: "compiler/implementation/lib/math.dartp"), |
62 | 76 |
63 "mirrors": const LibraryInfo( | 77 "mirrors": const LibraryInfo( |
64 "mirrors/mirrors.dart"), | 78 "mirrors/mirrors.dart"), |
65 | 79 |
66 // Used by Dartium applications | 80 // Used by Dartium applications |
67 "nativewrappers": const LibraryInfo( | 81 "nativewrappers": const LibraryInfo( |
68 "html/nativewrappers.dart", | 82 "html/nativewrappers.dart", |
69 category: "Client", | 83 category: "Client", |
70 implementation: true), | 84 implementation: true, |
71 | 85 documented: false, |
72 "unittest": const LibraryInfo( | 86 platforms: VM_PLATFORM), |
73 "unittest/unittest.dart", | |
74 category: "Tools"), | |
75 | 87 |
76 "uri": const LibraryInfo( | 88 "uri": const LibraryInfo( |
77 "uri/uri.dart"), | 89 "uri/uri.dart"), |
78 | 90 |
79 "utf": const LibraryInfo( | 91 "utf": const LibraryInfo( |
80 "utf/utf.dart"), | 92 "utf/utf.dart"), |
81 | 93 |
82 "web": const LibraryInfo( | 94 "web": const LibraryInfo( |
83 "web/web.dart"), | 95 "web/web.dart"), |
84 | 96 |
85 // Used by dart2js | 97 // Used by dart2js |
86 "_js_helper": const LibraryInfo( | 98 "_js_helper": const LibraryInfo( |
87 "compiler/implementation/lib/js_helper.dart", | 99 "compiler/implementation/lib/js_helper.dart", |
88 category: "Internal", | 100 category: "Internal", |
89 internal: true), | 101 documented: false, |
102 platforms: DART2JS_PLATFORM), | |
90 | 103 |
91 // Used by dart2js | 104 // Used by dart2js |
92 "_interceptors": const LibraryInfo( | 105 "_interceptors": const LibraryInfo( |
93 "compiler/implementation/lib/interceptors.dart", | 106 "compiler/implementation/lib/interceptors.dart", |
94 category: "Internal", | 107 category: "Internal", |
95 internal: true), | 108 documented: false, |
109 platforms: DART2JS_PLATFORM), | |
96 }; | 110 }; |
97 | 111 |
98 /** | 112 /** |
99 * Information about a "dart:" library. | 113 * Information about a "dart:" library. |
100 */ | 114 */ |
101 class LibraryInfo { | 115 class LibraryInfo { |
102 | 116 |
103 /** | 117 /** |
104 * Path to the library's *.dart file relative to this file. | 118 * Path to the library's *.dart file relative to this file. |
105 */ | 119 */ |
106 final String path; | 120 final String path; |
107 | 121 |
108 /** | 122 /** |
109 * The category in which the library should appear in the editor | 123 * The category in which the library should appear in the editor |
110 * (e.g. "Common", "Client", "Server", ...). | 124 * (e.g. "Common", "Client", "Server", ...). |
111 */ | 125 */ |
112 final String category; | 126 final String category; |
113 | 127 |
114 /** | 128 /** |
115 * Path to the dart2js library's *.dart file relative to this file | 129 * Path to the dart2js library's *.dart file relative to this file |
116 * or null if dart2js uses the common library path defined above. | 130 * or null if dart2js uses the common library path defined above. |
131 * Access using the [#getDart2JsPath()] method. | |
117 */ | 132 */ |
118 final String dart2jsPath; | 133 final String dart2jsPath; |
119 | 134 |
120 /** | 135 /** |
121 * Path to the dart2js library's patch file relative to this file | 136 * Path to the dart2js library's patch file relative to this file |
122 * or null if no dart2js patch file associated with this library. | 137 * or null if no dart2js patch file associated with this library. |
138 * Access using the [#getDart2JsPatchPath()] method. | |
123 */ | 139 */ |
124 final String dart2jsPatchPath; | 140 final String dart2jsPatchPath; |
125 | 141 |
126 /** | 142 /** |
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 |
128 */ | 144 */ |
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; | |
130 | 152 |
131 /** | 153 /** |
132 * True if the library contains implementation details for another library. | 154 * True if the library contains implementation details for another library. |
133 * The implication is that these libraries are less commonly used | 155 * The implication is that these libraries are less commonly used |
134 * and that tools like Dart Editor should not show these libraries | 156 * and that tools like Dart Editor should not show these libraries |
135 * in a list of all libraries unless the user specifically asks the tool to do so. | 157 * in a list of all libraries unless the user specifically asks the tool to do so. |
136 * (e.g. "coreimpl" contains implementation for the "core" library). | 158 * (e.g. "coreimpl" contains implementation for the "core" library). |
137 */ | 159 */ |
138 final bool implementation; | 160 final bool implementation; |
139 | 161 |
140 const LibraryInfo(this.path, [this.category = "Shared", | 162 const LibraryInfo(this.path, [ |
141 this.dart2jsPath, this.dart2jsPatchPath, | 163 this.category = "Shared", |
142 this.implementation = false, this.internal = false]); | 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; | |
Lasse Reichstein Nielsen
2012/09/12 10:19:54
You could even use the NO_PLATFORM for the zeros h
| |
171 bool isVmLibrary() => (platforms & VM_PLATFORM) != 0; | |
172 | |
173 String getDart2JsPath() => dart2jsPath != null ? "lib/$dart2jsPath" : "lib/$pa th"; | |
174 String getDart2jsPatchPath() => dart2jsPatchPath != null ? "lib/$dart2jsPatchP ath" : null; | |
143 } | 175 } |
OLD | NEW |