Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: pkg/analyzer/tool/summary/idl.dart

Issue 1584313005: Downplay the distinction between linked and prelinked summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/tool/summary/build_sdk_summary.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /** 5 /**
6 * This file is an "idl" style description of the summary format. It is not 6 * This file is an "idl" style description of the summary format. It is not
7 * executed directly; instead it is parsed and transformed into code that 7 * executed directly; instead it is parsed and transformed into code that
8 * implements the summary format. 8 * implements the summary format.
9 * 9 *
10 * The code generation process introduces the following non-typical semantics: 10 * The code generation process introduces the following non-typical semantics:
11 * - Fields of type List are never null, and have a default value of the empty 11 * - Fields of type List are never null, and have a default value of the empty
12 * list. 12 * list.
13 * - Fields of type int are never null, and have a default value of zero. 13 * - Fields of type int are never null, and have a default value of zero.
14 * - Fields of type String are never null, and have a default value of ''. 14 * - Fields of type String are never null, and have a default value of ''.
15 * - Fields of type bool are never null, and have a default value of false. 15 * - Fields of type bool are never null, and have a default value of false.
16 * - Fields whose type is an enum are never null, and have a default value of 16 * - Fields whose type is an enum are never null, and have a default value of
17 * the first value declared in the enum. 17 * the first value declared in the enum.
18 * 18 *
19 * Terminology used in this document: 19 * Terminology used in this document:
20 * - "Unlinked" refers to information that can be determined from reading the 20 * - "Unlinked" refers to information that can be determined from reading a
21 * .dart file for the library itself (including all parts) and no other 21 * single .dart file in isolation.
22 * files. 22 * - "Prelinked" refers to information that can be determined from the defining
23 * - "Prelinked" refers to information that can be determined from reading the 23 * compilation unit of a library, plus direct imports, plus the transitive
24 * unlinked information for the library itself and the unlinked information 24 * closure of exports reachable from those libraries, plus all part files
25 * for all direct imports (plus the transitive closure of exports reachable 25 * constituting those libraries.
26 * from those direct imports). 26 * - "Linked" refers to all other information; in theory, this information may
27 * - "Linked" refers to information that can be determined only from reading 27 * depend on all files in the transitive import/export closure. However, in
28 * the unlinked and prelinked information for the library itself and the 28 * practice we expect that the number of additional dependencies will usually
29 * transitive closure of its imports. 29 * be small, since the additional dependencies only need to be consulted for
30 * type propagation, type inference, and constant evaluation, which typically
31 * have short dependency chains.
30 * 32 *
31 * TODO(paulberry): currently the summary format only contains unlinked and 33 * Since we expect "linked" and "prelinked" dependencies to be similar, we only
32 * prelinked information. 34 * rarely distinguish between them; most information is that is not "unlinked"
35 * is typically considered "linked" for simplicity.
33 * 36 *
34 * Except as otherwise noted, synthetic elements are not stored in the summary; 37 * Except as otherwise noted, synthetic elements are not stored in the summary;
35 * they are re-synthesized at the time the summary is read. 38 * they are re-synthesized at the time the summary is read.
36 */ 39 */
37 library analyzer.tool.summary.idl; 40 library analyzer.tool.summary.idl;
38 41
39 /** 42 /**
40 * Annotation describing information which is not part of Dart semantics; in 43 * Annotation describing information which is not part of Dart semantics; in
41 * other words, if this information (or any information it refers to) changes, 44 * other words, if this information (or any information it refers to) changes,
42 * static analysis and runtime behavior of the library are unaffected. 45 * static analysis and runtime behavior of the library are unaffected.
(...skipping 16 matching lines...) Expand all
59 /** 62 /**
60 * Annotation describing a class which can be the top level object in an 63 * Annotation describing a class which can be the top level object in an
61 * encoded summary. 64 * encoded summary.
62 */ 65 */
63 const topLevel = null; 66 const topLevel = null;
64 67
65 /** 68 /**
66 * Information about a dependency that exists between one library and another 69 * Information about a dependency that exists between one library and another
67 * due to an "import" declaration. 70 * due to an "import" declaration.
68 */ 71 */
69 class PrelinkedDependency { 72 class LinkedDependency {
70 /** 73 /**
71 * The relative URI of the dependent library. This URI is relative to the 74 * The relative URI of the dependent library. This URI is relative to the
72 * importing library, even if there are intervening `export` declarations. 75 * importing library, even if there are intervening `export` declarations.
73 * So, for example, if `a.dart` imports `b/c.dart` and `b/c.dart` exports 76 * So, for example, if `a.dart` imports `b/c.dart` and `b/c.dart` exports
74 * `d/e.dart`, the URI listed for `a.dart`'s dependency on `e.dart` will be 77 * `d/e.dart`, the URI listed for `a.dart`'s dependency on `e.dart` will be
75 * `b/d/e.dart`. 78 * `b/d/e.dart`.
76 */ 79 */
77 String uri; 80 String uri;
78 81
79 /** 82 /**
80 * URI for the compilation units listed in the library's `part` declarations. 83 * URI for the compilation units listed in the library's `part` declarations.
81 * These URIs are relative to the importing library. 84 * These URIs are relative to the importing library.
82 */ 85 */
83 List<String> parts; 86 List<String> parts;
84 } 87 }
85 88
86 /** 89 /**
87 * Information about a single name in the export namespace of the library that 90 * Information about a single name in the export namespace of the library that
88 * is not in the public namespace. 91 * is not in the public namespace.
89 */ 92 */
90 class PrelinkedExportName { 93 class LinkedExportName {
91 /** 94 /**
92 * Name of the exported entity. TODO(paulberry): do we include the trailing 95 * Name of the exported entity. TODO(paulberry): do we include the trailing
93 * '=' for a setter? 96 * '=' for a setter?
94 */ 97 */
95 String name; 98 String name;
96 99
97 /** 100 /**
98 * Index into [PrelinkedLibrary.dependencies] for the library in which the 101 * Index into [LinkedLibrary.dependencies] for the library in which the
99 * entity is defined. 102 * entity is defined.
100 */ 103 */
101 int dependency; 104 int dependency;
102 105
103 /** 106 /**
104 * Integer index indicating which unit in the exported library contains the 107 * Integer index indicating which unit in the exported library contains the
105 * definition of the entity. As with indices into [PrelinkedLibrary.units], 108 * definition of the entity. As with indices into [LinkedLibrary.units],
106 * zero represents the defining compilation unit, and nonzero values 109 * zero represents the defining compilation unit, and nonzero values
107 * represent parts in the order of the corresponding `part` declarations. 110 * represent parts in the order of the corresponding `part` declarations.
108 */ 111 */
109 int unit; 112 int unit;
110 113
111 /** 114 /**
112 * The kind of the entity being referred to. 115 * The kind of the entity being referred to.
113 */ 116 */
114 PrelinkedReferenceKind kind; 117 ReferenceKind kind;
115 } 118 }
116 119
117 /** 120 /**
118 * Pre-linked summary of a library. 121 * Linked summary of a library.
119 */ 122 */
120 @topLevel 123 @topLevel
121 class PrelinkedLibrary { 124 class LinkedLibrary {
122 /** 125 /**
123 * The pre-linked summary of all the compilation units constituting the 126 * The linked summary of all the compilation units constituting the
124 * library. The summary of the defining compilation unit is listed first, 127 * library. The summary of the defining compilation unit is listed first,
125 * followed by the summary of each part, in the order of the `part` 128 * followed by the summary of each part, in the order of the `part`
126 * declarations in the defining compilation unit. 129 * declarations in the defining compilation unit.
127 */ 130 */
128 List<PrelinkedUnit> units; 131 List<LinkedUnit> units;
129 132
130 /** 133 /**
131 * The libraries that this library depends on (either via an explicit import 134 * The libraries that this library depends on (either via an explicit import
132 * statement or via the implicit dependencies on `dart:core` and 135 * statement or via the implicit dependencies on `dart:core` and
133 * `dart:async`). The first element of this array is a pseudo-dependency 136 * `dart:async`). The first element of this array is a pseudo-dependency
134 * representing the library itself (it is also used for "dynamic"). 137 * representing the library itself (it is also used for "dynamic").
135 * 138 *
136 * TODO(paulberry): consider removing this entirely and just using 139 * TODO(paulberry): consider removing this entirely and just using
137 * [UnlinkedLibrary.imports]. 140 * [UnlinkedLibrary.imports].
138 */ 141 */
139 List<PrelinkedDependency> dependencies; 142 List<LinkedDependency> dependencies;
140 143
141 /** 144 /**
142 * For each import in [UnlinkedUnit.imports], an index into [dependencies] 145 * For each import in [UnlinkedUnit.imports], an index into [dependencies]
143 * of the library being imported. 146 * of the library being imported.
144 * 147 *
145 * TODO(paulberry): if [dependencies] is removed, this can be removed as 148 * TODO(paulberry): if [dependencies] is removed, this can be removed as
146 * well, since there will effectively be a one-to-one mapping. 149 * well, since there will effectively be a one-to-one mapping.
147 */ 150 */
148 List<int> importDependencies; 151 List<int> importDependencies;
149 152
150 /** 153 /**
151 * Information about entities in the export namespace of the library that are 154 * Information about entities in the export namespace of the library that are
152 * not in the public namespace of the library (that is, entities that are 155 * not in the public namespace of the library (that is, entities that are
153 * brought into the namespace via `export` directives). 156 * brought into the namespace via `export` directives).
154 * 157 *
155 * Sorted by name. 158 * Sorted by name.
156 */ 159 */
157 List<PrelinkedExportName> exportNames; 160 List<LinkedExportName> exportNames;
158 } 161 }
159 162
160 /** 163 /**
161 * Information about the resolution of an [UnlinkedReference]. 164 * Information about the resolution of an [UnlinkedReference].
162 */ 165 */
163 class PrelinkedReference { 166 class LinkedReference {
164 /** 167 /**
165 * Index into [PrelinkedLibrary.dependencies] indicating which imported librar y 168 * Index into [LinkedLibrary.dependencies] indicating which imported library
166 * declares the entity being referred to. 169 * declares the entity being referred to.
167 */ 170 */
168 int dependency; 171 int dependency;
169 172
170 /** 173 /**
171 * The kind of the entity being referred to. For the pseudo-type `dynamic`, 174 * The kind of the entity being referred to. For the pseudo-type `dynamic`,
172 * the kind is [PrelinkedReferenceKind.classOrEnum]. 175 * the kind is [ReferenceKind.classOrEnum].
173 */ 176 */
174 PrelinkedReferenceKind kind; 177 ReferenceKind kind;
175 178
176 /** 179 /**
177 * Integer index indicating which unit in the imported library contains the 180 * Integer index indicating which unit in the imported library contains the
178 * definition of the entity. As with indices into [PrelinkedLibrary.units], 181 * definition of the entity. As with indices into [LinkedLibrary.units],
179 * zero represents the defining compilation unit, and nonzero values 182 * zero represents the defining compilation unit, and nonzero values
180 * represent parts in the order of the corresponding `part` declarations. 183 * represent parts in the order of the corresponding `part` declarations.
181 */ 184 */
182 int unit; 185 int unit;
183 186
184 /** 187 /**
185 * If the entity being referred to is generic, the number of type parameters 188 * If the entity being referred to is generic, the number of type parameters
186 * it accepts. Otherwise zero. 189 * it accepts. Otherwise zero.
187 */ 190 */
188 int numTypeParameters; 191 int numTypeParameters;
189 } 192 }
190 193
191 /** 194 /**
195 * Linked summary of a compilation unit.
196 */
197 class LinkedUnit {
198 /**
199 * For each reference in [UnlinkedUnit.references], information about how
200 * that reference is resolved.
201 */
202 List<LinkedReference> references;
203 }
204
205 /**
192 * Enum used to indicate the kind of entity referred to by a 206 * Enum used to indicate the kind of entity referred to by a
193 * [PrelinkedReference]. 207 * [LinkedReference].
194 */ 208 */
195 enum PrelinkedReferenceKind { 209 enum ReferenceKind {
196 /** 210 /**
197 * The entity is a class or enum. 211 * The entity is a class or enum.
198 */ 212 */
199 classOrEnum, 213 classOrEnum,
200 214
201 /** 215 /**
202 * The entity is a typedef. 216 * The entity is a typedef.
203 */ 217 */
204 typedef, 218 typedef,
205 219
(...skipping 12 matching lines...) Expand all
218 */ 232 */
219 prefix, 233 prefix,
220 234
221 /** 235 /**
222 * The entity being referred to does not exist. 236 * The entity being referred to does not exist.
223 */ 237 */
224 unresolved 238 unresolved
225 } 239 }
226 240
227 /** 241 /**
228 * Pre-linked summary of a compilation unit.
229 */
230 class PrelinkedUnit {
231 /**
232 * For each reference in [UnlinkedUnit.references], information about how
233 * that reference is resolved.
234 */
235 List<PrelinkedReference> references;
236 }
237
238 /**
239 * Information about SDK. 242 * Information about SDK.
240 */ 243 */
241 @topLevel 244 @topLevel
242 class SdkBundle { 245 class SdkBundle {
243 /** 246 /**
244 * The list of URIs of items in [prelinkedLibraries], e.g. `dart:core`. 247 * The list of URIs of items in [linkedLibraries], e.g. `dart:core`.
245 */ 248 */
246 List<String> prelinkedLibraryUris; 249 List<String> linkedLibraryUris;
247 250
248 /** 251 /**
249 * Pre-linked libraries. 252 * Linked libraries.
250 */ 253 */
251 List<PrelinkedLibrary> prelinkedLibraries; 254 List<LinkedLibrary> linkedLibraries;
252 255
253 /** 256 /**
254 * The list of URIs of items in [unlinkedUnits], e.g. `dart:core/bool.dart`. 257 * The list of URIs of items in [unlinkedUnits], e.g. `dart:core/bool.dart`.
255 */ 258 */
256 List<String> unlinkedUnitUris; 259 List<String> unlinkedUnitUris;
257 260
258 /** 261 /**
259 * Unlinked information for the compilation units constituting the SDK. 262 * Unlinked information for the compilation units constituting the SDK.
260 */ 263 */
261 List<UnlinkedUnit> unlinkedUnits; 264 List<UnlinkedUnit> unlinkedUnits;
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 */ 752 */
750 class UnlinkedPublicName { 753 class UnlinkedPublicName {
751 /** 754 /**
752 * The name itself. 755 * The name itself.
753 */ 756 */
754 String name; 757 String name;
755 758
756 /** 759 /**
757 * The kind of object referred to by the name. 760 * The kind of object referred to by the name.
758 */ 761 */
759 PrelinkedReferenceKind kind; 762 ReferenceKind kind;
760 763
761 /** 764 /**
762 * If the entity being referred to is generic, the number of type parameters 765 * If the entity being referred to is generic, the number of type parameters
763 * it accepts. Otherwise zero. 766 * it accepts. Otherwise zero.
764 */ 767 */
765 int numTypeParameters; 768 int numTypeParameters;
766 } 769 }
767 770
768 /** 771 /**
769 * Unlinked summary information about what a compilation unit contributes to a 772 * Unlinked summary information about what a compilation unit contributes to a
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 /** 1051 /**
1049 * Indicates whether the variable is declared using the `const` keyword. 1052 * Indicates whether the variable is declared using the `const` keyword.
1050 */ 1053 */
1051 bool isConst; 1054 bool isConst;
1052 1055
1053 /** 1056 /**
1054 * Indicates whether this variable lacks an explicit type declaration. 1057 * Indicates whether this variable lacks an explicit type declaration.
1055 */ 1058 */
1056 bool hasImplicitType; 1059 bool hasImplicitType;
1057 } 1060 }
OLDNEW
« no previous file with comments | « pkg/analyzer/tool/summary/build_sdk_summary.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698