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

Unified Diff: pkg/compiler/lib/src/js_backend/lookup_map_analysis.dart

Issue 2620023002: Use elements/types in constants/values (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/js_backend/lookup_map_analysis.dart
diff --git a/pkg/compiler/lib/src/js_backend/lookup_map_analysis.dart b/pkg/compiler/lib/src/js_backend/lookup_map_analysis.dart
index d7bf72e664bfc76d68c906def0d294c50f422dcc..eb9aa3ccea292b929168877db94e35edb60cf059 100644
--- a/pkg/compiler/lib/src/js_backend/lookup_map_analysis.dart
+++ b/pkg/compiler/lib/src/js_backend/lookup_map_analysis.dart
@@ -201,10 +201,13 @@ class LookupMapAnalysis {
}
/// Whether [constant] is an instance of a `LookupMap`.
- bool isLookupMap(ConstantValue constant) =>
- _isEnabled &&
- constant is ConstructedConstantValue &&
- constant.type.asRaw().element.isSubclassOf(typeLookupMapClass);
+ bool isLookupMap(ConstantValue constant) {
+ if (_isEnabled && constant is ConstructedConstantValue) {
+ ResolutionInterfaceType type = constant.type;
+ return type.element.isSubclassOf(typeLookupMapClass);
+ }
+ return false;
+ }
/// Registers an instance of a lookup-map with the analysis.
void registerLookupMapReference(ConstantValue lookupMap) {
@@ -246,13 +249,12 @@ class LookupMapAnalysis {
/// If [key] is a type, cache it in [_typeConstants].
_registerTypeKey(ConstantValue key) {
- if (key is TypeConstantValue) {
- ClassElement cls = key.representedType.element;
- if (cls == null || !cls.isClass) {
- // TODO(sigmund): report error?
- return;
- }
- _typeConstants[cls] = key;
+ if (key is TypeConstantValue &&
+ key.representedType is ResolutionInterfaceType) {
+ ResolutionInterfaceType type = key.representedType;
+ _typeConstants[type.element] = key;
+ } else {
+ // TODO(sigmund): report error?
}
}
@@ -431,7 +433,7 @@ class _LookupMapInfo {
/// Restores [original] to contain all of the entries marked as possibly used.
void _prepareForEmission() {
ListConstantValue originalEntries = original.fields[analysis.entriesField];
- ResolutionDartType listType = originalEntries.type;
+ ResolutionInterfaceType listType = originalEntries.type;
List<ConstantValue> keyValuePairs = <ConstantValue>[];
usedEntries.forEach((key, value) {
keyValuePairs.add(key);

Powered by Google App Engine
This is Rietveld 408576698