| 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 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1490 // [staticStateHolder]. | 1490 // [staticStateHolder]. |
| 1491 !element.isAccessor && | 1491 !element.isAccessor && |
| 1492 !element.isClass && | 1492 !element.isClass && |
| 1493 !element.isTypedef && | 1493 !element.isTypedef && |
| 1494 !element.isConstructor && | 1494 !element.isConstructor && |
| 1495 !element.isFunction && | 1495 !element.isFunction && |
| 1496 !element.isLibrary; | 1496 !element.isLibrary; |
| 1497 } | 1497 } |
| 1498 | 1498 |
| 1499 /// Returns [staticStateHolder] or one of [reservedGlobalObjectNames]. | 1499 /// Returns [staticStateHolder] or one of [reservedGlobalObjectNames]. |
| 1500 // TODO(johnniwinther): Verify that the implementation can be changed to |
| 1501 // `globalObjectForLibrary(element.library)`. |
| 1502 String globalObjectForMethod(MethodElement element) => |
| 1503 globalObjectFor(element); |
| 1504 |
| 1505 /// Returns [staticStateHolder] or one of [reservedGlobalObjectNames]. |
| 1500 String globalObjectFor(Element element) { | 1506 String globalObjectFor(Element element) { |
| 1501 if (_isPropertyOfStaticStateHolder(element)) return staticStateHolder; | 1507 if (_isPropertyOfStaticStateHolder(element)) return staticStateHolder; |
| 1502 LibraryElement library = element.library; | 1508 return globalObjectForLibrary(element.library); |
| 1509 } |
| 1510 |
| 1511 /// Returns the [reservedGlobalObjectNames] for [library]. |
| 1512 String globalObjectForLibrary(LibraryElement library) { |
| 1503 if (library == helpers.interceptorsLibrary) return 'J'; | 1513 if (library == helpers.interceptorsLibrary) return 'J'; |
| 1504 if (library.isInternalLibrary) return 'H'; | 1514 if (library.isInternalLibrary) return 'H'; |
| 1505 if (library.isPlatformLibrary) { | 1515 if (library.isPlatformLibrary) { |
| 1506 if ('${library.canonicalUri}' == 'dart:html') return 'W'; | 1516 if ('${library.canonicalUri}' == 'dart:html') return 'W'; |
| 1507 return 'P'; | 1517 return 'P'; |
| 1508 } | 1518 } |
| 1509 return userGlobalObjects[ | 1519 return userGlobalObjects[ |
| 1510 library.libraryOrScriptName.hashCode % userGlobalObjects.length]; | 1520 library.libraryOrScriptName.hashCode % userGlobalObjects.length]; |
| 1511 } | 1521 } |
| 1512 | 1522 |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2188 void addSuggestion(String original, String suggestion) { | 2198 void addSuggestion(String original, String suggestion) { |
| 2189 assert(!_suggestedNames.containsKey(original)); | 2199 assert(!_suggestedNames.containsKey(original)); |
| 2190 _suggestedNames[original] = suggestion; | 2200 _suggestedNames[original] = suggestion; |
| 2191 } | 2201 } |
| 2192 | 2202 |
| 2193 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); | 2203 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); |
| 2194 bool isSuggestion(String candidate) { | 2204 bool isSuggestion(String candidate) { |
| 2195 return _suggestedNames.containsValue(candidate); | 2205 return _suggestedNames.containsValue(candidate); |
| 2196 } | 2206 } |
| 2197 } | 2207 } |
| OLD | NEW |