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 3706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3717 // All strings share the same maximum element count to keep things | 3717 // All strings share the same maximum element count to keep things |
3718 // simple. We choose a value that will prevent integer overflow for | 3718 // simple. We choose a value that will prevent integer overflow for |
3719 // 2 byte strings, since it is the worst case. | 3719 // 2 byte strings, since it is the worst case. |
3720 static const intptr_t kSizeofRawString = sizeof(RawObject) + (2 * kWordSize); | 3720 static const intptr_t kSizeofRawString = sizeof(RawObject) + (2 * kWordSize); |
3721 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar; | 3721 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar; |
3722 | 3722 |
3723 class CodePointIterator : public ValueObject { | 3723 class CodePointIterator : public ValueObject { |
3724 public: | 3724 public: |
3725 explicit CodePointIterator(const String& str) | 3725 explicit CodePointIterator(const String& str) |
3726 : str_(str), | 3726 : str_(str), |
3727 ch_(0), | |
3727 index_(-1), | 3728 index_(-1), |
3728 ch_(-1) { | 3729 end_(str.Length()) { |
3730 } | |
3731 | |
3732 CodePointIterator(const String& str, intptr_t start, intptr_t length) | |
3733 : str_(str), | |
3734 ch_(0), | |
3735 index_(start - 1), | |
3736 end_(start + length) { | |
3737 ASSERT(start >= 0); | |
3738 ASSERT(end_ <= str.Length()); | |
3729 } | 3739 } |
3730 | 3740 |
3731 int32_t Current() { | 3741 int32_t Current() { |
3732 ASSERT(index_ >= 0); | 3742 ASSERT(index_ != -1); |
siva
2012/11/30 02:00:19
why was this change necessary?
cshapiro
2012/11/30 02:28:22
It was a remnant of an intermediate edit. Reverte
| |
3733 ASSERT(index_ < str_.Length()); | 3743 ASSERT(index_ < end_); |
3734 return ch_; | 3744 return ch_; |
3735 } | 3745 } |
3736 | 3746 |
3737 bool Next(); | 3747 bool Next(); |
3738 | 3748 |
3739 private: | 3749 private: |
3740 const String& str_; | 3750 const String& str_; |
3751 int32_t ch_; | |
3741 intptr_t index_; | 3752 intptr_t index_; |
3742 int32_t ch_; | 3753 intptr_t end_; |
3743 DISALLOW_IMPLICIT_CONSTRUCTORS(CodePointIterator); | 3754 DISALLOW_IMPLICIT_CONSTRUCTORS(CodePointIterator); |
3744 }; | 3755 }; |
3745 | 3756 |
3746 intptr_t Length() const { return Smi::Value(raw_ptr()->length_); } | 3757 intptr_t Length() const { return Smi::Value(raw_ptr()->length_); } |
3747 static intptr_t length_offset() { return OFFSET_OF(RawString, length_); } | 3758 static intptr_t length_offset() { return OFFSET_OF(RawString, length_); } |
3748 | 3759 |
3749 virtual intptr_t Hash() const; | 3760 virtual intptr_t Hash() const; |
3750 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } | 3761 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } |
3751 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); | 3762 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); |
3752 static intptr_t Hash(const uint8_t* characters, intptr_t len); | 3763 static intptr_t Hash(const uint8_t* characters, intptr_t len); |
(...skipping 2215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5968 if (this->CharAt(i) != str.CharAt(begin_index + i)) { | 5979 if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
5969 return false; | 5980 return false; |
5970 } | 5981 } |
5971 } | 5982 } |
5972 return true; | 5983 return true; |
5973 } | 5984 } |
5974 | 5985 |
5975 } // namespace dart | 5986 } // namespace dart |
5976 | 5987 |
5977 #endif // VM_OBJECT_H_ | 5988 #endif // VM_OBJECT_H_ |
OLD | NEW |