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

Side by Side Diff: pkg/analyzer/lib/src/summary/link.dart

Issue 1841283002: When building summaries from ASTs, handle circularities involving .length. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library is capable of producing linked summaries from unlinked 6 * This library is capable of producing linked summaries from unlinked
7 * ones (or prelinked ones). It functions by building a miniature 7 * ones (or prelinked ones). It functions by building a miniature
8 * element model to represent the contents of the summaries, and then 8 * element model to represent the contents of the summaries, and then
9 * scanning the element model to gather linked information and adding 9 * scanning the element model to gather linked information and adding
10 * it to the summary data structures. 10 * it to the summary data structures.
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 */ 1320 */
1321 bool get isEvaluated; 1321 bool get isEvaluated;
1322 1322
1323 /** 1323 /**
1324 * Compute the dependencies of this node. 1324 * Compute the dependencies of this node.
1325 */ 1325 */
1326 List<NodeType> computeDependencies(); 1326 List<NodeType> computeDependencies();
1327 } 1327 }
1328 1328
1329 /** 1329 /**
1330 * Element used for references that result from trying to access a nonstatic
1331 * member of an element that is not a container (e.g. accessing the "length"
1332 * property of a constant).
1333 */
1334 class NonstaticMemberElementForLink implements ReferenceableElementForLink {
1335 /**
1336 * If the thing from which a member was accessed is a constant, the
1337 * associated [ConstNode]. Otherwise `null`.
1338 */
1339 final ConstVariableNode _constNode;
1340
1341 NonstaticMemberElementForLink(this._constNode);
1342
1343 @override
1344 ConstructorElementForLink get asConstructor => null;
1345
1346 @override
1347 ConstVariableNode get asConstVariable => _constNode;
1348
1349 @override
1350 DartTypeForLink buildType(DartTypeForLink getTypeArgument(int i),
1351 List<int> implicitFunctionTypeIndices) =>
1352 DynamicTypeForLink.instance;
1353
1354 @override
1355 ReferenceableElementForLink getContainedName(String name) => this;
1356 }
1357
1358 /**
1330 * Element representing a function or method parameter resynthesized 1359 * Element representing a function or method parameter resynthesized
1331 * from a summary during linking. 1360 * from a summary during linking.
1332 */ 1361 */
1333 class ParameterElementForLink implements ParameterElement { 1362 class ParameterElementForLink implements ParameterElement {
1334 /** 1363 /**
1335 * The unlinked representation of the parameter in the summary. 1364 * The unlinked representation of the parameter in the summary.
1336 */ 1365 */
1337 final UnlinkedParam _unlinkedParam; 1366 final UnlinkedParam _unlinkedParam;
1338 1367
1339 /** 1368 /**
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 1527
1499 @override 1528 @override
1500 String get name => unlinkedVariable.name; 1529 String get name => unlinkedVariable.name;
1501 1530
1502 @override 1531 @override
1503 DartTypeForLink buildType(DartTypeForLink getTypeArgument(int i), 1532 DartTypeForLink buildType(DartTypeForLink getTypeArgument(int i),
1504 List<int> implicitFunctionTypeIndices) => 1533 List<int> implicitFunctionTypeIndices) =>
1505 DynamicTypeForLink.instance; 1534 DynamicTypeForLink.instance;
1506 1535
1507 ReferenceableElementForLink getContainedName(String name) { 1536 ReferenceableElementForLink getContainedName(String name) {
1508 // TODO(paulberry): implement. 1537 return new NonstaticMemberElementForLink(_constNode);
1509 // TODO(paulberry): make sure that circularities involving
1510 // ".length" are handled correctly.
1511 return UndefinedElementForLink.instance;
1512 } 1538 }
1513 1539
1514 @override 1540 @override
1515 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 1541 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
1516 } 1542 }
1517 1543
1518 /** 1544 /**
1519 * Representation of the void type during linking. 1545 * Representation of the void type during linking.
1520 */ 1546 */
1521 class VoidTypeForLink extends DartTypeForLink { 1547 class VoidTypeForLink extends DartTypeForLink {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 1629
1604 /** 1630 /**
1605 * Throw away any information produced by a previous call to [link]. 1631 * Throw away any information produced by a previous call to [link].
1606 */ 1632 */
1607 void unlink() { 1633 void unlink() {
1608 for (LibraryElementInBuildUnit library in _librariesInBuildUnit) { 1634 for (LibraryElementInBuildUnit library in _librariesInBuildUnit) {
1609 library.unlink(); 1635 library.unlink();
1610 } 1636 }
1611 } 1637 }
1612 } 1638 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698