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

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

Issue 2996723002: Support typedef type literals (Closed)
Patch Set: Cleanup Created 3 years, 4 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;
1940 if (type is InterfaceType) {
1941 name = type.element.name;
1942 } else if (type is TypedefType) {
1943 name = type.element.name;
1944 }
1940 if (name == null) { 1945 if (name == null) {
1941 // e.g. DartType 'dynamic' has no element. 1946 // e.g. DartType 'dynamic' has no element.
1942 name = rtiEncoder.getTypeRepresentationForTypeConstant(type); 1947 name = rtiEncoder.getTypeRepresentationForTypeConstant(type);
1943 } 1948 }
1944 addIdentifier(name); 1949 addIdentifier(name);
1945 add(getHashTag(constant, 3)); 1950 add(getHashTag(constant, 3));
1946 } 1951 }
1947 1952
1948 @override 1953 @override
1949 void visitInterceptor(InterceptorConstantValue constant, [_]) { 1954 void visitInterceptor(InterceptorConstantValue constant, [_]) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 int hash = _hashString(3, constant.type.element.name); 2057 int hash = _hashString(3, constant.type.element.name);
2053 codegenWorldBuilder.forEachInstanceField(constant.type.element, 2058 codegenWorldBuilder.forEachInstanceField(constant.type.element,
2054 (_, FieldEntity field) { 2059 (_, FieldEntity field) {
2055 hash = _combine(hash, _visit(constant.fields[field])); 2060 hash = _combine(hash, _visit(constant.fields[field]));
2056 }); 2061 });
2057 return hash; 2062 return hash;
2058 } 2063 }
2059 2064
2060 @override 2065 @override
2061 int visitType(TypeConstantValue constant, [_]) { 2066 int visitType(TypeConstantValue constant, [_]) {
2062 ResolutionDartType type = constant.representedType; 2067 DartType type = constant.representedType;
2063 // This name includes the library name and type parameters. 2068 // This name includes the library name and type parameters.
2064 String name = rtiEncoder.getTypeRepresentationForTypeConstant(type); 2069 String name = rtiEncoder.getTypeRepresentationForTypeConstant(type);
2065 return _hashString(4, name); 2070 return _hashString(4, name);
2066 } 2071 }
2067 2072
2068 @override 2073 @override
2069 int visitInterceptor(InterceptorConstantValue constant, [_]) { 2074 int visitInterceptor(InterceptorConstantValue constant, [_]) {
2070 String typeName = constant.cls.name; 2075 String typeName = constant.cls.name;
2071 return _hashString(5, typeName); 2076 return _hashString(5, typeName);
2072 } 2077 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2239 void addSuggestion(String original, String suggestion) { 2244 void addSuggestion(String original, String suggestion) {
2240 assert(!_suggestedNames.containsKey(original)); 2245 assert(!_suggestedNames.containsKey(original));
2241 _suggestedNames[original] = suggestion; 2246 _suggestedNames[original] = suggestion;
2242 } 2247 }
2243 2248
2244 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); 2249 bool hasSuggestion(String original) => _suggestedNames.containsKey(original);
2245 bool isSuggestion(String candidate) { 2250 bool isSuggestion(String candidate) {
2246 return _suggestedNames.containsValue(candidate); 2251 return _suggestedNames.containsValue(candidate);
2247 } 2252 }
2248 } 2253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698