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

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

Issue 1610043002: Add propagated types to summary files. (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/test/src/summary/summary_test.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:
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 * library. The summary of the defining compilation unit is listed first, 127 * library. The summary of the defining compilation unit is listed first,
128 * 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`
129 * declarations in the defining compilation unit. 129 * declarations in the defining compilation unit.
130 */ 130 */
131 List<LinkedUnit> units; 131 List<LinkedUnit> units;
132 132
133 /** 133 /**
134 * 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
135 * statement or via the implicit dependencies on `dart:core` and 135 * statement or via the implicit dependencies on `dart:core` and
136 * `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
137 * representing the library itself (it is also used for "dynamic"). 137 * representing the library itself (it is also used for "dynamic"). This is
138 * followed by elements representing "prelinked" dependencies (direct imports
139 * and the transitive closure of exports). After the prelinked dependencies
140 * are elements represent "linked" dependencies.
138 * 141 *
139 * TODO(paulberry): consider removing this entirely and just using 142 * A library is only included as a "linked" dependency if it is a true
140 * [UnlinkedLibrary.imports]. 143 * dependency (e.g. a propagated or inferred type or constant value
144 * implicitly refers to an element declared in the library) or
145 * anti-dependency (e.g. the result of type propagation or type inference
146 * depends on the lack of a certain declaration in the library).
141 */ 147 */
142 List<LinkedDependency> dependencies; 148 List<LinkedDependency> dependencies;
143 149
144 /** 150 /**
145 * For each import in [UnlinkedUnit.imports], an index into [dependencies] 151 * For each import in [UnlinkedUnit.imports], an index into [dependencies]
146 * of the library being imported. 152 * of the library being imported.
147 *
148 * TODO(paulberry): if [dependencies] is removed, this can be removed as
149 * well, since there will effectively be a one-to-one mapping.
150 */ 153 */
151 List<int> importDependencies; 154 List<int> importDependencies;
152 155
153 /** 156 /**
154 * Information about entities in the export namespace of the library that are 157 * Information about entities in the export namespace of the library that are
155 * not in the public namespace of the library (that is, entities that are 158 * not in the public namespace of the library (that is, entities that are
156 * brought into the namespace via `export` directives). 159 * brought into the namespace via `export` directives).
157 * 160 *
158 * Sorted by name. 161 * Sorted by name.
159 */ 162 */
160 List<LinkedExportName> exportNames; 163 List<LinkedExportName> exportNames;
164
165 /**
166 * The number of elements in [dependencies] which are not "linked"
167 * dependencies (that is, the number of libraries in the direct imports plus
168 * the transitive closure of exports, plus the library itself).
169 */
170 int numPrelinkedDependencies;
161 } 171 }
162 172
163 /** 173 /**
164 * Information about the resolution of an [UnlinkedReference]. 174 * Information about the resolution of an [UnlinkedReference].
165 */ 175 */
166 class LinkedReference { 176 class LinkedReference {
167 /** 177 /**
168 * Index into [LinkedLibrary.dependencies] indicating which imported library 178 * Index into [LinkedLibrary.dependencies] indicating which imported library
169 * declares the entity being referred to. 179 * declares the entity being referred to.
170 */ 180 */
(...skipping 11 matching lines...) Expand all
182 * zero represents the defining compilation unit, and nonzero values 192 * zero represents the defining compilation unit, and nonzero values
183 * represent parts in the order of the corresponding `part` declarations. 193 * represent parts in the order of the corresponding `part` declarations.
184 */ 194 */
185 int unit; 195 int unit;
186 196
187 /** 197 /**
188 * If the entity being referred to is generic, the number of type parameters 198 * If the entity being referred to is generic, the number of type parameters
189 * it accepts. Otherwise zero. 199 * it accepts. Otherwise zero.
190 */ 200 */
191 int numTypeParameters; 201 int numTypeParameters;
202
203 /**
204 * If this [LinkedReference] doesn't have an associated [UnlinkedReference],
205 * name of the entity being referred to. The empty string refers to the
206 * pseudo-type `dynamic`.
207 */
208 String name;
192 } 209 }
193 210
194 /** 211 /**
195 * Linked summary of a compilation unit. 212 * Linked summary of a compilation unit.
196 */ 213 */
197 class LinkedUnit { 214 class LinkedUnit {
198 /** 215 /**
199 * For each reference in [UnlinkedUnit.references], information about how 216 * Information about the resolution of references within the compilation
200 * that reference is resolved. 217 * unit. Each element of [UnlinkedUnit.references] has a corresponding
218 * element in this list (at the same index). If this list has additional
219 * elements beyond the number of elements in [UnlinkedUnit.references], those
220 * additional elements are references that are only referred to implicitly
221 * (e.g. elements involved in inferred or propagated types).
201 */ 222 */
202 List<LinkedReference> references; 223 List<LinkedReference> references;
224
225 /**
226 * List associating slot ids found inside the unlinked summary for the
227 * compilation unit with propagated and inferred types.
228 */
229 List<TypeRef> types;
203 } 230 }
204 231
205 /** 232 /**
206 * Enum used to indicate the kind of entity referred to by a 233 * Enum used to indicate the kind of entity referred to by a
207 * [LinkedReference]. 234 * [LinkedReference].
208 */ 235 */
209 enum ReferenceKind { 236 enum ReferenceKind {
210 /** 237 /**
211 * The entity is a class or enum. 238 * The entity is a class or enum.
212 */ 239 */
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 * Unlinked information for the compilation units constituting the SDK. 289 * Unlinked information for the compilation units constituting the SDK.
263 */ 290 */
264 List<UnlinkedUnit> unlinkedUnits; 291 List<UnlinkedUnit> unlinkedUnits;
265 } 292 }
266 293
267 /** 294 /**
268 * Summary information about a reference to a type. 295 * Summary information about a reference to a type.
269 */ 296 */
270 class TypeRef { 297 class TypeRef {
271 /** 298 /**
299 * If this [TypeRef] is contained within [LinkedUnit.types], slot id (which
300 * is unique within the compilation unit) identifying the target of type
301 * propagation or type inference with which this [TypeRef] is asociated.
302 *
303 * Otherwise zero.
304 */
305 int slot;
306
307 /**
272 * Index into [UnlinkedUnit.references] for the type being referred to, or 308 * Index into [UnlinkedUnit.references] for the type being referred to, or
273 * zero if this is a reference to a type parameter. 309 * zero if this is a reference to a type parameter.
274 * 310 *
275 * Note that since zero is also a valid index into 311 * Note that since zero is also a valid index into
276 * [UnlinkedUnit.references], we cannot distinguish between references to 312 * [UnlinkedUnit.references], we cannot distinguish between references to
277 * type parameters and references to types by checking [reference] against 313 * type parameters and references to types by checking [reference] against
278 * zero. To distinguish between references to type parameters and references 314 * zero. To distinguish between references to type parameters and references
279 * to types, check whether [paramReference] is zero. 315 * to types, check whether [paramReference] is zero.
280 */ 316 */
281 int reference; 317 int reference;
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 1405
1370 /** 1406 /**
1371 * Indicates whether the variable is declared using the `const` keyword. 1407 * Indicates whether the variable is declared using the `const` keyword.
1372 */ 1408 */
1373 bool isConst; 1409 bool isConst;
1374 1410
1375 /** 1411 /**
1376 * Indicates whether this variable lacks an explicit type declaration. 1412 * Indicates whether this variable lacks an explicit type declaration.
1377 */ 1413 */
1378 bool hasImplicitType; 1414 bool hasImplicitType;
1415
1416 /**
1417 * If this variable is propagable, nonzero slot id identifying which entry in
1418 * [LinkedLibrary.types] contains the propagated type for this variable. If
1419 * there is no matching entry in [LinkedLibrary.types], then this variable's
1420 * propagated type is the same as its declared type.
1421 *
1422 * Non-propagable variables have a [propagatedTypeSlot] of zero.
1423 */
1424 int propagatedTypeSlot;
1379 } 1425 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/summary_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698