Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/namer.dart

Issue 255843005: Avoid generating VariableUse nodes with non-identifier names (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 888
889 String getStaticClosureName(Element element) { 889 String getStaticClosureName(Element element) {
890 assert(Elements.isStaticOrTopLevelFunction(element)); 890 assert(Elements.isStaticOrTopLevelFunction(element));
891 return getMappedGlobalName("${getNameX(element)}\$closure"); 891 return getMappedGlobalName("${getNameX(element)}\$closure");
892 } 892 }
893 893
894 String isolateAccess(Element element) { 894 String isolateAccess(Element element) {
895 return "${globalObjectFor(element)}.${getNameX(element)}"; 895 return "${globalObjectFor(element)}.${getNameX(element)}";
896 } 896 }
897 897
898 String isolateLazyInitializerAccess(Element element) { 898 jsAst.Expression isolateLazyInitializerAccess(Element element) {
899 return "${globalObjectFor(element)}.${getLazyInitializerName(element)}"; 899 return js('#.#',
900 [globalObjectFor(element), getLazyInitializerName(element)]);
900 } 901 }
901 902
902 String isolateStaticClosureAccess(Element element) { 903 jsAst.Expression isolateStaticClosureAccess(Element element) {
903 return "${globalObjectFor(element)}.${getStaticClosureName(element)}()"; 904 return js('#.#()',
905 [globalObjectFor(element), getStaticClosureName(element)]);
906 }
907
908 // This name is used as part of the name of a TypeConstant
909 String uniqueNameForTypeConstantElement(Element element) {
910 // TODO(sra): If we replace the period with an identifier character,
911 // TypeConstants will have better names in unminified code.
912 return "${globalObjectFor(element)}.${getNameX(element)}";
904 } 913 }
905 914
906 String globalObjectForConstant(Constant constant) => 'C'; 915 String globalObjectForConstant(Constant constant) => 'C';
907 916
908 String operatorIsPrefix() => r'$is'; 917 String operatorIsPrefix() => r'$is';
909 918
910 String operatorAsPrefix() => r'$as'; 919 String operatorAsPrefix() => r'$as';
911 920
912 String operatorSignature() => r'$signature'; 921 String operatorSignature() => r'$signature';
913 922
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 for (int i = 0; i < constant.fields.length; i++) { 1180 for (int i = 0; i < constant.fields.length; i++) {
1172 _visit(constant.fields[i]); 1181 _visit(constant.fields[i]);
1173 if (failed) return; 1182 if (failed) return;
1174 } 1183 }
1175 } 1184 }
1176 1185
1177 visitType(TypeConstant constant) { 1186 visitType(TypeConstant constant) {
1178 addRoot('Type'); 1187 addRoot('Type');
1179 DartType type = constant.representedType; 1188 DartType type = constant.representedType;
1180 JavaScriptBackend backend = compiler.backend; 1189 JavaScriptBackend backend = compiler.backend;
1181 String name = backend.rti.getRawTypeRepresentation(type); 1190 String name = backend.rti.getTypeRepresentationForTypeConstant(type);
1182 addIdentifier(name); 1191 addIdentifier(name);
1183 } 1192 }
1184 1193
1185 visitInterceptor(InterceptorConstant constant) { 1194 visitInterceptor(InterceptorConstant constant) {
1186 addRoot(constant.dispatchedType.element.name); 1195 addRoot(constant.dispatchedType.element.name);
1187 add('methods'); 1196 add('methods');
1188 } 1197 }
1189 1198
1190 visitDummy(DummyConstant constant) { 1199 visitDummy(DummyConstant constant) {
1191 add('dummy_receiver'); 1200 add('dummy_receiver');
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 int hash = _hashString(3, constant.type.element.name); 1260 int hash = _hashString(3, constant.type.element.name);
1252 for (int i = 0; i < constant.fields.length; i++) { 1261 for (int i = 0; i < constant.fields.length; i++) {
1253 hash = _combine(hash, _visit(constant.fields[i])); 1262 hash = _combine(hash, _visit(constant.fields[i]));
1254 } 1263 }
1255 return hash; 1264 return hash;
1256 } 1265 }
1257 1266
1258 int visitType(TypeConstant constant) { 1267 int visitType(TypeConstant constant) {
1259 DartType type = constant.representedType; 1268 DartType type = constant.representedType;
1260 JavaScriptBackend backend = compiler.backend; 1269 JavaScriptBackend backend = compiler.backend;
1261 String name = backend.rti.getRawTypeRepresentation(type); 1270 String name = backend.rti.getTypeRepresentationForTypeConstant(type);
1262 return _hashString(4, name); 1271 return _hashString(4, name);
1263 } 1272 }
1264 1273
1265 visitInterceptor(InterceptorConstant constant) { 1274 visitInterceptor(InterceptorConstant constant) {
1266 String typeName = constant.dispatchedType.element.name; 1275 String typeName = constant.dispatchedType.element.name;
1267 return _hashString(5, typeName); 1276 return _hashString(5, typeName);
1268 } 1277 }
1269 1278
1270 visitDummy(DummyConstant constant) { 1279 visitDummy(DummyConstant constant) {
1271 compiler.internalError(NO_LOCATION_SPANNABLE, 1280 compiler.internalError(NO_LOCATION_SPANNABLE,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 if (!first) { 1405 if (!first) {
1397 sb.write('_'); 1406 sb.write('_');
1398 } 1407 }
1399 sb.write('_'); 1408 sb.write('_');
1400 visit(link.head); 1409 visit(link.head);
1401 first = true; 1410 first = true;
1402 } 1411 }
1403 } 1412 }
1404 } 1413 }
1405 } 1414 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698