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

Side by Side Diff: pkg/compiler/lib/src/js_backend/namer.dart

Issue 2927093002: Support user class in compile_from_dill_test (Closed)
Patch Set: Created 3 years, 6 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
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 library js_backend.namer; 5 library js_backend.namer;
6 6
7 import 'dart:collection' show HashMap; 7 import 'dart:collection' show HashMap;
8 8
9 import 'package:js_runtime/shared/embedded_names.dart' show JsGetName; 9 import 'package:js_runtime/shared/embedded_names.dart' show JsGetName;
10 10
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 // name part, we disambiguate the library name here. 1344 // name part, we disambiguate the library name here.
1345 String disambiguated = name; 1345 String disambiguated = name;
1346 for (int c = 0; libraryLongNames.containsValue(disambiguated); c++) { 1346 for (int c = 0; libraryLongNames.containsValue(disambiguated); c++) {
1347 disambiguated = "$name$c"; 1347 disambiguated = "$name$c";
1348 } 1348 }
1349 libraryLongNames[library] = disambiguated; 1349 libraryLongNames[library] = disambiguated;
1350 return disambiguated; 1350 return disambiguated;
1351 } 1351 }
1352 1352
1353 String suffixForGetInterceptor(Iterable<ClassEntity> classes) { 1353 String suffixForGetInterceptor(Iterable<ClassEntity> classes) {
1354 String abbreviate(ClassElement cls) { 1354 String abbreviate(ClassEntity cls) {
1355 if (cls == _commonElements.objectClass) return "o"; 1355 if (cls == _commonElements.objectClass) return "o";
1356 if (cls == _commonElements.jsStringClass) return "s"; 1356 if (cls == _commonElements.jsStringClass) return "s";
1357 if (cls == _commonElements.jsArrayClass) return "a"; 1357 if (cls == _commonElements.jsArrayClass) return "a";
1358 if (cls == _commonElements.jsDoubleClass) return "d"; 1358 if (cls == _commonElements.jsDoubleClass) return "d";
1359 if (cls == _commonElements.jsIntClass) return "i"; 1359 if (cls == _commonElements.jsIntClass) return "i";
1360 if (cls == _commonElements.jsNumberClass) return "n"; 1360 if (cls == _commonElements.jsNumberClass) return "n";
1361 if (cls == _commonElements.jsNullClass) return "u"; 1361 if (cls == _commonElements.jsNullClass) return "u";
1362 if (cls == _commonElements.jsBoolClass) return "b"; 1362 if (cls == _commonElements.jsBoolClass) return "b";
1363 if (cls == _commonElements.jsInterceptorClass) return "I"; 1363 if (cls == _commonElements.jsInterceptorClass) return "I";
1364 return cls.name; 1364 return cls.name;
1365 } 1365 }
1366 1366
1367 List<String> names = classes 1367 List<String> names = classes
1368 .where((cls) => !_nativeData.isNativeOrExtendsNative(cls)) 1368 .where((cls) => !_nativeData.isNativeOrExtendsNative(cls))
1369 .map(abbreviate) 1369 .map(abbreviate)
1370 .toList(); 1370 .toList();
1371 // There is one dispatch mechanism for all native classes. 1371 // There is one dispatch mechanism for all native classes.
1372 if (classes.any((cls) => _nativeData.isNativeOrExtendsNative(cls))) { 1372 if (classes.any((cls) => _nativeData.isNativeOrExtendsNative(cls))) {
1373 names.add("x"); 1373 names.add("x");
1374 } 1374 }
1375 // Sort the names of the classes after abbreviating them to ensure 1375 // Sort the names of the classes after abbreviating them to ensure
1376 // the suffix is stable and predictable for the suggested names. 1376 // the suffix is stable and predictable for the suggested names.
1377 names.sort(); 1377 names.sort();
1378 return names.join(); 1378 return names.join();
1379 } 1379 }
1380 1380
1381 /// Property name used for `getInterceptor` or one of its specializations. 1381 /// Property name used for `getInterceptor` or one of its specializations.
1382 jsAst.Name nameForGetInterceptor(Iterable<ClassEntity> classes) { 1382 jsAst.Name nameForGetInterceptor(Iterable<ClassEntity> classes) {
1383 MethodElement getInterceptor = _commonElements.getInterceptorMethod; 1383 FunctionEntity getInterceptor = _commonElements.getInterceptorMethod;
1384 if (classes.contains(_commonElements.jsInterceptorClass)) { 1384 if (classes.contains(_commonElements.jsInterceptorClass)) {
1385 // If the base Interceptor class is in the set of intercepted classes, we 1385 // If the base Interceptor class is in the set of intercepted classes, we
1386 // need to go through the generic getInterceptorMethod, since any subclass 1386 // need to go through the generic getInterceptorMethod, since any subclass
1387 // of the base Interceptor could match. 1387 // of the base Interceptor could match.
1388 // The unspecialized getInterceptor method can also be accessed through 1388 // The unspecialized getInterceptor method can also be accessed through
1389 // its element, so we treat this as a user-space global instead of an 1389 // its element, so we treat this as a user-space global instead of an
1390 // internal global. 1390 // internal global.
1391 return _disambiguateGlobalMember(getInterceptor); 1391 return _disambiguateGlobalMember(getInterceptor);
1392 } 1392 }
1393 String suffix = suffixForGetInterceptor(classes); 1393 String suffix = suffixForGetInterceptor(classes);
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 void addSuggestion(String original, String suggestion) { 2232 void addSuggestion(String original, String suggestion) {
2233 assert(!_suggestedNames.containsKey(original)); 2233 assert(!_suggestedNames.containsKey(original));
2234 _suggestedNames[original] = suggestion; 2234 _suggestedNames[original] = suggestion;
2235 } 2235 }
2236 2236
2237 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); 2237 bool hasSuggestion(String original) => _suggestedNames.containsKey(original);
2238 bool isSuggestion(String candidate) { 2238 bool isSuggestion(String candidate) {
2239 return _suggestedNames.containsValue(candidate); 2239 return _suggestedNames.containsValue(candidate);
2240 } 2240 }
2241 } 2241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698