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

Side by Side Diff: pkg/compiler/lib/src/js_backend/namer.dart

Issue 2997033002: Revert "Implement .getCallType" and "Update status" (Closed)
Patch Set: Created 3 years, 4 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 js_backend.namer; 5 library js_backend.namer;
6 6
7 import 'dart:collection' show HashMap; 7 import 'dart:collection' show HashMap;
8 8
9 import 'package:js_runtime/shared/embedded_names.dart' show JsGetName; 9 import 'package:js_runtime/shared/embedded_names.dart' show JsGetName;
10 10
11 import '../closure.dart'; 11 import '../closure.dart';
12 import '../common.dart'; 12 import '../common.dart';
13 import '../common/names.dart' show Identifiers, Selectors; 13 import '../common/names.dart' show Identifiers, Selectors;
14 import '../constants/values.dart'; 14 import '../constants/values.dart';
15 import '../common_elements.dart' show CommonElements, ElementEnvironment; 15 import '../common_elements.dart' show CommonElements;
16 import '../diagnostics/invariant.dart' show DEBUG_MODE; 16 import '../diagnostics/invariant.dart' show DEBUG_MODE;
17 import '../elements/elements.dart' 17 import '../elements/elements.dart'
18 show 18 show
19 ClassElement, 19 ClassElement,
20 Element, 20 Element,
21 Elements, 21 Elements,
22 MemberElement, 22 MemberElement,
23 MixinApplicationElement; 23 MixinApplicationElement;
24 import '../elements/entities.dart'; 24 import '../elements/entities.dart';
25 import '../elements/entity_utils.dart' as utils; 25 import '../elements/entity_utils.dart' as utils;
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 final Map<LibraryEntity, String> _libraryKeys = 571 final Map<LibraryEntity, String> _libraryKeys =
572 new HashMap<LibraryEntity, String>(); 572 new HashMap<LibraryEntity, String>();
573 573
574 Namer(this._closedWorld, this._codegenWorldBuilder) { 574 Namer(this._closedWorld, this._codegenWorldBuilder) {
575 _literalAsyncPrefix = new StringBackedName(asyncPrefix); 575 _literalAsyncPrefix = new StringBackedName(asyncPrefix);
576 _literalGetterPrefix = new StringBackedName(getterPrefix); 576 _literalGetterPrefix = new StringBackedName(getterPrefix);
577 _literalSetterPrefix = new StringBackedName(setterPrefix); 577 _literalSetterPrefix = new StringBackedName(setterPrefix);
578 _literalLazyGetterPrefix = new StringBackedName(lazyGetterPrefix); 578 _literalLazyGetterPrefix = new StringBackedName(lazyGetterPrefix);
579 } 579 }
580 580
581 ElementEnvironment get _elementEnvironment => _closedWorld.elementEnvironment;
582
583 CommonElements get _commonElements => _closedWorld.commonElements; 581 CommonElements get _commonElements => _closedWorld.commonElements;
584 582
585 NativeData get _nativeData => _closedWorld.nativeData; 583 NativeData get _nativeData => _closedWorld.nativeData;
586 584
587 String get deferredTypesName => 'deferredTypes'; 585 String get deferredTypesName => 'deferredTypes';
588 String get isolateName => 'Isolate'; 586 String get isolateName => 'Isolate';
589 String get isolatePropertiesName => r'$isolateProperties'; 587 String get isolatePropertiesName => r'$isolateProperties';
590 jsAst.Name get noSuchMethodName => invocationName(Selectors.noSuchMethod_); 588 jsAst.Name get noSuchMethodName => invocationName(Selectors.noSuchMethod_);
591 589
592 /** 590 /**
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 return _disambiguateInternalMember(element, proposeName); 946 return _disambiguateInternalMember(element, proposeName);
949 } 947 }
950 948
951 // No superclass uses the disambiguated name as a property name, so we can 949 // No superclass uses the disambiguated name as a property name, so we can
952 // use it for this field. This generates nicer field names since otherwise 950 // use it for this field. This generates nicer field names since otherwise
953 // the field name would have to be mangled. 951 // the field name would have to be mangled.
954 return _disambiguateMember(new Name(element.name, element.library)); 952 return _disambiguateMember(new Name(element.name, element.library));
955 } 953 }
956 954
957 bool _isShadowingSuperField(FieldEntity element) { 955 bool _isShadowingSuperField(FieldEntity element) {
958 assert(element.isField); 956 ClassEntity cls = element.enclosingClass;
959 String fieldName = element.name; 957 if (cls is ClassElement) {
960 bool isPrivate = Name.isPrivateName(fieldName); 958 return cls.hasFieldShadowedBy(element);
961 LibraryEntity memberLibrary = element.library;
962 ClassEntity lookupClass =
963 _elementEnvironment.getSuperClass(element.enclosingClass);
964 while (lookupClass != null) {
965 MemberEntity foundMember =
966 _elementEnvironment.lookupClassMember(lookupClass, fieldName);
967 if (foundMember != null) {
968 if (foundMember.isField) {
969 if (!isPrivate || memberLibrary == foundMember.library) {
970 // Private fields can only be shadowed by a field declared in the
971 // same library.
972 return true;
973 }
974 }
975 }
976 lookupClass = _elementEnvironment.getSuperClass(lookupClass);
977 } 959 }
960 // TODO(redemption): Support class entities.
978 return false; 961 return false;
979 } 962 }
980 963
981 /// True if [class_] is a non-native class that inherits from a native class. 964 /// True if [class_] is a non-native class that inherits from a native class.
982 bool _isUserClassExtendingNative(ClassEntity class_) { 965 bool _isUserClassExtendingNative(ClassEntity class_) {
983 return !_nativeData.isNativeClass(class_) && 966 return !_nativeData.isNativeClass(class_) &&
984 _nativeData.isNativeOrExtendsNative(class_); 967 _nativeData.isNativeOrExtendsNative(class_);
985 } 968 }
986 969
987 /// Annotated name for the setter of [element]. 970 /// Annotated name for the setter of [element].
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 void addSuggestion(String original, String suggestion) { 2244 void addSuggestion(String original, String suggestion) {
2262 assert(!_suggestedNames.containsKey(original)); 2245 assert(!_suggestedNames.containsKey(original));
2263 _suggestedNames[original] = suggestion; 2246 _suggestedNames[original] = suggestion;
2264 } 2247 }
2265 2248
2266 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); 2249 bool hasSuggestion(String original) => _suggestedNames.containsKey(original);
2267 bool isSuggestion(String candidate) { 2250 bool isSuggestion(String candidate) {
2268 return _suggestedNames.containsValue(candidate); 2251 return _suggestedNames.containsValue(candidate);
2269 } 2252 }
2270 } 2253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698