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

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

Issue 2072223002: Enforce use of the forEachInstanceField ordering for constructed constants. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Remove tab Created 4 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 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 * Names are generated through three stages: 10 * Names are generated through three stages:
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 } else { 1728 } else {
1729 // Using some bits from the keys hash tag groups the names Maps with the 1729 // Using some bits from the keys hash tag groups the names Maps with the
1730 // same structure. 1730 // same structure.
1731 add(getHashTag(constant.keyList, 2) + getHashTag(constant, 3)); 1731 add(getHashTag(constant.keyList, 2) + getHashTag(constant, 3));
1732 } 1732 }
1733 } 1733 }
1734 1734
1735 @override 1735 @override
1736 void visitConstructed(ConstructedConstantValue constant, [_]) { 1736 void visitConstructed(ConstructedConstantValue constant, [_]) {
1737 addRoot(constant.type.element.name); 1737 addRoot(constant.type.element.name);
1738 for (ConstantValue value in constant.fields.values) { 1738 constant.type.element.forEachInstanceField((_, FieldElement field) {
1739 _visit(value);
1740 if (failed) return; 1739 if (failed) return;
1741 } 1740 _visit(constant.fields[field]);
1741 }, includeSuperAndInjectedMembers: true);
1742 } 1742 }
1743 1743
1744 @override 1744 @override
1745 void visitType(TypeConstantValue constant, [_]) { 1745 void visitType(TypeConstantValue constant, [_]) {
1746 // Generates something like 'Type_String_k8F', using the simple name of the 1746 // Generates something like 'Type_String_k8F', using the simple name of the
1747 // type and a hash to disambiguate the same name in different libraries. 1747 // type and a hash to disambiguate the same name in different libraries.
1748 addRoot('Type'); 1748 addRoot('Type');
1749 DartType type = constant.representedType; 1749 DartType type = constant.representedType;
1750 String name = type.element?.name; 1750 String name = type.element?.name;
1751 if (name == null) { 1751 if (name == null) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 1855
1856 @override 1856 @override
1857 int visitMap(MapConstantValue constant, [_]) { 1857 int visitMap(MapConstantValue constant, [_]) {
1858 int hash = _hashList(constant.length, constant.keys); 1858 int hash = _hashList(constant.length, constant.keys);
1859 return _hashList(hash, constant.values); 1859 return _hashList(hash, constant.values);
1860 } 1860 }
1861 1861
1862 @override 1862 @override
1863 int visitConstructed(ConstructedConstantValue constant, [_]) { 1863 int visitConstructed(ConstructedConstantValue constant, [_]) {
1864 int hash = _hashString(3, constant.type.element.name); 1864 int hash = _hashString(3, constant.type.element.name);
1865 for (ConstantValue value in constant.fields.values) { 1865 constant.type.element.forEachInstanceField((_, FieldElement field) {
1866 hash = _combine(hash, _visit(value)); 1866 hash = _combine(hash, _visit(constant.fields[field]));
1867 } 1867 }, includeSuperAndInjectedMembers: true);
1868 return hash; 1868 return hash;
1869 } 1869 }
1870 1870
1871 @override 1871 @override
1872 int visitType(TypeConstantValue constant, [_]) { 1872 int visitType(TypeConstantValue constant, [_]) {
1873 DartType type = constant.representedType; 1873 DartType type = constant.representedType;
1874 JavaScriptBackend backend = compiler.backend; 1874 JavaScriptBackend backend = compiler.backend;
1875 // This name includes the library name and type parameters. 1875 // This name includes the library name and type parameters.
1876 String name = backend.rtiEncoder.getTypeRepresentationForTypeConstant(type); 1876 String name = backend.rtiEncoder.getTypeRepresentationForTypeConstant(type);
1877 return _hashString(4, name); 1877 return _hashString(4, name);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2054 void addSuggestion(String original, String suggestion) { 2054 void addSuggestion(String original, String suggestion) {
2055 assert(!_suggestedNames.containsKey(original)); 2055 assert(!_suggestedNames.containsKey(original));
2056 _suggestedNames[original] = suggestion; 2056 _suggestedNames[original] = suggestion;
2057 } 2057 }
2058 2058
2059 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); 2059 bool hasSuggestion(String original) => _suggestedNames.containsKey(original);
2060 bool isSuggestion(String candidate) { 2060 bool isSuggestion(String candidate) {
2061 return _suggestedNames.containsValue(candidate); 2061 return _suggestedNames.containsValue(candidate);
2062 } 2062 }
2063 } 2063 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/constant_system_javascript.dart ('k') | tests/language/const_constructor_super2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698