Index: pkg/compiler/lib/src/constants/expressions.dart |
diff --git a/pkg/compiler/lib/src/constants/expressions.dart b/pkg/compiler/lib/src/constants/expressions.dart |
index 5644b0f5847ce5db238ce8f803a226a1c2904470..dc0a3d9c811489aa12f3f1700c6d5afd758d8702 100644 |
--- a/pkg/compiler/lib/src/constants/expressions.dart |
+++ b/pkg/compiler/lib/src/constants/expressions.dart |
@@ -18,6 +18,7 @@ import '../elements/elements.dart' show |
import '../resolution/operators.dart'; |
import '../tree/tree.dart' show DartString; |
import '../universe/universe.dart' show CallStructure; |
+import '../util/util.dart'; |
import 'values.dart'; |
enum ConstantExpressionKind { |
@@ -141,6 +142,23 @@ class GenerativeConstantConstructor implements ConstantConstructor{ |
return appliedFieldMap; |
} |
+ int get hashCode { |
+ int hash = Hashing.objectHash(type); |
+ hash = Hashing.mapHash(defaultValues, hash); |
+ hash = Hashing.mapHash(fieldMap, hash); |
+ return Hashing.objectHash(superConstructorInvocation, hash); |
+ } |
+ |
+ bool operator ==(other) { |
+ if (identical(this, other)) return true; |
+ if (other is! GenerativeConstantConstructor) return false; |
+ return |
+ type == other.type && |
+ superConstructorInvocation == other.superConstructorInvocation && |
+ mapEquals(defaultValues, other.defaultValues) && |
+ mapEquals(fieldMap, other.fieldMap); |
+ } |
+ |
String toString() { |
StringBuffer sb = new StringBuffer(); |
sb.write("{'type': $type"); |
@@ -157,6 +175,16 @@ class GenerativeConstantConstructor implements ConstantConstructor{ |
return sb.toString(); |
} |
+ static bool mapEquals(Map map1, Map map2) { |
+ if (map1.length != map1.length) return false; |
+ for (var key in map1.keys) { |
+ if (map1[key] != map2[key]) { |
+ return false; |
+ } |
+ } |
+ return true; |
+ } |
+ |
/// Creates the field-to-constant map from applying [args] to |
/// [constructorInvocation]. If [constructorInvocation] is `null`, an empty |
/// map is created. |
@@ -205,6 +233,20 @@ class RedirectingGenerativeConstantConstructor implements ConstantConstructor { |
return appliedFieldMap; |
} |
+ int get hashCode { |
+ int hash = Hashing.objectHash(thisConstructorInvocation); |
+ return Hashing.mapHash(defaultValues, hash); |
+ } |
+ |
+ bool operator ==(other) { |
+ if (identical(this, other)) return true; |
+ if (other is! RedirectingGenerativeConstantConstructor) return false; |
+ return |
+ thisConstructorInvocation == other.thisConstructorInvocation && |
+ GenerativeConstantConstructor.mapEquals( |
+ defaultValues, other.defaultValues); |
+ } |
+ |
String toString() { |
StringBuffer sb = new StringBuffer(); |
sb.write("{'type': ${thisConstructorInvocation.type}"); |
@@ -240,6 +282,16 @@ class RedirectingFactoryConstantConstructor implements ConstantConstructor { |
return constantConstructor.computeInstanceFields(arguments, callStructure); |
} |
+ int get hashCode { |
+ return Hashing.objectHash(targetConstructorInvocation); |
+ } |
+ |
+ bool operator ==(other) { |
+ if (identical(this, other)) return true; |
+ if (other is! RedirectingFactoryConstantConstructor) return false; |
+ return targetConstructorInvocation == other.targetConstructorInvocation; |
+ } |
+ |
String toString() { |
StringBuffer sb = new StringBuffer(); |
sb.write("{"); |