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

Unified Diff: pkg/compiler/lib/src/util/enumset.dart

Issue 2543753004: Move processing of instance members from ResolutionEnqueuer to ResolutionWorldBuilderImpl (Closed)
Patch Set: Created 4 years 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/util/enumset.dart
diff --git a/pkg/compiler/lib/src/util/enumset.dart b/pkg/compiler/lib/src/util/enumset.dart
index ab4dcc86d94ca855ea6925317eb8a9ab592b490f..aeb82065b2500cfd134756014c306c08312034ec 100644
--- a/pkg/compiler/lib/src/util/enumset.dart
+++ b/pkg/compiler/lib/src/util/enumset.dart
@@ -35,9 +35,27 @@ abstract class EnumSet<E> {
/// Adds [enumValue] to this set.
void add(E enumValue);
+ /// Adds all enum values in [set] to this set.
+ void addAll(EnumSet<E> set);
+
/// Removes [enumValue] from this set.
void remove(E enumValue);
+ /// Removes all enum values in [set] from this set. The set of removed values
+ /// is returned.
+ EnumSet<E> removeAll(EnumSet<E> set);
+
+ /// Returns a new set containing all values in both this and the [other] set.
+ EnumSet<E> intersection(EnumSet<E> other) {
+ return new EnumSet.fromValue(value & other.value);
+ }
+
+ /// Returns a new set containing all values in both this bot _not_ in the
Harry Terkelsen 2016/12/05 22:48:53 "containing all values in this set that are not in
Johnni Winther 2016/12/06 09:28:06 Done.
+ /// [other] set.
+ EnumSet<E> minus(EnumSet<E> other) {
+ return new EnumSet.fromValue(value & ~other.value);
+ }
+
/// Clears this set.
void clear();
@@ -67,6 +85,9 @@ abstract class EnumSet<E> {
/// Returns `true` if this set is empty.
bool get isEmpty => value == 0;
+ /// Returns `true` if this set is not empty.
+ bool get isNotEmpty => value != 0;
+
int get hashCode => value.hashCode * 19;
bool operator ==(other) {
@@ -103,16 +124,32 @@ class _EnumSet<E> extends EnumSet<E> {
values.forEach(add);
}
+ @override
int get value => _value;
+ @override
void add(E enumValue) {
_value |= 1 << (enumValue as dynamic).index;
}
+ @override
+ void addAll(EnumSet<E> set) {
+ _value |= set.value;
+ }
+
+ @override
void remove(E enumValue) {
_value &= ~(1 << (enumValue as dynamic).index);
}
+ @override
+ EnumSet<E> removeAll(EnumSet<E> set) {
+ int removed = _value & set.value;
+ _value &= ~set.value;
+ return new EnumSet<E>.fromValue(removed);
+ }
+
+ @override
void clear() {
_value = 0;
}
@@ -142,6 +179,11 @@ class _ConstEnumSet<E> extends EnumSet<E> {
}
@override
+ void addAll(EnumSet<E> set) {
+ throw new UnsupportedError('EnumSet.addAll');
+ }
+
+ @override
void clear() {
throw new UnsupportedError('EnumSet.clear');
}
@@ -150,6 +192,11 @@ class _ConstEnumSet<E> extends EnumSet<E> {
void remove(E enumValue) {
throw new UnsupportedError('EnumSet.remove');
}
+
+ @override
+ EnumSet<E> removeAll(EnumSet<E> set) {
+ throw new UnsupportedError('EnumSet.removeAll');
+ }
}
class _EnumSetIterable<E> extends IterableBase<E> {

Powered by Google App Engine
This is Rietveld 408576698