| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // 26 letters in the alphabet, 25 not counting I. | 213 // 26 letters in the alphabet, 25 not counting I. |
| 214 assert(reservedGlobalObjectNames.length == 25); | 214 assert(reservedGlobalObjectNames.length == 25); |
| 215 _jsVariableReserved.addAll(reservedGlobalHelperFunctions); | 215 _jsVariableReserved.addAll(reservedGlobalHelperFunctions); |
| 216 } | 216 } |
| 217 return _jsVariableReserved; | 217 return _jsVariableReserved; |
| 218 } | 218 } |
| 219 | 219 |
| 220 final String currentIsolate = r'$'; | 220 final String currentIsolate = r'$'; |
| 221 final String getterPrefix = r'get$'; | 221 final String getterPrefix = r'get$'; |
| 222 final String setterPrefix = r'set$'; | 222 final String setterPrefix = r'set$'; |
| 223 final String superPrefix = r'super$'; |
| 223 final String metadataField = '@'; | 224 final String metadataField = '@'; |
| 224 final String callPrefix = 'call'; | 225 final String callPrefix = 'call'; |
| 225 final String callCatchAllName = r'call$catchAll'; | 226 final String callCatchAllName = r'call$catchAll'; |
| 226 final String reflectableField = r'$reflectable'; | 227 final String reflectableField = r'$reflectable'; |
| 227 final String defaultValuesField = r'$defaultValues'; | 228 final String defaultValuesField = r'$defaultValues'; |
| 228 final String methodsWithOptionalArgumentsField = | 229 final String methodsWithOptionalArgumentsField = |
| 229 r'$methodsWithOptionalArguments'; | 230 r'$methodsWithOptionalArguments'; |
| 230 | 231 |
| 231 final String classDescriptorProperty = r'^'; | 232 final String classDescriptorProperty = r'^'; |
| 232 | 233 |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 | 803 |
| 803 String getNameOfLibrary(LibraryElement library) => getNameX(library); | 804 String getNameOfLibrary(LibraryElement library) => getNameX(library); |
| 804 | 805 |
| 805 String getNameOfClass(ClassElement cls) => getNameX(cls); | 806 String getNameOfClass(ClassElement cls) => getNameX(cls); |
| 806 | 807 |
| 807 String getNameOfField(VariableElement field) => getNameX(field); | 808 String getNameOfField(VariableElement field) => getNameX(field); |
| 808 | 809 |
| 809 // TODO(ahe): Remove this method. Use get getNameOfMember instead. | 810 // TODO(ahe): Remove this method. Use get getNameOfMember instead. |
| 810 String getNameOfInstanceMember(Element member) => getNameX(member); | 811 String getNameOfInstanceMember(Element member) => getNameX(member); |
| 811 | 812 |
| 813 String getNameOfAliasedSuperMember(Element member) { |
| 814 ClassElement superClass = member.enclosingClass; |
| 815 String className = getNameOfClass(superClass); |
| 816 String memberName = getNameOfMember(member); |
| 817 String proposal = "$superPrefix$className\$$memberName"; |
| 818 return getMappedInstanceName(proposal); |
| 819 } |
| 820 |
| 812 String getNameOfMember(Element member) => getNameX(member); | 821 String getNameOfMember(Element member) => getNameX(member); |
| 813 | 822 |
| 814 String getNameOfGlobalField(VariableElement field) => getNameX(field); | 823 String getNameOfGlobalField(VariableElement field) => getNameX(field); |
| 815 | 824 |
| 816 /// Returns true if [element] is stored on current isolate ('$'). We intend | 825 /// Returns true if [element] is stored on current isolate ('$'). We intend |
| 817 /// to store only mutable static state in [currentIsolate], constants are | 826 /// to store only mutable static state in [currentIsolate], constants are |
| 818 /// stored in 'C', and functions, accessors, classes, etc. are stored in one | 827 /// stored in 'C', and functions, accessors, classes, etc. are stored in one |
| 819 /// of the other objects in [reservedGlobalObjectNames]. | 828 /// of the other objects in [reservedGlobalObjectNames]. |
| 820 bool isPropertyOfCurrentIsolate(Element element) { | 829 bool isPropertyOfCurrentIsolate(Element element) { |
| 821 // TODO(ahe): Make sure this method's documentation is always true and | 830 // TODO(ahe): Make sure this method's documentation is always true and |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 if (!first) { | 1396 if (!first) { |
| 1388 sb.write('_'); | 1397 sb.write('_'); |
| 1389 } | 1398 } |
| 1390 sb.write('_'); | 1399 sb.write('_'); |
| 1391 visit(parameter); | 1400 visit(parameter); |
| 1392 first = true; | 1401 first = true; |
| 1393 } | 1402 } |
| 1394 } | 1403 } |
| 1395 } | 1404 } |
| 1396 } | 1405 } |
| OLD | NEW |