| 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 3172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3183 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } | 3183 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } |
| 3184 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); | 3184 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); |
| 3185 static intptr_t Hash(const uint8_t* characters, intptr_t len); | 3185 static intptr_t Hash(const uint8_t* characters, intptr_t len); |
| 3186 static intptr_t Hash(const uint16_t* characters, intptr_t len); | 3186 static intptr_t Hash(const uint16_t* characters, intptr_t len); |
| 3187 static intptr_t Hash(const uint32_t* characters, intptr_t len); | 3187 static intptr_t Hash(const uint32_t* characters, intptr_t len); |
| 3188 | 3188 |
| 3189 virtual int32_t CharAt(intptr_t index) const; | 3189 virtual int32_t CharAt(intptr_t index) const; |
| 3190 | 3190 |
| 3191 virtual intptr_t CharSize() const; | 3191 virtual intptr_t CharSize() const; |
| 3192 | 3192 |
| 3193 bool Equals(const String& str) const { | 3193 inline bool Equals(const String& str) const; |
| 3194 if (raw() == str.raw()) { | 3194 inline bool Equals(const String& str, |
| 3195 return true; // Both handles point to the same raw instance. | 3195 intptr_t begin_index, // begin index on 'str'. |
| 3196 } | 3196 intptr_t len) const; // len on 'str'. |
| 3197 if (str.IsNull()) { | |
| 3198 return false; | |
| 3199 } | |
| 3200 return Equals(str, 0, str.Length()); | |
| 3201 } | |
| 3202 bool Equals(const String& str, intptr_t begin_index, intptr_t len) const; | |
| 3203 bool Equals(const char* str) const; | 3197 bool Equals(const char* str) const; |
| 3204 bool Equals(const uint8_t* characters, intptr_t len) const; | 3198 bool Equals(const uint8_t* characters, intptr_t len) const; |
| 3205 bool Equals(const uint16_t* characters, intptr_t len) const; | 3199 bool Equals(const uint16_t* characters, intptr_t len) const; |
| 3206 bool Equals(const uint32_t* characters, intptr_t len) const; | 3200 bool Equals(const uint32_t* characters, intptr_t len) const; |
| 3207 | 3201 |
| 3208 virtual bool Equals(const Instance& other) const; | 3202 virtual bool Equals(const Instance& other) const; |
| 3209 | 3203 |
| 3210 intptr_t CompareTo(const String& other) const; | 3204 intptr_t CompareTo(const String& other) const; |
| 3211 | 3205 |
| 3212 bool StartsWith(const String& other) const; | 3206 bool StartsWith(const String& other) const; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3335 virtual int32_t CharAt(intptr_t index) const { | 3329 virtual int32_t CharAt(intptr_t index) const { |
| 3336 return *CharAddr(index); | 3330 return *CharAddr(index); |
| 3337 } | 3331 } |
| 3338 | 3332 |
| 3339 virtual intptr_t CharSize() const { | 3333 virtual intptr_t CharSize() const { |
| 3340 return kOneByteChar; | 3334 return kOneByteChar; |
| 3341 } | 3335 } |
| 3342 | 3336 |
| 3343 RawOneByteString* EscapeDoubleQuotes() const; | 3337 RawOneByteString* EscapeDoubleQuotes() const; |
| 3344 | 3338 |
| 3339 bool EqualsIgnoringPrivateKey(const OneByteString& str) const; |
| 3340 |
| 3345 static intptr_t data_offset() { return OFFSET_OF(RawOneByteString, data_); } | 3341 static intptr_t data_offset() { return OFFSET_OF(RawOneByteString, data_); } |
| 3346 | 3342 |
| 3347 static intptr_t InstanceSize() { | 3343 static intptr_t InstanceSize() { |
| 3348 ASSERT(sizeof(RawOneByteString) == OFFSET_OF(RawOneByteString, data_)); | 3344 ASSERT(sizeof(RawOneByteString) == OFFSET_OF(RawOneByteString, data_)); |
| 3349 return 0; | 3345 return 0; |
| 3350 } | 3346 } |
| 3351 | 3347 |
| 3352 static intptr_t InstanceSize(intptr_t len) { | 3348 static intptr_t InstanceSize(intptr_t len) { |
| 3353 return RoundedAllocationSize(sizeof(RawOneByteString) + len); | 3349 return RoundedAllocationSize(sizeof(RawOneByteString) + len); |
| 3354 } | 3350 } |
| 3355 | 3351 |
| 3356 static RawOneByteString* New(intptr_t len, | 3352 static RawOneByteString* New(intptr_t len, |
| 3357 Heap::Space space); | 3353 Heap::Space space); |
| 3354 static RawOneByteString* New(const char* c_string, |
| 3355 Heap::Space space = Heap::kNew) { |
| 3356 return New(reinterpret_cast<const uint8_t*>(c_string), |
| 3357 strlen(c_string), |
| 3358 space); |
| 3359 } |
| 3358 static RawOneByteString* New(const uint8_t* characters, | 3360 static RawOneByteString* New(const uint8_t* characters, |
| 3359 intptr_t len, | 3361 intptr_t len, |
| 3360 Heap::Space space); | 3362 Heap::Space space); |
| 3361 static RawOneByteString* New(const uint16_t* characters, | 3363 static RawOneByteString* New(const uint16_t* characters, |
| 3362 intptr_t len, | 3364 intptr_t len, |
| 3363 Heap::Space space); | 3365 Heap::Space space); |
| 3364 static RawOneByteString* New(const uint32_t* characters, | 3366 static RawOneByteString* New(const uint32_t* characters, |
| 3365 intptr_t len, | 3367 intptr_t len, |
| 3366 Heap::Space space); | 3368 Heap::Space space); |
| 3367 static RawOneByteString* New(const OneByteString& str, | 3369 static RawOneByteString* New(const OneByteString& str, |
| (...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5133 | 5135 |
| 5134 void Context::SetAt(intptr_t index, const Instance& value) const { | 5136 void Context::SetAt(intptr_t index, const Instance& value) const { |
| 5135 StorePointer(InstanceAddr(index), value.raw()); | 5137 StorePointer(InstanceAddr(index), value.raw()); |
| 5136 } | 5138 } |
| 5137 | 5139 |
| 5138 | 5140 |
| 5139 intptr_t Stackmap::SizeInBits() const { | 5141 intptr_t Stackmap::SizeInBits() const { |
| 5140 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); | 5142 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); |
| 5141 } | 5143 } |
| 5142 | 5144 |
| 5145 |
| 5146 bool String::Equals(const String& str) const { |
| 5147 if (raw() == str.raw()) { |
| 5148 return true; // Both handles point to the same raw instance. |
| 5149 } |
| 5150 if (str.IsNull()) { |
| 5151 return false; |
| 5152 } |
| 5153 return Equals(str, 0, str.Length()); |
| 5154 } |
| 5155 |
| 5156 |
| 5157 bool String::Equals(const String& str, |
| 5158 intptr_t begin_index, |
| 5159 intptr_t len) const { |
| 5160 ASSERT(begin_index >= 0); |
| 5161 ASSERT((begin_index == 0) || (begin_index < str.Length())); |
| 5162 ASSERT(len >= 0); |
| 5163 ASSERT(len <= str.Length()); |
| 5164 if (len != this->Length()) { |
| 5165 return false; // Lengths don't match. |
| 5166 } |
| 5167 for (intptr_t i = 0; i < len; i++) { |
| 5168 if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
| 5169 return false; |
| 5170 } |
| 5171 } |
| 5172 return true; |
| 5173 } |
| 5174 |
| 5143 } // namespace dart | 5175 } // namespace dart |
| 5144 | 5176 |
| 5145 #endif // VM_OBJECT_H_ | 5177 #endif // VM_OBJECT_H_ |
| OLD | NEW |