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

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

Issue 2976973002: dart2ks-kernel: constant types and constant lists with type parameters (Closed)
Patch Set: Created 3 years, 5 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 1917 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 if (failed) return; 1928 if (failed) return;
1929 _visit(constant.fields[field]); 1929 _visit(constant.fields[field]);
1930 }); 1930 });
1931 } 1931 }
1932 1932
1933 @override 1933 @override
1934 void visitType(TypeConstantValue constant, [_]) { 1934 void visitType(TypeConstantValue constant, [_]) {
1935 // Generates something like 'Type_String_k8F', using the simple name of the 1935 // Generates something like 'Type_String_k8F', using the simple name of the
1936 // type and a hash to disambiguate the same name in different libraries. 1936 // type and a hash to disambiguate the same name in different libraries.
1937 addRoot('Type'); 1937 addRoot('Type');
1938 ResolutionDartType type = constant.representedType; 1938 DartType type = constant.representedType;
1939 String name = type.element?.name; 1939 String name = type.element?.name;
1940 if (name == null) { 1940 if (name == null) {
1941 // e.g. DartType 'dynamic' has no element. 1941 // e.g. DartType 'dynamic' has no element.
1942 name = rtiEncoder.getTypeRepresentationForTypeConstant(type); 1942 name = rtiEncoder.getTypeRepresentationForTypeConstant(type);
1943 } 1943 }
1944 addIdentifier(name); 1944 addIdentifier(name);
1945 add(getHashTag(constant, 3)); 1945 add(getHashTag(constant, 3));
1946 } 1946 }
1947 1947
1948 @override 1948 @override
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 int hash = _hashString(3, constant.type.element.name); 2052 int hash = _hashString(3, constant.type.element.name);
2053 codegenWorldBuilder.forEachInstanceField(constant.type.element, 2053 codegenWorldBuilder.forEachInstanceField(constant.type.element,
2054 (_, FieldEntity field) { 2054 (_, FieldEntity field) {
2055 hash = _combine(hash, _visit(constant.fields[field])); 2055 hash = _combine(hash, _visit(constant.fields[field]));
2056 }); 2056 });
2057 return hash; 2057 return hash;
2058 } 2058 }
2059 2059
2060 @override 2060 @override
2061 int visitType(TypeConstantValue constant, [_]) { 2061 int visitType(TypeConstantValue constant, [_]) {
2062 ResolutionDartType type = constant.representedType; 2062 DartType type = constant.representedType;
2063 // This name includes the library name and type parameters. 2063 // This name includes the library name and type parameters.
2064 String name = rtiEncoder.getTypeRepresentationForTypeConstant(type); 2064 String name = rtiEncoder.getTypeRepresentationForTypeConstant(type);
2065 return _hashString(4, name); 2065 return _hashString(4, name);
2066 } 2066 }
2067 2067
2068 @override 2068 @override
2069 int visitInterceptor(InterceptorConstantValue constant, [_]) { 2069 int visitInterceptor(InterceptorConstantValue constant, [_]) {
2070 String typeName = constant.cls.name; 2070 String typeName = constant.cls.name;
2071 return _hashString(5, typeName); 2071 return _hashString(5, typeName);
2072 } 2072 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2239 void addSuggestion(String original, String suggestion) { 2239 void addSuggestion(String original, String suggestion) {
2240 assert(!_suggestedNames.containsKey(original)); 2240 assert(!_suggestedNames.containsKey(original));
2241 _suggestedNames[original] = suggestion; 2241 _suggestedNames[original] = suggestion;
2242 } 2242 }
2243 2243
2244 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); 2244 bool hasSuggestion(String original) => _suggestedNames.containsKey(original);
2245 bool isSuggestion(String candidate) { 2245 bool isSuggestion(String candidate) {
2246 return _suggestedNames.containsValue(candidate); 2246 return _suggestedNames.containsValue(candidate);
2247 } 2247 }
2248 } 2248 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698