| 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 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 /// of the other objects in [reservedGlobalObjectNames]. | 815 /// of the other objects in [reservedGlobalObjectNames]. |
| 816 bool isPropertyOfCurrentIsolate(Element element) { | 816 bool isPropertyOfCurrentIsolate(Element element) { |
| 817 // TODO(ahe): Make sure this method's documentation is always true and | 817 // TODO(ahe): Make sure this method's documentation is always true and |
| 818 // remove the word "intend". | 818 // remove the word "intend". |
| 819 return | 819 return |
| 820 // TODO(ahe): Re-write these tests to be positive (so it only returns | 820 // TODO(ahe): Re-write these tests to be positive (so it only returns |
| 821 // true for static/top-level mutable fields). Right now, a number of | 821 // true for static/top-level mutable fields). Right now, a number of |
| 822 // other elements, such as bound closures also live in [currentIsolate]. | 822 // other elements, such as bound closures also live in [currentIsolate]. |
| 823 !element.isAccessor && | 823 !element.isAccessor && |
| 824 !element.isClass && | 824 !element.isClass && |
| 825 !element.isTypedef && |
| 825 !element.isConstructor && | 826 !element.isConstructor && |
| 826 !element.isFunction && | 827 !element.isFunction && |
| 827 !element.isLibrary; | 828 !element.isLibrary; |
| 828 } | 829 } |
| 829 | 830 |
| 830 /// Returns [currentIsolate] or one of [reservedGlobalObjectNames]. | 831 /// Returns [currentIsolate] or one of [reservedGlobalObjectNames]. |
| 831 String globalObjectFor(Element element) { | 832 String globalObjectFor(Element element) { |
| 832 if (isPropertyOfCurrentIsolate(element)) return currentIsolate; | 833 if (isPropertyOfCurrentIsolate(element)) return currentIsolate; |
| 833 LibraryElement library = element.library; | 834 LibraryElement library = element.library; |
| 834 if (library == backend.interceptorsLibrary) return 'J'; | 835 if (library == backend.interceptorsLibrary) return 'J'; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 } | 877 } |
| 877 | 878 |
| 878 String globalObjectForConstant(Constant constant) => 'C'; | 879 String globalObjectForConstant(Constant constant) => 'C'; |
| 879 | 880 |
| 880 String operatorIsPrefix() => r'$is'; | 881 String operatorIsPrefix() => r'$is'; |
| 881 | 882 |
| 882 String operatorAsPrefix() => r'$as'; | 883 String operatorAsPrefix() => r'$as'; |
| 883 | 884 |
| 884 String operatorSignature() => r'$signature'; | 885 String operatorSignature() => r'$signature'; |
| 885 | 886 |
| 887 String typedefTag() => r'typedef'; |
| 888 |
| 886 String functionTypeTag() => r'func'; | 889 String functionTypeTag() => r'func'; |
| 887 | 890 |
| 888 String functionTypeVoidReturnTag() => r'void'; | 891 String functionTypeVoidReturnTag() => r'void'; |
| 889 | 892 |
| 890 String functionTypeReturnTypeTag() => r'ret'; | 893 String functionTypeReturnTypeTag() => r'ret'; |
| 891 | 894 |
| 892 String functionTypeRequiredParametersTag() => r'args'; | 895 String functionTypeRequiredParametersTag() => r'args'; |
| 893 | 896 |
| 894 String functionTypeOptionalParametersTag() => r'opt'; | 897 String functionTypeOptionalParametersTag() => r'opt'; |
| 895 | 898 |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 if (!first) { | 1374 if (!first) { |
| 1372 sb.write('_'); | 1375 sb.write('_'); |
| 1373 } | 1376 } |
| 1374 sb.write('_'); | 1377 sb.write('_'); |
| 1375 visit(parameter); | 1378 visit(parameter); |
| 1376 first = true; | 1379 first = true; |
| 1377 } | 1380 } |
| 1378 } | 1381 } |
| 1379 } | 1382 } |
| 1380 } | 1383 } |
| OLD | NEW |