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 part of js_backend; | 5 part of js_backend; |
6 | 6 |
7 /** | 7 /** |
8 * Assigns JavaScript identifiers to Dart variables, class-names and members. | 8 * Assigns JavaScript identifiers to Dart variables, class-names and members. |
9 */ | 9 */ |
10 class Namer implements ClosureNamer { | 10 class Namer implements ClosureNamer { |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 if (cls == backend.jsArrayClass) return "a"; | 559 if (cls == backend.jsArrayClass) return "a"; |
560 if (cls == backend.jsDoubleClass) return "d"; | 560 if (cls == backend.jsDoubleClass) return "d"; |
561 if (cls == backend.jsIntClass) return "i"; | 561 if (cls == backend.jsIntClass) return "i"; |
562 if (cls == backend.jsNumberClass) return "n"; | 562 if (cls == backend.jsNumberClass) return "n"; |
563 if (cls == backend.jsNullClass) return "u"; | 563 if (cls == backend.jsNullClass) return "u"; |
564 if (cls == backend.jsBoolClass) return "b"; | 564 if (cls == backend.jsBoolClass) return "b"; |
565 if (cls == backend.jsInterceptorClass) return "I"; | 565 if (cls == backend.jsInterceptorClass) return "I"; |
566 return cls.name.slowToString(); | 566 return cls.name.slowToString(); |
567 } | 567 } |
568 List<String> names = classes | 568 List<String> names = classes |
569 .where((cls) => !cls.isNative()) | 569 .where((cls) => !Elements.isNativeOrExtendsNative(cls)) |
570 .map(abbreviate) | 570 .map(abbreviate) |
571 .toList(); | 571 .toList(); |
572 // There is one dispatch mechanism for all native classes. | 572 // There is one dispatch mechanism for all native classes. |
573 if (classes.any((cls) => cls.isNative())) { | 573 if (classes.any((cls) => Elements.isNativeOrExtendsNative(cls))) { |
574 names.add("x"); | 574 names.add("x"); |
575 } | 575 } |
576 // Sort the names of the classes after abbreviating them to ensure | 576 // Sort the names of the classes after abbreviating them to ensure |
577 // the suffix is stable and predictable for the suggested names. | 577 // the suffix is stable and predictable for the suggested names. |
578 names.sort(); | 578 names.sort(); |
579 return names.join(); | 579 return names.join(); |
580 } | 580 } |
581 | 581 |
582 String getInterceptorName(Element element, Iterable<ClassElement> classes) { | 582 String getInterceptorName(Element element, Iterable<ClassElement> classes) { |
583 JavaScriptBackend backend = compiler.backend; | 583 JavaScriptBackend backend = compiler.backend; |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 if (!first) { | 1262 if (!first) { |
1263 sb.write('_'); | 1263 sb.write('_'); |
1264 } | 1264 } |
1265 sb.write('_'); | 1265 sb.write('_'); |
1266 visit(link.head); | 1266 visit(link.head); |
1267 first = true; | 1267 first = true; |
1268 } | 1268 } |
1269 } | 1269 } |
1270 } | 1270 } |
1271 } | 1271 } |
OLD | NEW |