Add SetLiteralUse and start tracking them in resolution.
Change-Id: Ib5f36a2e24631007a4ddb9c9779abcc892a6f7c0
Reviewed-on: https://dart-review.googlesource.com/c/92166
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
diff --git a/pkg/compiler/lib/src/common/resolution.dart b/pkg/compiler/lib/src/common/resolution.dart
index ad9214f..e8ac328 100644
--- a/pkg/compiler/lib/src/common/resolution.dart
+++ b/pkg/compiler/lib/src/common/resolution.dart
@@ -14,6 +14,7 @@
Iterable<Feature> get features => const <Feature>[];
Iterable<MapLiteralUse> get mapLiterals => const <MapLiteralUse>[];
+ Iterable<SetLiteralUse> get setLiterals => const <SetLiteralUse>[];
Iterable<ListLiteralUse> get listLiterals => const <ListLiteralUse>[];
Iterable<String> get constSymbolNames => const <String>[];
Iterable<ConstantExpression> get constantLiterals =>
diff --git a/pkg/compiler/lib/src/resolution/registry.dart b/pkg/compiler/lib/src/resolution/registry.dart
index 18f373a..853beb3 100644
--- a/pkg/compiler/lib/src/resolution/registry.dart
+++ b/pkg/compiler/lib/src/resolution/registry.dart
@@ -17,6 +17,7 @@
final String name;
EnumSet<Feature> _features;
Setlet<MapLiteralUse> _mapLiterals;
+ Setlet<SetLiteralUse> _setLiterals;
Setlet<ListLiteralUse> _listLiterals;
Setlet<String> _constSymbolNames;
Setlet<ConstantExpression> _constantLiterals;
@@ -41,6 +42,16 @@
return _mapLiterals != null ? _mapLiterals : const <MapLiteralUse>[];
}
+ void registerSetLiteral(SetLiteralUse setLiteralUse) {
+ assert(setLiteralUse != null);
+ _setLiterals ??= new Setlet<SetLiteralUse>();
+ _setLiterals.add(setLiteralUse);
+ }
+
+ @override
+ Iterable<SetLiteralUse> get setLiterals =>
+ _setLiterals ?? const <SetLiteralUse>[];
+
void registerListLiteral(ListLiteralUse listLiteralUse) {
assert(listLiteralUse != null);
_listLiterals ??= new Setlet<ListLiteralUse>();
@@ -145,6 +156,12 @@
sb.write('\n $use');
}
}
+ if (_setLiterals != null) {
+ sb.write('\n set-literals:');
+ for (SetLiteralUse use in _setLiterals) {
+ sb.write('\n $use');
+ }
+ }
if (_listLiterals != null) {
sb.write('\n list-literals:');
for (ListLiteralUse use in _listLiterals) {
diff --git a/pkg/compiler/lib/src/universe/feature.dart b/pkg/compiler/lib/src/universe/feature.dart
index 1367e6d..f0c29bc 100644
--- a/pkg/compiler/lib/src/universe/feature.dart
+++ b/pkg/compiler/lib/src/universe/feature.dart
@@ -122,6 +122,29 @@
}
}
+/// Describes a use of a set literal in the program.
+class SetLiteralUse {
+ final InterfaceType type;
+ final bool isConstant;
+ final bool isEmpty;
+
+ SetLiteralUse(this.type, {this.isConstant: false, this.isEmpty: false});
+
+ int get hashCode =>
+ type.hashCode * 13 + isConstant.hashCode * 17 + isEmpty.hashCode * 19;
+
+ bool operator ==(other) {
+ if (identical(this, other)) return true;
+ if (other is! SetLiteralUse) return false;
+ return type == other.type &&
+ isConstant == other.isConstant &&
+ isEmpty == other.isEmpty;
+ }
+
+ String toString() =>
+ 'SetLiteralUse($type,isConstant:$isConstant,isEmpty:$isEmpty)';
+}
+
/// Describes the use of a list literal in the program.
class ListLiteralUse {
final InterfaceType type;