| 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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" | 
| (...skipping 9938 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 9949   this->SetHash(result); | 9949   this->SetHash(result); | 
| 9950   return result; | 9950   return result; | 
| 9951 } | 9951 } | 
| 9952 | 9952 | 
| 9953 | 9953 | 
| 9954 intptr_t String::Hash(const String& str, intptr_t begin_index, intptr_t len) { | 9954 intptr_t String::Hash(const String& str, intptr_t begin_index, intptr_t len) { | 
| 9955   ASSERT(begin_index >= 0); | 9955   ASSERT(begin_index >= 0); | 
| 9956   ASSERT(len >= 0); | 9956   ASSERT(len >= 0); | 
| 9957   ASSERT((begin_index + len) <= str.Length()); | 9957   ASSERT((begin_index + len) <= str.Length()); | 
| 9958   StringHasher hasher; | 9958   StringHasher hasher; | 
| 9959   for (intptr_t i = 0; i < len; i++) { | 9959   CodePointIterator it(str, begin_index, len); | 
| 9960     hasher.Add(str.CharAt(begin_index + i)); | 9960   while (it.Next()) { | 
|  | 9961     hasher.Add(it.Current()); | 
| 9961   } | 9962   } | 
| 9962   return hasher.Finalize(String::kHashBits); | 9963   return hasher.Finalize(String::kHashBits); | 
| 9963 } | 9964 } | 
| 9964 | 9965 | 
| 9965 | 9966 | 
| 9966 template<typename T> | 9967 template<typename T> | 
| 9967 static intptr_t HashImpl(const T* characters, intptr_t len) { | 9968 static intptr_t HashImpl(const T* characters, intptr_t len) { | 
| 9968   ASSERT(len >= 0); | 9969   ASSERT(len >= 0); | 
| 9969   StringHasher hasher; | 9970   StringHasher hasher; | 
| 9970   for (intptr_t i = 0; i < len; i++) { | 9971   for (intptr_t i = 0; i < len; i++) { | 
| 9971     hasher.Add(characters[i]); | 9972     hasher.Add(characters[i]); | 
| 9972   } | 9973   } | 
| 9973   return hasher.Finalize(String::kHashBits); | 9974   return hasher.Finalize(String::kHashBits); | 
| 9974 } | 9975 } | 
| 9975 | 9976 | 
| 9976 | 9977 | 
| 9977 intptr_t String::Hash(const uint8_t* characters, intptr_t len) { | 9978 intptr_t String::Hash(const uint8_t* characters, intptr_t len) { | 
| 9978   return HashImpl(characters, len); | 9979   return HashImpl(characters, len); | 
| 9979 } | 9980 } | 
| 9980 | 9981 | 
| 9981 | 9982 | 
| 9982 intptr_t String::Hash(const uint16_t* characters, intptr_t len) { | 9983 intptr_t String::Hash(const uint16_t* characters, intptr_t len) { | 
| 9983   return HashImpl(characters, len); | 9984   StringHasher hasher; | 
|  | 9985   intptr_t i = 0; | 
|  | 9986   while (i < len) { | 
|  | 9987     hasher.Add(Utf16::Next(characters, &i, len)); | 
|  | 9988   } | 
|  | 9989   return hasher.Finalize(String::kHashBits); | 
| 9984 } | 9990 } | 
| 9985 | 9991 | 
| 9986 | 9992 | 
| 9987 intptr_t String::Hash(const int32_t* characters, intptr_t len) { | 9993 intptr_t String::Hash(const int32_t* characters, intptr_t len) { | 
| 9988   return HashImpl(characters, len); | 9994   return HashImpl(characters, len); | 
| 9989 } | 9995 } | 
| 9990 | 9996 | 
| 9991 | 9997 | 
| 9992 int32_t String::CharAt(intptr_t index) const { | 9998 int32_t String::CharAt(intptr_t index) const { | 
| 9993   intptr_t class_id = raw()->GetClassId(); | 9999   intptr_t class_id = raw()->GetClassId(); | 
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 10599 | 10605 | 
| 10600 | 10606 | 
| 10601 RawString* String::ToLowerCase(const String& str, Heap::Space space) { | 10607 RawString* String::ToLowerCase(const String& str, Heap::Space space) { | 
| 10602   // TODO(cshapiro): create a fast-path for OneByteString instances. | 10608   // TODO(cshapiro): create a fast-path for OneByteString instances. | 
| 10603   return Transform(CaseMapping::ToLower, str, space); | 10609   return Transform(CaseMapping::ToLower, str, space); | 
| 10604 } | 10610 } | 
| 10605 | 10611 | 
| 10606 | 10612 | 
| 10607 bool String::CodePointIterator::Next() { | 10613 bool String::CodePointIterator::Next() { | 
| 10608   ASSERT(index_ >= -1); | 10614   ASSERT(index_ >= -1); | 
| 10609   ASSERT(index_ < str_.Length()); | 10615   intptr_t length = Utf16::Length(ch_); | 
| 10610   int d = Utf16::Length(ch_); | 10616   if (index_ < (end_ - length)) { | 
| 10611   if (index_ == (str_.Length() - d)) { | 10617     index_ += length; | 
| 10612     return false; | 10618     ch_ = str_.CharAt(index_); | 
|  | 10619     if (Utf16::IsLeadSurrogate(ch_) && (index_ < (end_ - 1))) { | 
|  | 10620       int32_t ch2 = str_.CharAt(index_ + 1); | 
|  | 10621       if (Utf16::IsTrailSurrogate(ch2)) { | 
|  | 10622         ch_ = Utf16::Decode(ch_, ch2); | 
|  | 10623       } | 
|  | 10624     } | 
|  | 10625     return true; | 
| 10613   } | 10626   } | 
| 10614   index_ += d; | 10627   index_ = end_; | 
| 10615   ch_ = str_.CharAt(index_); | 10628   return false; | 
| 10616   if (Utf16::IsLeadSurrogate(ch_) && (index_ != (str_.Length() - 1))) { |  | 
| 10617     int32_t ch2 = str_.CharAt(index_ + 1); |  | 
| 10618     if (Utf16::IsTrailSurrogate(ch2)) { |  | 
| 10619       ch_ = Utf16::Decode(ch_, ch2); |  | 
| 10620     } |  | 
| 10621   } |  | 
| 10622   return true; |  | 
| 10623 } | 10629 } | 
| 10624 | 10630 | 
| 10625 | 10631 | 
| 10626 RawOneByteString* OneByteString::EscapeSpecialCharacters(const String& str, | 10632 RawOneByteString* OneByteString::EscapeSpecialCharacters(const String& str, | 
| 10627                                                          bool raw_str) { | 10633                                                          bool raw_str) { | 
| 10628   intptr_t len = str.Length(); | 10634   intptr_t len = str.Length(); | 
| 10629   if (len > 0) { | 10635   if (len > 0) { | 
| 10630     intptr_t num_escapes = 0; | 10636     intptr_t num_escapes = 0; | 
| 10631     intptr_t index = 0; | 10637     intptr_t index = 0; | 
| 10632     for (intptr_t i = 0; i < len; i++) { | 10638     for (intptr_t i = 0; i < len; i++) { | 
| (...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 12190   } | 12196   } | 
| 12191   return result.raw(); | 12197   return result.raw(); | 
| 12192 } | 12198 } | 
| 12193 | 12199 | 
| 12194 | 12200 | 
| 12195 const char* WeakProperty::ToCString() const { | 12201 const char* WeakProperty::ToCString() const { | 
| 12196   return "_WeakProperty"; | 12202   return "_WeakProperty"; | 
| 12197 } | 12203 } | 
| 12198 | 12204 | 
| 12199 }  // namespace dart | 12205 }  // namespace dart | 
| OLD | NEW | 
|---|