OLD | NEW |
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 |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 element, () => asEntity.declaredEntity.name); | 846 element, () => asEntity.declaredEntity.name); |
847 } | 847 } |
848 | 848 |
849 // If the name of the field might clash with another field, | 849 // If the name of the field might clash with another field, |
850 // use a mangled field name to avoid potential clashes. | 850 // use a mangled field name to avoid potential clashes. |
851 // Note that if the class extends a native class, that native class might | 851 // Note that if the class extends a native class, that native class might |
852 // have fields with fixed backend names, so we assume the worst and always | 852 // have fields with fixed backend names, so we assume the worst and always |
853 // mangle the field names of classes extending native classes. | 853 // mangle the field names of classes extending native classes. |
854 // Methods on such classes are stored on the interceptor, not the instance, | 854 // Methods on such classes are stored on the interceptor, not the instance, |
855 // so only fields have the potential to clash with a native property name. | 855 // so only fields have the potential to clash with a native property name. |
856 ClassWorld classWorld = compiler.world; | 856 ClassWorld classWorld = compiler.closedWorld; |
857 if (classWorld.isUsedAsMixin(enclosingClass) || | 857 if (classWorld.isUsedAsMixin(enclosingClass) || |
858 _isShadowingSuperField(element) || | 858 _isShadowingSuperField(element) || |
859 _isUserClassExtendingNative(enclosingClass)) { | 859 _isUserClassExtendingNative(enclosingClass)) { |
860 String proposeName() => '${enclosingClass.name}_${element.name}'; | 860 String proposeName() => '${enclosingClass.name}_${element.name}'; |
861 return _disambiguateInternalMember(element, proposeName); | 861 return _disambiguateInternalMember(element, proposeName); |
862 } | 862 } |
863 | 863 |
864 // No superclass uses the disambiguated name as a property name, so we can | 864 // No superclass uses the disambiguated name as a property name, so we can |
865 // use it for this field. This generates nicer field names since otherwise | 865 // use it for this field. This generates nicer field names since otherwise |
866 // the field name would have to be mangled. | 866 // the field name would have to be mangled. |
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2100 void addSuggestion(String original, String suggestion) { | 2100 void addSuggestion(String original, String suggestion) { |
2101 assert(!_suggestedNames.containsKey(original)); | 2101 assert(!_suggestedNames.containsKey(original)); |
2102 _suggestedNames[original] = suggestion; | 2102 _suggestedNames[original] = suggestion; |
2103 } | 2103 } |
2104 | 2104 |
2105 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); | 2105 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); |
2106 bool isSuggestion(String candidate) { | 2106 bool isSuggestion(String candidate) { |
2107 return _suggestedNames.containsValue(candidate); | 2107 return _suggestedNames.containsValue(candidate); |
2108 } | 2108 } |
2109 } | 2109 } |
OLD | NEW |