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

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

Issue 2907373002: Use entities for globals in Namer. (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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/code_emitter_task.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 _rtiEncoder = value; 507 _rtiEncoder = value;
508 } 508 }
509 509
510 /// Used disambiguated names in the global namespace, issued by 510 /// Used disambiguated names in the global namespace, issued by
511 /// [_disambiguateGlobal], and [_disambiguateInternalGlobal]. 511 /// [_disambiguateGlobal], and [_disambiguateInternalGlobal].
512 /// 512 ///
513 /// Although global names are distributed across a number of global objects, 513 /// Although global names are distributed across a number of global objects,
514 /// (see [globalObjectFor]), we currently use a single namespace for all these 514 /// (see [globalObjectFor]), we currently use a single namespace for all these
515 /// names. 515 /// names.
516 final NamingScope globalScope = new NamingScope(); 516 final NamingScope globalScope = new NamingScope();
517 final Map<Element, jsAst.Name> userGlobals = 517 final Map<Entity, jsAst.Name> userGlobals = new HashMap<Entity, jsAst.Name>();
518 new HashMap<Element, jsAst.Name>();
519 final Map<String, jsAst.Name> internalGlobals = 518 final Map<String, jsAst.Name> internalGlobals =
520 new HashMap<String, jsAst.Name>(); 519 new HashMap<String, jsAst.Name>();
521 520
522 /// Used disambiguated names in the instance namespace, issued by 521 /// Used disambiguated names in the instance namespace, issued by
523 /// [_disambiguateMember], [_disambiguateInternalMember], 522 /// [_disambiguateMember], [_disambiguateInternalMember],
524 /// [_disambiguateOperator], and [reservePublicMemberName]. 523 /// [_disambiguateOperator], and [reservePublicMemberName].
525 final NamingScope instanceScope = new NamingScope(); 524 final NamingScope instanceScope = new NamingScope();
526 final Map<String, jsAst.Name> userInstanceMembers = 525 final Map<String, jsAst.Name> userInstanceMembers =
527 new HashMap<String, jsAst.Name>(); 526 new HashMap<String, jsAst.Name>();
528 final Map<Element, jsAst.Name> internalInstanceMembers = 527 final Map<Element, jsAst.Name> internalInstanceMembers =
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 jsAst.Name invocationMirrorInternalName(Selector selector) => 859 jsAst.Name invocationMirrorInternalName(Selector selector) =>
861 invocationName(selector); 860 invocationName(selector);
862 861
863 /** 862 /**
864 * Returns the disambiguated name for the given field, used for constructing 863 * Returns the disambiguated name for the given field, used for constructing
865 * the getter and setter names. 864 * the getter and setter names.
866 */ 865 */
867 jsAst.Name fieldAccessorName(FieldElement element) { 866 jsAst.Name fieldAccessorName(FieldElement element) {
868 return element.isInstanceMember 867 return element.isInstanceMember
869 ? _disambiguateMember(element.memberName) 868 ? _disambiguateMember(element.memberName)
870 : _disambiguateGlobal(element); 869 : _disambiguateGlobalMember(element);
871 } 870 }
872 871
873 /** 872 /**
874 * Returns name of the JavaScript property used to store a static or instance 873 * Returns name of the JavaScript property used to store a static or instance
875 * field. 874 * field.
876 */ 875 */
877 jsAst.Name fieldPropertyName(FieldElement element) { 876 jsAst.Name fieldPropertyName(FieldElement element) {
878 return element.isInstanceMember 877 return element.isInstanceMember
879 ? instanceFieldPropertyName(element) 878 ? instanceFieldPropertyName(element)
880 : _disambiguateGlobal(element); 879 : _disambiguateGlobalMember(element);
881 } 880 }
882 881
882 jsAst.Name globalPropertyNameForMember(MemberEntity element) =>
883 _disambiguateGlobalMember(element);
884
885 jsAst.Name globalPropertyNameForClass(ClassEntity element) =>
886 _disambiguateGlobalType(element);
887
888 jsAst.Name globalPropertyNameForType(TypeDeclarationElement element) =>
889 _disambiguateGlobalType(element);
890
883 /** 891 /**
884 * Returns a JavaScript property name used to store [element] on one 892 * Returns a JavaScript property name used to store [element] on one
885 * of the global objects. 893 * of the global objects.
886 * 894 *
887 * Should be used together with [globalObjectFor], which denotes the object 895 * Should be used together with [globalObjectFor], which denotes the object
888 * on which the returned property name should be used. 896 * on which the returned property name should be used.
889 */ 897 */
890 jsAst.Name globalPropertyName(Element element) { 898 /*jsAst.Name _globalPropertyName(Element element) {
Siggi Cherem (dart-lang) 2017/05/30 21:37:20 delete?
Johnni Winther 2017/05/31 07:57:06 Done.
891 return _disambiguateGlobal(element); 899 return _disambiguateGlobal(element);
892 } 900 }*/
893 901
894 /** 902 /**
895 * Returns the JavaScript property name used to store an instance field. 903 * Returns the JavaScript property name used to store an instance field.
896 */ 904 */
897 jsAst.Name instanceFieldPropertyName(FieldElement element) { 905 jsAst.Name instanceFieldPropertyName(FieldElement element) {
898 ClassElement enclosingClass = element.enclosingClass; 906 ClassElement enclosingClass = element.enclosingClass;
899 907
900 if (_nativeData.hasFixedBackendName(element)) { 908 if (_nativeData.hasFixedBackendName(element)) {
901 return new StringBackedName(_nativeData.getFixedBackendName(element)); 909 return new StringBackedName(_nativeData.getFixedBackendName(element));
902 } 910 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 String keyBase = library.name; 1024 String keyBase = library.name;
1017 int counter = 0; 1025 int counter = 0;
1018 String key = keyBase; 1026 String key = keyBase;
1019 while (_libraryKeys.values.contains(key)) { 1027 while (_libraryKeys.values.contains(key)) {
1020 key = "$keyBase${counter++}"; 1028 key = "$keyBase${counter++}";
1021 } 1029 }
1022 return key; 1030 return key;
1023 }); 1031 });
1024 } 1032 }
1025 1033
1034 jsAst.Name _disambiguateGlobalMember(MemberEntity element) {
1035 return _disambiguateGlobal(element, _proposeNameForMember);
1036 }
1037
1038 jsAst.Name _disambiguateGlobalType(Entity element) {
1039 return _disambiguateGlobal(element, _proposeNameForType);
1040 }
1041
1026 /// Returns the disambiguated name for a top-level or static element. 1042 /// Returns the disambiguated name for a top-level or static element.
1027 /// 1043 ///
1028 /// The resulting name is unique within the global-member namespace. 1044 /// The resulting name is unique within the global-member namespace.
1029 jsAst.Name _disambiguateGlobal(Element element) { 1045 jsAst.Name _disambiguateGlobal(
1046 Entity element, String proposeName(Entity element)) {
1030 // TODO(asgerf): We can reuse more short names if we disambiguate with 1047 // TODO(asgerf): We can reuse more short names if we disambiguate with
1031 // a separate namespace for each of the global holder objects. 1048 // a separate namespace for each of the global holder objects.
1032 element = element.declaration; 1049 if (element is Element) {
Siggi Cherem (dart-lang) 2017/05/30 21:37:20 TODO to ensure we work with declarations all the t
Johnni Winther 2017/05/31 07:57:06 J/K-Elements are only declaration elements. Added
1050 Element e = element;
1051 element = e.declaration;
1052 }
1033 jsAst.Name newName = userGlobals[element]; 1053 jsAst.Name newName = userGlobals[element];
1034 if (newName == null) { 1054 if (newName == null) {
1035 String proposedName = _proposeNameForGlobal(element); 1055 String proposedName = proposeName(element);
1036 newName = getFreshName(globalScope, proposedName); 1056 newName = getFreshName(globalScope, proposedName);
1037 userGlobals[element] = newName; 1057 userGlobals[element] = newName;
1038 } 1058 }
1039 return _newReference(newName); 1059 return _newReference(newName);
1040 } 1060 }
1041 1061
1042 /// Returns the disambiguated name for an instance method or field 1062 /// Returns the disambiguated name for an instance method or field
1043 /// with [originalName] in [library]. 1063 /// with [originalName] in [library].
1044 /// 1064 ///
1045 /// [library] may be `null` if [originalName] is known to be public. 1065 /// [library] may be `null` if [originalName] is known to be public.
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 /// If [name] is not an annotated name, the result will not be an annotated 1260 /// If [name] is not an annotated name, the result will not be an annotated
1241 /// name either. 1261 /// name either.
1242 String _sanitizeForNatives(String name) { 1262 String _sanitizeForNatives(String name) {
1243 if (!name.contains(r'$')) { 1263 if (!name.contains(r'$')) {
1244 // Prepend $$. The result must not coincide with an annotated name. 1264 // Prepend $$. The result must not coincide with an annotated name.
1245 name = '\$\$$name'; 1265 name = '\$\$$name';
1246 } 1266 }
1247 return name; 1267 return name;
1248 } 1268 }
1249 1269
1250 /** 1270 /// Returns a proposed name for the given typedef or class [element].
1251 * Returns a proposed name for the given top-level or static element. 1271 /// The returned id is guaranteed to be a valid JavaScript identifier.
1252 * The returned id is guaranteed to be a valid JavaScript identifier. 1272 String _proposeNameForType(Entity element) {
1253 */ 1273 return element.name.replaceAll('+', '_');
1254 String _proposeNameForGlobal(Element element) { 1274 }
1255 assert(!element.isInstanceMember); 1275
1276 /// Returns a proposed name for the given top-level or static member
1277 /// [element]. The returned id is guaranteed to be a valid JavaScript
1278 /// identifier.
1279 String _proposeNameForMember(MemberEntity element) {
1280 if (element.isConstructor) {
1281 return _proposeNameForConstructor(element);
1282 } else if (element.enclosingClass != null) {
1283 ClassEntity enclosingClass = element.enclosingClass;
1284 return '${enclosingClass.name}_${element.name}';
1285 }
1286 return element.name.replaceAll('+', '_');
1287 }
1288
1289 String _proposeNameForConstructor(ConstructorEntity element) {
1290 String className = element.enclosingClass.name;
1256 if (element.isGenerativeConstructor) { 1291 if (element.isGenerativeConstructor) {
1257 return '${element.enclosingClass.name}\$${element.name}'; 1292 return '${className}\$${element.name}';
1258 } 1293 } else {
1259 if (element.isFactoryConstructor) {
1260 // TODO(johnniwinther): Change factory name encoding as to not include 1294 // TODO(johnniwinther): Change factory name encoding as to not include
1261 // the class-name twice. 1295 // the class-name twice.
1262 String className = element.enclosingClass.name; 1296 String constructorName;
1263 return '${className}_${Elements.reconstructConstructorName(element)}'; 1297 if (element.name == '') {
1298 constructorName = className;
1299 } else {
1300 constructorName = '${className}\$${element.name}';
1301 }
1302 return '${className}_${constructorName}';
1264 } 1303 }
1265 if (Elements.isStaticOrTopLevel(element)) {
1266 if (element.isClassMember) {
1267 ClassElement enclosingClass = element.enclosingClass;
1268 return '${enclosingClass.name}_${element.name}';
1269 }
1270 return element.name.replaceAll('+', '_');
1271 }
1272 if (element.isLibrary) {
1273 LibraryElement library = element;
1274 return _proposeNameForLibrary(library);
1275 }
1276 return element.name;
1277 } 1304 }
1278 1305
1279 /** 1306 /**
1280 * Returns a proposed name for the given [LibraryElement]. 1307 * Returns a proposed name for the given [LibraryElement].
1281 * The returned id is guaranteed to be a valid JavaScript identifier. 1308 * The returned id is guaranteed to be a valid JavaScript identifier.
1282 */ 1309 */
1283 // TODO(sra): Pre-process libraries to assign [libraryLongNames] in a way that 1310 // TODO(sra): Pre-process libraries to assign [libraryLongNames] in a way that
1284 // is independent of the order of calls to namer. 1311 // is independent of the order of calls to namer.
1285 String _proposeNameForLibrary(LibraryEntity library) { 1312 String _proposeNameForLibrary(LibraryEntity library) {
1286 String name = libraryLongNames[library]; 1313 String name = libraryLongNames[library];
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 /// Property name used for `getInterceptor` or one of its specializations. 1376 /// Property name used for `getInterceptor` or one of its specializations.
1350 jsAst.Name nameForGetInterceptor(Iterable<ClassEntity> classes) { 1377 jsAst.Name nameForGetInterceptor(Iterable<ClassEntity> classes) {
1351 MethodElement getInterceptor = _commonElements.getInterceptorMethod; 1378 MethodElement getInterceptor = _commonElements.getInterceptorMethod;
1352 if (classes.contains(_commonElements.jsInterceptorClass)) { 1379 if (classes.contains(_commonElements.jsInterceptorClass)) {
1353 // If the base Interceptor class is in the set of intercepted classes, we 1380 // If the base Interceptor class is in the set of intercepted classes, we
1354 // need to go through the generic getInterceptorMethod, since any subclass 1381 // need to go through the generic getInterceptorMethod, since any subclass
1355 // of the base Interceptor could match. 1382 // of the base Interceptor could match.
1356 // The unspecialized getInterceptor method can also be accessed through 1383 // The unspecialized getInterceptor method can also be accessed through
1357 // its element, so we treat this as a user-space global instead of an 1384 // its element, so we treat this as a user-space global instead of an
1358 // internal global. 1385 // internal global.
1359 return _disambiguateGlobal(getInterceptor); 1386 return _disambiguateGlobalMember(getInterceptor);
1360 } 1387 }
1361 String suffix = suffixForGetInterceptor(classes); 1388 String suffix = suffixForGetInterceptor(classes);
1362 return _disambiguateInternalGlobal("${getInterceptor.name}\$$suffix"); 1389 return _disambiguateInternalGlobal("${getInterceptor.name}\$$suffix");
1363 } 1390 }
1364 1391
1365 /// Property name used for the one-shot interceptor method for the given 1392 /// Property name used for the one-shot interceptor method for the given
1366 /// [selector] and return-type specialization. 1393 /// [selector] and return-type specialization.
1367 jsAst.Name nameForGetOneShotInterceptor( 1394 jsAst.Name nameForGetOneShotInterceptor(
1368 Selector selector, Iterable<ClassEntity> classes) { 1395 Selector selector, Iterable<ClassEntity> classes) {
1369 // The one-shot name is a global name derived from the invocation name. To 1396 // The one-shot name is a global name derived from the invocation name. To
(...skipping 30 matching lines...) Expand all
1400 // 1427 //
1401 // - If given a class, this must coincide with the class name, which 1428 // - If given a class, this must coincide with the class name, which
1402 // is also the GLOBAL property name of its constructor. 1429 // is also the GLOBAL property name of its constructor.
1403 // 1430 //
1404 // - The result is used to derive `$isX` and `$asX` names, which are used 1431 // - The result is used to derive `$isX` and `$asX` names, which are used
1405 // as INSTANCE property names. 1432 // as INSTANCE property names.
1406 // 1433 //
1407 // To prevent clashes in both namespaces at once, we disambiguate the name 1434 // To prevent clashes in both namespaces at once, we disambiguate the name
1408 // as a global here, and in [_sanitizeForAnnotations] we ensure that 1435 // as a global here, and in [_sanitizeForAnnotations] we ensure that
1409 // ordinary instance members cannot start with `$is` or `$as`. 1436 // ordinary instance members cannot start with `$is` or `$as`.
1410 return _disambiguateGlobal(element); 1437 return _disambiguateGlobalType(element);
1411 } 1438 }
1412 1439
1413 /// Returns the disambiguated name of [class_]. 1440 /// Returns the disambiguated name of [class_].
1414 /// 1441 ///
1415 /// This is both the *runtime type* of the class (see [runtimeTypeName]) 1442 /// This is both the *runtime type* of the class (see [runtimeTypeName])
1416 /// and a global property name in which to store its JS constructor. 1443 /// and a global property name in which to store its JS constructor.
1417 jsAst.Name className(ClassElement class_) => _disambiguateGlobal(class_); 1444 jsAst.Name className(ClassElement class_) => _disambiguateGlobalType(class_);
1418 1445
1419 /// Property name on which [member] can be accessed directly, 1446 /// Property name on which [member] can be accessed directly,
1420 /// without clashing with another JS property name. 1447 /// without clashing with another JS property name.
1421 /// 1448 ///
1422 /// This is used for implementing super-calls, where ordinary dispatch 1449 /// This is used for implementing super-calls, where ordinary dispatch
1423 /// semantics must be circumvented. For example: 1450 /// semantics must be circumvented. For example:
1424 /// 1451 ///
1425 /// class A { foo() } 1452 /// class A { foo() }
1426 /// class B extends A { 1453 /// class B extends A {
1427 /// foo() { super.foo() } 1454 /// foo() { super.foo() }
(...skipping 15 matching lines...) Expand all
1443 return "super\$${member.enclosingClass.name}\$$invocationName"; 1470 return "super\$${member.enclosingClass.name}\$$invocationName";
1444 }); 1471 });
1445 } 1472 }
1446 1473
1447 /// Property name in which to store the given static or instance [method]. 1474 /// Property name in which to store the given static or instance [method].
1448 /// For instance methods, this includes the suffix encoding arity and named 1475 /// For instance methods, this includes the suffix encoding arity and named
1449 /// parameters. 1476 /// parameters.
1450 /// 1477 ///
1451 /// The name is not necessarily unique to [method], since a static method 1478 /// The name is not necessarily unique to [method], since a static method
1452 /// may share its name with an instance method. 1479 /// may share its name with an instance method.
1453 jsAst.Name methodPropertyName(Element method) { 1480 jsAst.Name methodPropertyName(MethodElement method) {
1454 return method.isInstanceMember 1481 return method.isInstanceMember
1455 ? instanceMethodName(method) 1482 ? instanceMethodName(method)
1456 : globalPropertyName(method); 1483 : globalPropertyNameForMember(method);
1457 } 1484 }
1458 1485
1459 /// Returns true if [element] is stored in the static state holder 1486 /// Returns true if [element] is stored in the static state holder
1460 /// ([staticStateHolder]). We intend to store only mutable static state 1487 /// ([staticStateHolder]). We intend to store only mutable static state
1461 /// there, whereas constants are stored in 'C'. Functions, accessors, 1488 /// there, whereas constants are stored in 'C'. Functions, accessors,
1462 /// classes, etc. are stored in one of the other objects in 1489 /// classes, etc. are stored in one of the other objects in
1463 /// [reservedGlobalObjectNames]. 1490 /// [reservedGlobalObjectNames].
1464 bool _isPropertyOfStaticStateHolder(Element element) { 1491 bool _isPropertyOfStaticStateHolder(MemberEntity element) {
1465 // TODO(ahe): Make sure this method's documentation is always true and 1492 // TODO(ahe): Make sure this method's documentation is always true and
1466 // remove the word "intend". 1493 // remove the word "intend".
1467 return 1494 if (element is MemberElement) {
1468 // TODO(ahe): Re-write these tests to be positive (so it only returns 1495 // TODO(johnniwinther): Clean up this method to have a single semantics on
1469 // true for static/top-level mutable fields). Right now, a number of 1496 // entities.
1470 // other elements, such as bound closures also live in 1497 return
1471 // [staticStateHolder]. 1498 // TODO(ahe): Re-write these tests to be positive (so it only returns
1472 !element.isAccessor && 1499 // true for static/top-level mutable fields). Right now, a number of
1473 !element.isClass && 1500 // other elements, such as bound closures also live in
1474 !element.isTypedef && 1501 // [staticStateHolder].
1475 !element.isConstructor && 1502 !element.isAccessor &&
1476 !element.isFunction && 1503 !element.isClass &&
1477 !element.isLibrary; 1504 !element.isTypedef &&
1505 !element.isConstructor &&
1506 !element.isFunction &&
1507 !element.isLibrary;
1508 }
1509 return element.isField;
1478 } 1510 }
1479 1511
1480 /// Returns [staticStateHolder] or one of [reservedGlobalObjectNames]. 1512 /// Returns [staticStateHolder] or one of [reservedGlobalObjectNames].
1481 // TODO(johnniwinther): Verify that the implementation can be changed to 1513 // TODO(johnniwinther): Verify that the implementation can be changed to
1482 // `globalObjectForLibrary(element.library)`. 1514 // `globalObjectForLibrary(element.library)`.
1483 String globalObjectForMethod(MethodElement element) => 1515 String globalObjectForMethod(MethodElement element) =>
1484 globalObjectFor(element); 1516 globalObjectForMember(element);
1485 1517
1486 /// Returns [staticStateHolder] or one of [reservedGlobalObjectNames]. 1518 /// Returns [staticStateHolder] or one of [reservedGlobalObjectNames].
1487 String globalObjectFor(Element element) { 1519 String globalObjectForMember(MemberEntity element) {
1488 if (_isPropertyOfStaticStateHolder(element)) return staticStateHolder; 1520 if (_isPropertyOfStaticStateHolder(element)) return staticStateHolder;
1489 return globalObjectForLibrary(element.library); 1521 return globalObjectForLibrary(element.library);
1490 } 1522 }
1491 1523
1524 String globalObjectForClass(ClassEntity element) {
1525 return globalObjectForLibrary(element.library);
1526 }
1527
1528 String globalObjectForType(Entity element) {
1529 if (element is TypedefElement) {
1530 return globalObjectForLibrary(element.library);
1531 }
1532 return globalObjectForClass(element);
1533 }
1534
1492 /// Returns the [reservedGlobalObjectNames] for [library]. 1535 /// Returns the [reservedGlobalObjectNames] for [library].
1493 String globalObjectForLibrary(LibraryElement library) { 1536 String globalObjectForLibrary(LibraryEntity library) {
1494 if (library == _commonElements.interceptorsLibrary) return 'J'; 1537 if (library == _commonElements.interceptorsLibrary) return 'J';
1495 if (library.isInternalLibrary) return 'H'; 1538 Uri uri = library.canonicalUri;
1496 if (library.isPlatformLibrary) { 1539 if (uri.scheme == 'dart') {
1497 if ('${library.canonicalUri}' == 'dart:html') return 'W'; 1540 if (uri.path == 'html') return 'W';
1541 if (uri.path.startsWith('_')) return 'H';
1498 return 'P'; 1542 return 'P';
1499 } 1543 }
1500 return userGlobalObjects[library.name.hashCode % userGlobalObjects.length]; 1544 return userGlobalObjects[library.name.hashCode % userGlobalObjects.length];
1501 } 1545 }
1502 1546
1503 jsAst.Name deriveLazyInitializerName(jsAst.Name name) { 1547 jsAst.Name deriveLazyInitializerName(jsAst.Name name) {
1504 // These are not real dart getters, so do not use GetterName; 1548 // These are not real dart getters, so do not use GetterName;
1505 return new CompoundName([_literalLazyGetterPrefix, name]); 1549 return new CompoundName([_literalLazyGetterPrefix, name]);
1506 } 1550 }
1507 1551
1508 jsAst.Name lazyInitializerName(Element element) { 1552 jsAst.Name lazyInitializerName(FieldEntity element) {
1509 assert(Elements.isStaticOrTopLevelField(element)); 1553 assert(element.isTopLevel || element.isStatic);
1510 jsAst.Name name = _disambiguateGlobal(element); 1554 jsAst.Name name = _disambiguateGlobalMember(element);
1511 // These are not real dart getters, so do not use GetterName; 1555 // These are not real dart getters, so do not use GetterName;
1512 return deriveLazyInitializerName(name); 1556 return deriveLazyInitializerName(name);
1513 } 1557 }
1514 1558
1515 jsAst.Name staticClosureName(Element element) { 1559 jsAst.Name staticClosureName(Element element) {
1516 assert(Elements.isStaticOrTopLevelFunction(element)); 1560 assert(Elements.isStaticOrTopLevelFunction(element));
1517 String enclosing = 1561 String enclosing =
1518 element.enclosingClass == null ? "" : element.enclosingClass.name; 1562 element.enclosingClass == null ? "" : element.enclosingClass.name;
1519 String library = _proposeNameForLibrary(element.library); 1563 String library = _proposeNameForLibrary(element.library);
1520 return _disambiguateInternalGlobal( 1564 return _disambiguateInternalGlobal(
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 void addSuggestion(String original, String suggestion) { 2233 void addSuggestion(String original, String suggestion) {
2190 assert(!_suggestedNames.containsKey(original)); 2234 assert(!_suggestedNames.containsKey(original));
2191 _suggestedNames[original] = suggestion; 2235 _suggestedNames[original] = suggestion;
2192 } 2236 }
2193 2237
2194 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); 2238 bool hasSuggestion(String original) => _suggestedNames.containsKey(original);
2195 bool isSuggestion(String candidate) { 2239 bool isSuggestion(String candidate) {
2196 return _suggestedNames.containsValue(candidate); 2240 return _suggestedNames.containsValue(candidate);
2197 } 2241 }
2198 } 2242 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/code_emitter_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698