Index: runtime/vm/object.h |
=================================================================== |
--- runtime/vm/object.h (revision 35933) |
+++ runtime/vm/object.h (working copy) |
@@ -4130,7 +4130,17 @@ |
// in Dart source code. |
class Instance : public Object { |
public: |
- virtual bool Equals(const Instance& other) const; |
+ // Equality and identity testing. |
+ // 1. OperatorEquals: true iff 'this == other' is true in Dart code. |
rmacnak
2014/05/12 17:15:17
Reminds me of Self's equivalent (=), indistinguish
koda
2014/05/12 17:41:43
Maybe we should add SameSameButDifferent :)
|
+ // 2. IsIdenticalTo: true iff 'identical(this, other)' is true in Dart code. |
+ // 3. CanonicalizeEquals: used to canonicalize compile-time constants, e.g., |
hausner
2014/05/12 17:09:30
Would it make sense to rename this as BitwiseEqual
koda
2014/05/12 17:41:43
That is almost true, but not technically true for
|
+ // using bitwise equality of fields and list elements. |
+ // Subclasses where 1 and 3 coincide may also define a plain Equals, e.g., |
+ // String and Integer. |
+ virtual bool OperatorEquals(const Instance& other) const; |
+ bool IsIdenticalTo(const Instance& other) const; |
+ virtual bool CanonicalizeEquals(const Instance& other) const; |
+ |
// Returns Instance::null() if instance cannot be canonicalized. |
// Any non-canonical number of string will be canonicalized here. |
// An instance cannot be canonicalized if it still contains non-canonical |
@@ -4160,10 +4170,6 @@ |
const TypeArguments& type_instantiator, |
Error* bound_error) const; |
- // Check whether this instance is identical to the argument according to the |
- // specification of dare:core's identical(). |
- bool IsIdenticalTo(const Instance& other) const; |
- |
bool IsValidNativeIndex(int index) const { |
return ((index >= 0) && (index < clazz()->ptr()->num_native_fields_)); |
} |
@@ -4308,6 +4314,9 @@ |
virtual RawTypeArguments* arguments() const; |
virtual intptr_t token_pos() const; |
virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const; |
+ virtual bool CanonicalizeEquals(const Instance& other) const { |
+ return Equals(other); |
+ } |
virtual bool Equals(const Instance& other) const { |
return IsEquivalent(other); |
} |
@@ -4874,6 +4883,17 @@ |
Heap::Space space = Heap::kNew, |
const bool silent = false); |
+ virtual bool OperatorEquals(const Instance& other) const { |
+ return Equals(other); |
+ } |
+ virtual bool CanonicalizeEquals(const Instance& other) const { |
+ return Equals(other); |
+ } |
+ virtual bool Equals(const Instance& other) const { |
+ UNREACHABLE(); |
+ return false; |
+ } |
+ |
// Integer is an abstract class. |
virtual bool IsZero() const { |
UNREACHABLE(); |
@@ -5138,8 +5158,9 @@ |
return raw_ptr()->value_; |
} |
- bool EqualsToDouble(double value) const; |
- virtual bool Equals(const Instance& other) const; |
+ bool BitwiseEqualsToDouble(double value) const; |
+ virtual bool OperatorEquals(const Instance& other) const; |
+ virtual bool CanonicalizeEquals(const Instance& other) const; |
static RawDouble* New(double d, Heap::Space space = Heap::kNew); |
@@ -5259,6 +5280,12 @@ |
// Compares to an array of UTF-32 encoded characters. |
bool Equals(const int32_t* characters, intptr_t len) const; |
+ virtual bool OperatorEquals(const Instance& other) const { |
+ return Equals(other); |
+ } |
+ virtual bool CanonicalizeEquals(const Instance& other) const { |
+ return Equals(other); |
+ } |
virtual bool Equals(const Instance& other) const; |
intptr_t CompareTo(const String& other) const; |
@@ -5889,7 +5916,7 @@ |
StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
} |
- virtual bool Equals(const Instance& other) const; |
+ virtual bool CanonicalizeEquals(const Instance& other) const; |
static const intptr_t kBytesPerElement = kWordSize; |
static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
@@ -6049,7 +6076,7 @@ |
StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
} |
- virtual bool Equals(const Instance& other) const; |
+ virtual bool CanonicalizeEquals(const Instance& other) const; |
virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { |
UNREACHABLE(); |
@@ -6760,7 +6787,7 @@ |
static RawJSRegExp* FromDataStartAddress(void* data); |
const char* Flags() const; |
- virtual bool Equals(const Instance& other) const; |
+ virtual bool CanonicalizeEquals(const Instance& other) const; |
static const intptr_t kBytesPerElement = 1; |
static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |