Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
| (...skipping 3170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3181 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } | 3181 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } |
| 3182 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); | 3182 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); |
| 3183 static intptr_t Hash(const uint8_t* characters, intptr_t len); | 3183 static intptr_t Hash(const uint8_t* characters, intptr_t len); |
| 3184 static intptr_t Hash(const uint16_t* characters, intptr_t len); | 3184 static intptr_t Hash(const uint16_t* characters, intptr_t len); |
| 3185 static intptr_t Hash(const uint32_t* characters, intptr_t len); | 3185 static intptr_t Hash(const uint32_t* characters, intptr_t len); |
| 3186 | 3186 |
| 3187 virtual int32_t CharAt(intptr_t index) const; | 3187 virtual int32_t CharAt(intptr_t index) const; |
| 3188 | 3188 |
| 3189 virtual intptr_t CharSize() const; | 3189 virtual intptr_t CharSize() const; |
| 3190 | 3190 |
| 3191 bool Equals(const String& str) const { | 3191 inline bool Equals(const String& str) const; |
| 3192 if (raw() == str.raw()) { | 3192 inline bool Equals(const String& str, |
| 3193 return true; // Both handles point to the same raw instance. | 3193 intptr_t begin_index, |
| 3194 } | 3194 intptr_t len) const; |
| 3195 if (str.IsNull()) { | |
| 3196 return false; | |
| 3197 } | |
| 3198 return Equals(str, 0, str.Length()); | |
| 3199 } | |
| 3200 bool Equals(const String& str, intptr_t begin_index, intptr_t len) const; | |
| 3201 bool Equals(const char* str) const; | 3195 bool Equals(const char* str) const; |
| 3202 bool Equals(const uint8_t* characters, intptr_t len) const; | 3196 bool Equals(const uint8_t* characters, intptr_t len) const; |
| 3203 bool Equals(const uint16_t* characters, intptr_t len) const; | 3197 bool Equals(const uint16_t* characters, intptr_t len) const; |
| 3204 bool Equals(const uint32_t* characters, intptr_t len) const; | 3198 bool Equals(const uint32_t* characters, intptr_t len) const; |
| 3205 | 3199 |
| 3206 virtual bool Equals(const Instance& other) const; | 3200 virtual bool Equals(const Instance& other) const; |
| 3207 | 3201 |
| 3208 intptr_t CompareTo(const String& other) const; | 3202 intptr_t CompareTo(const String& other) const; |
| 3209 | 3203 |
| 3210 bool StartsWith(const String& other) const; | 3204 bool StartsWith(const String& other) const; |
| (...skipping 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5131 | 5125 |
| 5132 void Context::SetAt(intptr_t index, const Instance& value) const { | 5126 void Context::SetAt(intptr_t index, const Instance& value) const { |
| 5133 StorePointer(InstanceAddr(index), value.raw()); | 5127 StorePointer(InstanceAddr(index), value.raw()); |
| 5134 } | 5128 } |
| 5135 | 5129 |
| 5136 | 5130 |
| 5137 intptr_t Stackmap::SizeInBits() const { | 5131 intptr_t Stackmap::SizeInBits() const { |
| 5138 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); | 5132 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); |
| 5139 } | 5133 } |
| 5140 | 5134 |
| 5135 | |
| 5136 bool String::Equals(const String& str) const { | |
| 5137 if (raw() == str.raw()) { | |
| 5138 return true; // Both handles point to the same raw instance. | |
| 5139 } | |
| 5140 if (str.IsNull()) { | |
| 5141 return false; | |
| 5142 } | |
| 5143 return Equals(str, 0, str.Length()); | |
| 5144 } | |
| 5145 | |
| 5146 | |
| 5147 bool String::Equals(const String& str, | |
| 5148 intptr_t begin_index, | |
| 5149 intptr_t len) const { | |
| 5150 ASSERT(begin_index >= 0); | |
|
srdjan
2012/07/13 23:22:23
Compare raws as well.
siva
2012/07/16 18:29:23
I don't think we can do a raw comparision and retu
| |
| 5151 ASSERT(begin_index == 0 || begin_index < str.Length()); | |
|
srdjan
2012/07/13 23:22:23
Add parenthesis
siva
2012/07/16 18:29:23
Done.
| |
| 5152 ASSERT(len >= 0); | |
| 5153 ASSERT(len <= str.Length()); | |
| 5154 if (len != this->Length()) { | |
| 5155 return false; // Lengths don't match. | |
| 5156 } | |
| 5157 for (intptr_t i = 0; i < len; i++) { | |
| 5158 if (this->CharAt(i) != str.CharAt(begin_index + i)) { | |
| 5159 return false; | |
| 5160 } | |
| 5161 } | |
| 5162 return true; | |
| 5163 } | |
| 5164 | |
| 5141 } // namespace dart | 5165 } // namespace dart |
| 5142 | 5166 |
| 5143 #endif // VM_OBJECT_H_ | 5167 #endif // VM_OBJECT_H_ |
| OLD | NEW |