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

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

Issue 1642483002: Improve 'length' instance property reference encoding. (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
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 import 'package:analyzer/src/summary/format.dart'; 5 import 'package:analyzer/src/summary/format.dart';
6 import 'package:analyzer/src/summary/name_filter.dart'; 6 import 'package:analyzer/src/summary/name_filter.dart';
7 7
8 /** 8 /**
9 * Create a [LinkedLibraryBuilder] corresponding to the given 9 * Create a [LinkedLibraryBuilder] corresponding to the given
10 * [definingUnit], which should be the defining compilation unit for a library. 10 * [definingUnit], which should be the defining compilation unit for a library.
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 List<LinkedReferenceBuilder> references = <LinkedReferenceBuilder>[]; 405 List<LinkedReferenceBuilder> references = <LinkedReferenceBuilder>[];
406 for (int i = 0; i < unit.references.length; i++) { 406 for (int i = 0; i < unit.references.length; i++) {
407 UnlinkedReference reference = unit.references[i]; 407 UnlinkedReference reference = unit.references[i];
408 Map<String, _Meaning> namespace; 408 Map<String, _Meaning> namespace;
409 if (reference.prefixReference == 0) { 409 if (reference.prefixReference == 0) {
410 namespace = privateNamespace; 410 namespace = privateNamespace;
411 } else { 411 } else {
412 // Prefix references must always point backward. 412 // Prefix references must always point backward.
413 assert(reference.prefixReference < i); 413 assert(reference.prefixReference < i);
414 namespace = prefixNamespaces[reference.prefixReference]; 414 namespace = prefixNamespaces[reference.prefixReference];
415 // If in `a.length` the `a` prefix is a top-level variable or a field,
416 // then it must be the `String.length` property reference.
417 if (namespace == null && reference.name == 'length') {
418 ReferenceKind prefixKind = references[reference.prefixReference].kind;
419 if (prefixKind == ReferenceKind.topLevelPropertyAccessor ||
420 prefixKind == ReferenceKind.constField) {
421 references
422 .add(new LinkedReferenceBuilder(kind: ReferenceKind.length));
423 continue;
424 }
425 }
415 // Prefix references must always point to proper prefixes. 426 // Prefix references must always point to proper prefixes.
416 assert(namespace != null); 427 assert(namespace != null);
417 } 428 }
418 _Meaning meaning = namespace[reference.name]; 429 _Meaning meaning = namespace[reference.name];
419 if (meaning != null) { 430 if (meaning != null) {
420 if (meaning is _PrefixMeaning) { 431 if (meaning is _PrefixMeaning) {
421 prefixNamespaces[i] = meaning.namespace; 432 prefixNamespaces[i] = meaning.namespace;
422 } else if (meaning is _ClassMeaning) { 433 } else if (meaning is _ClassMeaning) {
423 prefixNamespaces[i] = meaning.namespace; 434 prefixNamespaces[i] = meaning.namespace;
424 } 435 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 * [sourceUri] is also relative. 499 * [sourceUri] is also relative.
489 */ 500 */
490 String resolveUri(String sourceUri, String relativeUri) { 501 String resolveUri(String sourceUri, String relativeUri) {
491 if (sourceUri == null) { 502 if (sourceUri == null) {
492 return relativeUri; 503 return relativeUri;
493 } else { 504 } else {
494 return Uri.parse(sourceUri).resolve(relativeUri).toString(); 505 return Uri.parse(sourceUri).resolve(relativeUri).toString();
495 } 506 }
496 } 507 }
497 } 508 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698