OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2838 // Verify output. | 2838 // Verify output. |
2839 ASSERT(string == NULL || offset_out == 0); | 2839 ASSERT(string == NULL || offset_out == 0); |
2840 ASSERT(string == NULL || | 2840 ASSERT(string == NULL || |
2841 *length_out == static_cast<unsigned>(string->length())); | 2841 *length_out == static_cast<unsigned>(string->length())); |
2842 ASSERT(string == NULL || *type_out == string->map()->instance_type()); | 2842 ASSERT(string == NULL || *type_out == string->map()->instance_type()); |
2843 return string; | 2843 return string; |
2844 } | 2844 } |
2845 | 2845 |
2846 | 2846 |
2847 uint16_t StringCharacterStream::GetNext() { | 2847 uint16_t StringCharacterStream::GetNext() { |
2848 ASSERT((buffer8_ == NULL && end_ == NULL) || buffer8_ < end_); | 2848 ASSERT(buffer8_ != NULL && end_ != NULL); |
| 2849 // Advance cursor if needed. |
| 2850 // TODO(dcarney): Ensure uses of the api call HasMore first and avoid this. |
| 2851 if (buffer8_ == end_) HasMore(); |
| 2852 ASSERT(buffer8_ < end_); |
2849 return is_one_byte_ ? *buffer8_++ : *buffer16_++; | 2853 return is_one_byte_ ? *buffer8_++ : *buffer16_++; |
2850 } | 2854 } |
2851 | 2855 |
2852 | 2856 |
2853 StringCharacterStream::StringCharacterStream( | 2857 StringCharacterStream::StringCharacterStream(String* string, |
2854 String* string, unsigned offset, ConsStringIteratorOp* op) | 2858 ConsStringIteratorOp* op, |
| 2859 unsigned offset) |
2855 : is_one_byte_(false), | 2860 : is_one_byte_(false), |
2856 buffer8_(NULL), | |
2857 end_(NULL), | |
2858 op_(op) { | 2861 op_(op) { |
2859 op->Reset(); | 2862 Reset(string, offset); |
2860 int32_t type = string->map()->instance_type(); | |
2861 unsigned length = string->length(); | |
2862 String::Visit(string, offset, *this, *op, type, length); | |
2863 } | 2863 } |
2864 | 2864 |
2865 | 2865 |
| 2866 void StringCharacterStream::Reset(String* string, unsigned offset) { |
| 2867 op_->Reset(); |
| 2868 buffer8_ = NULL; |
| 2869 end_ = NULL; |
| 2870 int32_t type = string->map()->instance_type(); |
| 2871 unsigned length = string->length(); |
| 2872 String::Visit(string, offset, *this, *op_, type, length); |
| 2873 } |
| 2874 |
| 2875 |
2866 bool StringCharacterStream::HasMore() { | 2876 bool StringCharacterStream::HasMore() { |
2867 if (buffer8_ != end_) return true; | 2877 if (buffer8_ != end_) return true; |
2868 if (!op_->HasMore()) return false; | 2878 if (!op_->HasMore()) return false; |
2869 unsigned length; | 2879 unsigned length; |
2870 int32_t type; | 2880 int32_t type; |
2871 String* string = op_->ContinueOperation(&type, &length); | 2881 String* string = op_->ContinueOperation(&type, &length); |
2872 if (string == NULL) return false; | 2882 if (string == NULL) return false; |
2873 ASSERT(!string->IsConsString()); | 2883 ASSERT(!string->IsConsString()); |
2874 ASSERT(string->length() != 0); | 2884 ASSERT(string->length() != 0); |
2875 ConsStringNullOp null_op; | 2885 ConsStringNullOp null_op; |
(...skipping 2895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5771 #undef WRITE_UINT32_FIELD | 5781 #undef WRITE_UINT32_FIELD |
5772 #undef READ_SHORT_FIELD | 5782 #undef READ_SHORT_FIELD |
5773 #undef WRITE_SHORT_FIELD | 5783 #undef WRITE_SHORT_FIELD |
5774 #undef READ_BYTE_FIELD | 5784 #undef READ_BYTE_FIELD |
5775 #undef WRITE_BYTE_FIELD | 5785 #undef WRITE_BYTE_FIELD |
5776 | 5786 |
5777 | 5787 |
5778 } } // namespace v8::internal | 5788 } } // namespace v8::internal |
5779 | 5789 |
5780 #endif // V8_OBJECTS_INL_H_ | 5790 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |