| 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 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 } | 1515 } |
| 1516 | 1516 |
| 1517 /// Returns the [reservedGlobalObjectNames] for [library]. | 1517 /// Returns the [reservedGlobalObjectNames] for [library]. |
| 1518 String globalObjectForLibrary(LibraryElement library) { | 1518 String globalObjectForLibrary(LibraryElement library) { |
| 1519 if (library == helpers.interceptorsLibrary) return 'J'; | 1519 if (library == helpers.interceptorsLibrary) return 'J'; |
| 1520 if (library.isInternalLibrary) return 'H'; | 1520 if (library.isInternalLibrary) return 'H'; |
| 1521 if (library.isPlatformLibrary) { | 1521 if (library.isPlatformLibrary) { |
| 1522 if ('${library.canonicalUri}' == 'dart:html') return 'W'; | 1522 if ('${library.canonicalUri}' == 'dart:html') return 'W'; |
| 1523 return 'P'; | 1523 return 'P'; |
| 1524 } | 1524 } |
| 1525 return userGlobalObjects[ | 1525 return userGlobalObjects[library.name.hashCode % userGlobalObjects.length]; |
| 1526 library.libraryOrScriptName.hashCode % userGlobalObjects.length]; | |
| 1527 } | 1526 } |
| 1528 | 1527 |
| 1529 jsAst.Name deriveLazyInitializerName(jsAst.Name name) { | 1528 jsAst.Name deriveLazyInitializerName(jsAst.Name name) { |
| 1530 // These are not real dart getters, so do not use GetterName; | 1529 // These are not real dart getters, so do not use GetterName; |
| 1531 return new CompoundName([_literalLazyGetterPrefix, name]); | 1530 return new CompoundName([_literalLazyGetterPrefix, name]); |
| 1532 } | 1531 } |
| 1533 | 1532 |
| 1534 jsAst.Name lazyInitializerName(Element element) { | 1533 jsAst.Name lazyInitializerName(Element element) { |
| 1535 assert(Elements.isStaticOrTopLevelField(element)); | 1534 assert(Elements.isStaticOrTopLevelField(element)); |
| 1536 jsAst.Name name = _disambiguateGlobal(element); | 1535 jsAst.Name name = _disambiguateGlobal(element); |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2192 void addSuggestion(String original, String suggestion) { | 2191 void addSuggestion(String original, String suggestion) { |
| 2193 assert(!_suggestedNames.containsKey(original)); | 2192 assert(!_suggestedNames.containsKey(original)); |
| 2194 _suggestedNames[original] = suggestion; | 2193 _suggestedNames[original] = suggestion; |
| 2195 } | 2194 } |
| 2196 | 2195 |
| 2197 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); | 2196 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); |
| 2198 bool isSuggestion(String candidate) { | 2197 bool isSuggestion(String candidate) { |
| 2199 return _suggestedNames.containsValue(candidate); | 2198 return _suggestedNames.containsValue(candidate); |
| 2200 } | 2199 } |
| 2201 } | 2200 } |
| OLD | NEW |