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 #include "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 17055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17066 } | 17066 } |
17067 return hasher.Finalize(String::kHashBits); | 17067 return hasher.Finalize(String::kHashBits); |
17068 } | 17068 } |
17069 | 17069 |
17070 | 17070 |
17071 intptr_t String::Hash(const int32_t* characters, intptr_t len) { | 17071 intptr_t String::Hash(const int32_t* characters, intptr_t len) { |
17072 return HashImpl(characters, len); | 17072 return HashImpl(characters, len); |
17073 } | 17073 } |
17074 | 17074 |
17075 | 17075 |
17076 int32_t String::CharAt(intptr_t index) const { | 17076 uint16_t String::CharAt(intptr_t index) const { |
17077 intptr_t class_id = raw()->GetClassId(); | 17077 intptr_t class_id = raw()->GetClassId(); |
17078 ASSERT(RawObject::IsStringClassId(class_id)); | 17078 ASSERT(RawObject::IsStringClassId(class_id)); |
17079 NoGCScope no_gc; | 17079 NoGCScope no_gc; |
17080 if (class_id == kOneByteStringCid) { | 17080 if (class_id == kOneByteStringCid) { |
17081 return *OneByteString::CharAddr(*this, index); | 17081 return *OneByteString::CharAddr(*this, index); |
17082 } | 17082 } |
17083 if (class_id == kTwoByteStringCid) { | 17083 if (class_id == kTwoByteStringCid) { |
17084 return *TwoByteString::CharAddr(*this, index); | 17084 return *TwoByteString::CharAddr(*this, index); |
17085 } | 17085 } |
17086 if (class_id == kExternalOneByteStringCid) { | 17086 if (class_id == kExternalOneByteStringCid) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17223 str1.Equals(*this, 0, str1.Length()) && | 17223 str1.Equals(*this, 0, str1.Length()) && |
17224 str2.Equals(*this, str1.Length(), str2.Length()); | 17224 str2.Equals(*this, str1.Length(), str2.Length()); |
17225 } | 17225 } |
17226 | 17226 |
17227 | 17227 |
17228 intptr_t String::CompareTo(const String& other) const { | 17228 intptr_t String::CompareTo(const String& other) const { |
17229 const intptr_t this_len = this->Length(); | 17229 const intptr_t this_len = this->Length(); |
17230 const intptr_t other_len = other.IsNull() ? 0 : other.Length(); | 17230 const intptr_t other_len = other.IsNull() ? 0 : other.Length(); |
17231 const intptr_t len = (this_len < other_len) ? this_len : other_len; | 17231 const intptr_t len = (this_len < other_len) ? this_len : other_len; |
17232 for (intptr_t i = 0; i < len; i++) { | 17232 for (intptr_t i = 0; i < len; i++) { |
17233 int32_t this_code_point = this->CharAt(i); | 17233 uint16_t this_code_unit = this->CharAt(i); |
17234 int32_t other_code_point = other.CharAt(i); | 17234 uint16_t other_code_unit = other.CharAt(i); |
17235 if (this_code_point < other_code_point) { | 17235 if (this_code_unit < other_code_unit) { |
17236 return -1; | 17236 return -1; |
17237 } | 17237 } |
17238 if (this_code_point > other_code_point) { | 17238 if (this_code_unit > other_code_unit) { |
17239 return 1; | 17239 return 1; |
17240 } | 17240 } |
17241 } | 17241 } |
17242 if (this_len < other_len) return -1; | 17242 if (this_len < other_len) return -1; |
17243 if (this_len > other_len) return 1; | 17243 if (this_len > other_len) return 1; |
17244 return 0; | 17244 return 0; |
17245 } | 17245 } |
17246 | 17246 |
17247 | 17247 |
17248 bool String::StartsWith(const String& other) const { | 17248 bool String::StartsWith(const String& other) const { |
(...skipping 3103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20352 return tag_label.ToCString(); | 20352 return tag_label.ToCString(); |
20353 } | 20353 } |
20354 | 20354 |
20355 | 20355 |
20356 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20356 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20357 Instance::PrintJSONImpl(stream, ref); | 20357 Instance::PrintJSONImpl(stream, ref); |
20358 } | 20358 } |
20359 | 20359 |
20360 | 20360 |
20361 } // namespace dart | 20361 } // namespace dart |
OLD | NEW |