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

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

Issue 2680823002: Extract InterceptorData from JavaScriptBackend. (Closed)
Patch Set: Updated cf. comments Created 3 years, 10 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 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 return _disambiguateMember(element.memberName); 960 return _disambiguateMember(element.memberName);
961 } 961 }
962 962
963 bool _isShadowingSuperField(Element element) { 963 bool _isShadowingSuperField(Element element) {
964 return element.enclosingClass.hasFieldShadowedBy(element); 964 return element.enclosingClass.hasFieldShadowedBy(element);
965 } 965 }
966 966
967 /// True if [class_] is a non-native class that inherits from a native class. 967 /// True if [class_] is a non-native class that inherits from a native class.
968 bool _isUserClassExtendingNative(ClassElement class_) { 968 bool _isUserClassExtendingNative(ClassElement class_) {
969 return !backend.isNative(class_) && 969 return !backend.isNative(class_) &&
970 backend.isNativeOrExtendsNative(class_.superclass); 970 backend.nativeData.isNativeOrExtendsNative(class_.superclass);
971 } 971 }
972 972
973 /// Annotated name for the setter of [element]. 973 /// Annotated name for the setter of [element].
974 jsAst.Name setterForElement(MemberElement element) { 974 jsAst.Name setterForElement(MemberElement element) {
975 // We dynamically create setters from the field-name. The setter name must 975 // We dynamically create setters from the field-name. The setter name must
976 // therefore be derived from the instance field-name. 976 // therefore be derived from the instance field-name.
977 jsAst.Name name = _disambiguateMember(element.memberName); 977 jsAst.Name name = _disambiguateMember(element.memberName);
978 return deriveSetterName(name); 978 return deriveSetterName(name);
979 } 979 }
980 980
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 if (cls == helpers.jsDoubleClass) return "d"; 1351 if (cls == helpers.jsDoubleClass) return "d";
1352 if (cls == helpers.jsIntClass) return "i"; 1352 if (cls == helpers.jsIntClass) return "i";
1353 if (cls == helpers.jsNumberClass) return "n"; 1353 if (cls == helpers.jsNumberClass) return "n";
1354 if (cls == helpers.jsNullClass) return "u"; 1354 if (cls == helpers.jsNullClass) return "u";
1355 if (cls == helpers.jsBoolClass) return "b"; 1355 if (cls == helpers.jsBoolClass) return "b";
1356 if (cls == helpers.jsInterceptorClass) return "I"; 1356 if (cls == helpers.jsInterceptorClass) return "I";
1357 return cls.name; 1357 return cls.name;
1358 } 1358 }
1359 1359
1360 List<String> names = classes 1360 List<String> names = classes
1361 .where((cls) => !backend.isNativeOrExtendsNative(cls)) 1361 .where((cls) => !backend.nativeData.isNativeOrExtendsNative(cls))
1362 .map(abbreviate) 1362 .map(abbreviate)
1363 .toList(); 1363 .toList();
1364 // There is one dispatch mechanism for all native classes. 1364 // There is one dispatch mechanism for all native classes.
1365 if (classes.any((cls) => backend.isNativeOrExtendsNative(cls))) { 1365 if (classes.any((cls) => backend.nativeData.isNativeOrExtendsNative(cls))) {
1366 names.add("x"); 1366 names.add("x");
1367 } 1367 }
1368 // Sort the names of the classes after abbreviating them to ensure 1368 // Sort the names of the classes after abbreviating them to ensure
1369 // the suffix is stable and predictable for the suggested names. 1369 // the suffix is stable and predictable for the suggested names.
1370 names.sort(); 1370 names.sort();
1371 return names.join(); 1371 return names.join();
1372 } 1372 }
1373 1373
1374 /// Property name used for `getInterceptor` or one of its specializations. 1374 /// Property name used for `getInterceptor` or one of its specializations.
1375 jsAst.Name nameForGetInterceptor(Iterable<ClassEntity> classes) { 1375 jsAst.Name nameForGetInterceptor(Iterable<ClassEntity> classes) {
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
2192 void addSuggestion(String original, String suggestion) { 2192 void addSuggestion(String original, String suggestion) {
2193 assert(!_suggestedNames.containsKey(original)); 2193 assert(!_suggestedNames.containsKey(original));
2194 _suggestedNames[original] = suggestion; 2194 _suggestedNames[original] = suggestion;
2195 } 2195 }
2196 2196
2197 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); 2197 bool hasSuggestion(String original) => _suggestedNames.containsKey(original);
2198 bool isSuggestion(String candidate) { 2198 bool isSuggestion(String candidate) {
2199 return _suggestedNames.containsValue(candidate); 2199 return _suggestedNames.containsValue(candidate);
2200 } 2200 }
2201 } 2201 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/interceptor_data.dart ('k') | pkg/compiler/lib/src/js_backend/native_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698