| 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 3724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3735 // All strings share the same maximum element count to keep things | 3735 // All strings share the same maximum element count to keep things |
| 3736 // simple. We choose a value that will prevent integer overflow for | 3736 // simple. We choose a value that will prevent integer overflow for |
| 3737 // 2 byte strings, since it is the worst case. | 3737 // 2 byte strings, since it is the worst case. |
| 3738 static const intptr_t kSizeofRawString = sizeof(RawObject) + (2 * kWordSize); | 3738 static const intptr_t kSizeofRawString = sizeof(RawObject) + (2 * kWordSize); |
| 3739 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar; | 3739 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar; |
| 3740 | 3740 |
| 3741 class CodePointIterator : public ValueObject { | 3741 class CodePointIterator : public ValueObject { |
| 3742 public: | 3742 public: |
| 3743 explicit CodePointIterator(const String& str) | 3743 explicit CodePointIterator(const String& str) |
| 3744 : str_(str), | 3744 : str_(str), |
| 3745 ch_(0), |
| 3745 index_(-1), | 3746 index_(-1), |
| 3746 ch_(-1) { | 3747 end_(str.Length()) { |
| 3748 } |
| 3749 |
| 3750 CodePointIterator(const String& str, intptr_t start, intptr_t length) |
| 3751 : str_(str), |
| 3752 ch_(0), |
| 3753 index_(start - 1), |
| 3754 end_(start + length) { |
| 3755 ASSERT(start >= 0); |
| 3756 ASSERT(end_ <= str.Length()); |
| 3747 } | 3757 } |
| 3748 | 3758 |
| 3749 int32_t Current() { | 3759 int32_t Current() { |
| 3750 ASSERT(index_ >= 0); | 3760 ASSERT(index_ >= 0); |
| 3751 ASSERT(index_ < str_.Length()); | 3761 ASSERT(index_ < end_); |
| 3752 return ch_; | 3762 return ch_; |
| 3753 } | 3763 } |
| 3754 | 3764 |
| 3755 bool Next(); | 3765 bool Next(); |
| 3756 | 3766 |
| 3757 private: | 3767 private: |
| 3758 const String& str_; | 3768 const String& str_; |
| 3769 int32_t ch_; |
| 3759 intptr_t index_; | 3770 intptr_t index_; |
| 3760 int32_t ch_; | 3771 intptr_t end_; |
| 3761 DISALLOW_IMPLICIT_CONSTRUCTORS(CodePointIterator); | 3772 DISALLOW_IMPLICIT_CONSTRUCTORS(CodePointIterator); |
| 3762 }; | 3773 }; |
| 3763 | 3774 |
| 3764 intptr_t Length() const { return Smi::Value(raw_ptr()->length_); } | 3775 intptr_t Length() const { return Smi::Value(raw_ptr()->length_); } |
| 3765 static intptr_t length_offset() { return OFFSET_OF(RawString, length_); } | 3776 static intptr_t length_offset() { return OFFSET_OF(RawString, length_); } |
| 3766 | 3777 |
| 3767 virtual intptr_t Hash() const; | 3778 virtual intptr_t Hash() const; |
| 3768 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } | 3779 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } |
| 3769 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); | 3780 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); |
| 3770 static intptr_t Hash(const uint8_t* characters, intptr_t len); | 3781 static intptr_t Hash(const uint8_t* characters, intptr_t len); |
| (...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5993 if (this->CharAt(i) != str.CharAt(begin_index + i)) { | 6004 if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
| 5994 return false; | 6005 return false; |
| 5995 } | 6006 } |
| 5996 } | 6007 } |
| 5997 return true; | 6008 return true; |
| 5998 } | 6009 } |
| 5999 | 6010 |
| 6000 } // namespace dart | 6011 } // namespace dart |
| 6001 | 6012 |
| 6002 #endif // VM_OBJECT_H_ | 6013 #endif // VM_OBJECT_H_ |
| OLD | NEW |