| 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 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 if (cls == helpers.jsStringClass) return "s"; | 1244 if (cls == helpers.jsStringClass) return "s"; |
| 1245 if (cls == helpers.jsArrayClass) return "a"; | 1245 if (cls == helpers.jsArrayClass) return "a"; |
| 1246 if (cls == helpers.jsDoubleClass) return "d"; | 1246 if (cls == helpers.jsDoubleClass) return "d"; |
| 1247 if (cls == helpers.jsIntClass) return "i"; | 1247 if (cls == helpers.jsIntClass) return "i"; |
| 1248 if (cls == helpers.jsNumberClass) return "n"; | 1248 if (cls == helpers.jsNumberClass) return "n"; |
| 1249 if (cls == helpers.jsNullClass) return "u"; | 1249 if (cls == helpers.jsNullClass) return "u"; |
| 1250 if (cls == helpers.jsBoolClass) return "b"; | 1250 if (cls == helpers.jsBoolClass) return "b"; |
| 1251 if (cls == helpers.jsInterceptorClass) return "I"; | 1251 if (cls == helpers.jsInterceptorClass) return "I"; |
| 1252 return cls.name; | 1252 return cls.name; |
| 1253 } | 1253 } |
| 1254 |
| 1254 List<String> names = classes | 1255 List<String> names = classes |
| 1255 .where((cls) => !backend.isNativeOrExtendsNative(cls)) | 1256 .where((cls) => !backend.isNativeOrExtendsNative(cls)) |
| 1256 .map(abbreviate) | 1257 .map(abbreviate) |
| 1257 .toList(); | 1258 .toList(); |
| 1258 // There is one dispatch mechanism for all native classes. | 1259 // There is one dispatch mechanism for all native classes. |
| 1259 if (classes.any((cls) => backend.isNativeOrExtendsNative(cls))) { | 1260 if (classes.any((cls) => backend.isNativeOrExtendsNative(cls))) { |
| 1260 names.add("x"); | 1261 names.add("x"); |
| 1261 } | 1262 } |
| 1262 // Sort the names of the classes after abbreviating them to ensure | 1263 // Sort the names of the classes after abbreviating them to ensure |
| 1263 // the suffix is stable and predictable for the suggested names. | 1264 // the suffix is stable and predictable for the suggested names. |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2087 void addSuggestion(String original, String suggestion) { | 2088 void addSuggestion(String original, String suggestion) { |
| 2088 assert(!_suggestedNames.containsKey(original)); | 2089 assert(!_suggestedNames.containsKey(original)); |
| 2089 _suggestedNames[original] = suggestion; | 2090 _suggestedNames[original] = suggestion; |
| 2090 } | 2091 } |
| 2091 | 2092 |
| 2092 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); | 2093 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); |
| 2093 bool isSuggestion(String candidate) { | 2094 bool isSuggestion(String candidate) { |
| 2094 return _suggestedNames.containsValue(candidate); | 2095 return _suggestedNames.containsValue(candidate); |
| 2095 } | 2096 } |
| 2096 } | 2097 } |
| OLD | NEW |