| 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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 /// [element.fixedBackendName] should be evaluated. Only applicable for | 789 /// [element.fixedBackendName] should be evaluated. Only applicable for |
| 790 /// elements using typed JavaScript interop. | 790 /// elements using typed JavaScript interop. |
| 791 /// For example: fixedBackendPath for the static method createMap in the | 791 /// For example: fixedBackendPath for the static method createMap in the |
| 792 /// Map class of the goog.map JavaScript library would have path | 792 /// Map class of the goog.map JavaScript library would have path |
| 793 /// "goog.maps.Map". | 793 /// "goog.maps.Map". |
| 794 String fixedBackendMethodPath(MethodElement element) { | 794 String fixedBackendMethodPath(MethodElement element) { |
| 795 return _fixedBackendPath(element); | 795 return _fixedBackendPath(element); |
| 796 } | 796 } |
| 797 | 797 |
| 798 String _fixedBackendPath(Element element) { | 798 String _fixedBackendPath(Element element) { |
| 799 if (!backend.isJsInterop(element)) return null; | 799 if (!backend.nativeData.isJsInterop(element)) return null; |
| 800 if (element.isInstanceMember) return 'this'; | 800 if (element.isInstanceMember) return 'this'; |
| 801 if (element.isConstructor) return _fixedBackendPath(element.enclosingClass); | 801 if (element.isConstructor) return _fixedBackendPath(element.enclosingClass); |
| 802 if (element.isLibrary) return 'self'; | 802 if (element.isLibrary) return 'self'; |
| 803 var sb = new StringBuffer(); | 803 var sb = new StringBuffer(); |
| 804 sb..write(_jsNameHelper(element.library)); | 804 sb..write(_jsNameHelper(element.library)); |
| 805 | 805 |
| 806 if (element.enclosingClass != null && element.enclosingClass != element) { | 806 if (element.enclosingClass != null && element.enclosingClass != element) { |
| 807 sb..write('.')..write(_jsNameHelper(element.enclosingClass)); | 807 sb..write('.')..write(_jsNameHelper(element.enclosingClass)); |
| 808 } | 808 } |
| 809 return sb.toString(); | 809 return sb.toString(); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 // the field name would have to be mangled. | 972 // the field name would have to be mangled. |
| 973 return _disambiguateMember(element.memberName); | 973 return _disambiguateMember(element.memberName); |
| 974 } | 974 } |
| 975 | 975 |
| 976 bool _isShadowingSuperField(Element element) { | 976 bool _isShadowingSuperField(Element element) { |
| 977 return element.enclosingClass.hasFieldShadowedBy(element); | 977 return element.enclosingClass.hasFieldShadowedBy(element); |
| 978 } | 978 } |
| 979 | 979 |
| 980 /// True if [class_] is a non-native class that inherits from a native class. | 980 /// True if [class_] is a non-native class that inherits from a native class. |
| 981 bool _isUserClassExtendingNative(ClassElement class_) { | 981 bool _isUserClassExtendingNative(ClassElement class_) { |
| 982 return !backend.isNative(class_) && | 982 return !backend.nativeData.isNativeClass(class_) && |
| 983 backend.nativeData.isNativeOrExtendsNative(class_.superclass); | 983 backend.nativeData.isNativeOrExtendsNative(class_.superclass); |
| 984 } | 984 } |
| 985 | 985 |
| 986 /// Annotated name for the setter of [element]. | 986 /// Annotated name for the setter of [element]. |
| 987 jsAst.Name setterForElement(MemberElement element) { | 987 jsAst.Name setterForElement(MemberElement element) { |
| 988 // We dynamically create setters from the field-name. The setter name must | 988 // We dynamically create setters from the field-name. The setter name must |
| 989 // therefore be derived from the instance field-name. | 989 // therefore be derived from the instance field-name. |
| 990 jsAst.Name name = _disambiguateMember(element.memberName); | 990 jsAst.Name name = _disambiguateMember(element.memberName); |
| 991 return deriveSetterName(name); | 991 return deriveSetterName(name); |
| 992 } | 992 } |
| (...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2207 void addSuggestion(String original, String suggestion) { | 2207 void addSuggestion(String original, String suggestion) { |
| 2208 assert(!_suggestedNames.containsKey(original)); | 2208 assert(!_suggestedNames.containsKey(original)); |
| 2209 _suggestedNames[original] = suggestion; | 2209 _suggestedNames[original] = suggestion; |
| 2210 } | 2210 } |
| 2211 | 2211 |
| 2212 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); | 2212 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); |
| 2213 bool isSuggestion(String candidate) { | 2213 bool isSuggestion(String candidate) { |
| 2214 return _suggestedNames.containsValue(candidate); | 2214 return _suggestedNames.containsValue(candidate); |
| 2215 } | 2215 } |
| 2216 } | 2216 } |
| OLD | NEW |