| 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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 JavaScriptBackend backend = compiler.backend; | 545 JavaScriptBackend backend = compiler.backend; |
| 546 if (cls == backend.jsStringClass) return "s"; | 546 if (cls == backend.jsStringClass) return "s"; |
| 547 if (cls == backend.jsArrayClass) return "a"; | 547 if (cls == backend.jsArrayClass) return "a"; |
| 548 if (cls == backend.jsDoubleClass) return "d"; | 548 if (cls == backend.jsDoubleClass) return "d"; |
| 549 if (cls == backend.jsNumberClass) return "n"; | 549 if (cls == backend.jsNumberClass) return "n"; |
| 550 if (cls == backend.jsNullClass) return "u"; | 550 if (cls == backend.jsNullClass) return "u"; |
| 551 if (cls == backend.jsFunctionClass) return "f"; | 551 if (cls == backend.jsFunctionClass) return "f"; |
| 552 if (cls == backend.jsBoolClass) return "b"; | 552 if (cls == backend.jsBoolClass) return "b"; |
| 553 return cls.name.slowToString(); | 553 return cls.name.slowToString(); |
| 554 } | 554 } |
| 555 List<String> names = classes |
| 556 .where((cls) => !cls.isNative()) |
| 557 .map(abbreviate) |
| 558 .toList(); |
| 559 // There is one dispatch mechanism for all native classes. |
| 560 if (classes.any((cls) => cls.isNative())) { |
| 561 names.add("x"); |
| 562 } |
| 555 // Sort the names of the classes after abbreviating them to ensure | 563 // Sort the names of the classes after abbreviating them to ensure |
| 556 // the suffix is stable and predictable for the suggested names. | 564 // the suffix is stable and predictable for the suggested names. |
| 557 List<String> names = classes.map(abbreviate).toList(); | |
| 558 names.sort(); | 565 names.sort(); |
| 559 return names.join(); | 566 return names.join(); |
| 560 } | 567 } |
| 561 | 568 |
| 562 String getInterceptorName(Element element, Collection<ClassElement> classes) { | 569 String getInterceptorName(Element element, Collection<ClassElement> classes) { |
| 563 if (classes.contains(compiler.objectClass)) { | 570 if (classes.contains(compiler.objectClass)) { |
| 564 // If the object class is in the set of intercepted classes, we | 571 // If the object class is in the set of intercepted classes, we |
| 565 // need to go through the generic getInterceptorMethod. | 572 // need to go through the generic getInterceptorMethod. |
| 566 return getName(element); | 573 return getName(element); |
| 567 } | 574 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 return const SourceString(r'$or'); | 790 return const SourceString(r'$or'); |
| 784 } else if (value == '-') { | 791 } else if (value == '-') { |
| 785 return const SourceString(r'$sub'); | 792 return const SourceString(r'$sub'); |
| 786 } else if (value == 'unary-') { | 793 } else if (value == 'unary-') { |
| 787 return const SourceString(r'$negate'); | 794 return const SourceString(r'$negate'); |
| 788 } else { | 795 } else { |
| 789 return name; | 796 return name; |
| 790 } | 797 } |
| 791 } | 798 } |
| 792 } | 799 } |
| OLD | NEW |