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 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 return name; | 944 return name; |
945 } | 945 } |
946 | 946 |
947 String substitutionName(Element element) { | 947 String substitutionName(Element element) { |
948 // TODO(ahe): Creating a string here is unfortunate. It is slow (due to | 948 // TODO(ahe): Creating a string here is unfortunate. It is slow (due to |
949 // string concatenation in the implementation), and may prevent | 949 // string concatenation in the implementation), and may prevent |
950 // segmentation of '$'. | 950 // segmentation of '$'. |
951 return '${operatorAsPrefix()}${getNameForRti(element)}'; | 951 return '${operatorAsPrefix()}${getNameForRti(element)}'; |
952 } | 952 } |
953 | 953 |
954 String signatureLocation(FunctionType type) { | |
955 ClassElement classElement = Types.getClassContext(type); | |
956 return (classElement != null) | |
957 ? '${isolateAccess(classElement)}' | |
958 : currentIsolate; | |
959 } | |
960 | |
961 String signatureName(FunctionType type) { | |
962 String signature = '${operatorSignature()}_${getFunctionTypeName(type)}'; | |
963 return '${signatureLocation(type)}.$signature'; | |
964 } | |
965 | |
966 String safeName(String name) => _safeName(name, jsReserved); | 954 String safeName(String name) => _safeName(name, jsReserved); |
967 String safeVariableName(String name) => _safeName(name, jsVariableReserved); | 955 String safeVariableName(String name) => _safeName(name, jsVariableReserved); |
968 | 956 |
969 String operatorNameToIdentifier(String name) { | 957 String operatorNameToIdentifier(String name) { |
970 if (name == null) return null; | 958 if (name == null) return null; |
971 if (name == '==') { | 959 if (name == '==') { |
972 return r'$eq'; | 960 return r'$eq'; |
973 } else if (name == '~') { | 961 } else if (name == '~') { |
974 return r'$not'; | 962 return r'$not'; |
975 } else if (name == '[]') { | 963 } else if (name == '[]') { |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 if (!first) { | 1379 if (!first) { |
1392 sb.write('_'); | 1380 sb.write('_'); |
1393 } | 1381 } |
1394 sb.write('_'); | 1382 sb.write('_'); |
1395 visit(link.head); | 1383 visit(link.head); |
1396 first = true; | 1384 first = true; |
1397 } | 1385 } |
1398 } | 1386 } |
1399 } | 1387 } |
1400 } | 1388 } |
OLD | NEW |