OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/scanner-character-streams.h" | 7 #include "src/scanner-character-streams.h" |
8 | 8 |
9 #include "include/v8.h" | 9 #include "include/v8.h" |
10 #include "src/handles.h" | 10 #include "src/handles.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 return BufferSeekForward(delta); | 123 return BufferSeekForward(delta); |
124 } | 124 } |
125 | 125 |
126 | 126 |
127 // ---------------------------------------------------------------------------- | 127 // ---------------------------------------------------------------------------- |
128 // GenericStringUtf16CharacterStream | 128 // GenericStringUtf16CharacterStream |
129 | 129 |
130 | 130 |
131 GenericStringUtf16CharacterStream::GenericStringUtf16CharacterStream( | 131 GenericStringUtf16CharacterStream::GenericStringUtf16CharacterStream( |
132 Handle<String> data, size_t start_position, size_t end_position) | 132 Handle<String> data, size_t start_position, size_t end_position) |
133 : string_(data), length_(end_position) { | 133 : string_(data), length_(end_position), bookmark_(start_position) { |
134 DCHECK(end_position >= start_position); | 134 DCHECK(end_position >= start_position); |
135 pos_ = start_position; | 135 pos_ = start_position; |
136 } | 136 } |
137 | 137 |
138 | 138 |
139 GenericStringUtf16CharacterStream::~GenericStringUtf16CharacterStream() { } | 139 GenericStringUtf16CharacterStream::~GenericStringUtf16CharacterStream() { } |
140 | 140 |
141 | 141 |
| 142 bool GenericStringUtf16CharacterStream::SetBookmark() { |
| 143 bookmark_ = pos_; |
| 144 return true; |
| 145 } |
| 146 |
| 147 |
| 148 void GenericStringUtf16CharacterStream::ResetToBookmark() { |
| 149 pos_ = bookmark_; |
| 150 buffer_cursor_ = buffer_; |
| 151 buffer_end_ = buffer_ + FillBuffer(pos_); |
| 152 } |
| 153 |
| 154 |
142 size_t GenericStringUtf16CharacterStream::BufferSeekForward(size_t delta) { | 155 size_t GenericStringUtf16CharacterStream::BufferSeekForward(size_t delta) { |
143 size_t old_pos = pos_; | 156 size_t old_pos = pos_; |
144 pos_ = Min(pos_ + delta, length_); | 157 pos_ = Min(pos_ + delta, length_); |
145 ReadBlock(); | 158 ReadBlock(); |
146 return pos_ - old_pos; | 159 return pos_ - old_pos; |
147 } | 160 } |
148 | 161 |
149 | 162 |
150 size_t GenericStringUtf16CharacterStream::FillBuffer(size_t from_pos) { | 163 size_t GenericStringUtf16CharacterStream::FillBuffer(size_t from_pos) { |
151 if (from_pos >= length_) return 0; | 164 if (from_pos >= length_) return 0; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 } | 453 } |
441 | 454 |
442 | 455 |
443 // ---------------------------------------------------------------------------- | 456 // ---------------------------------------------------------------------------- |
444 // ExternalTwoByteStringUtf16CharacterStream | 457 // ExternalTwoByteStringUtf16CharacterStream |
445 | 458 |
446 ExternalTwoByteStringUtf16CharacterStream:: | 459 ExternalTwoByteStringUtf16CharacterStream:: |
447 ~ExternalTwoByteStringUtf16CharacterStream() { } | 460 ~ExternalTwoByteStringUtf16CharacterStream() { } |
448 | 461 |
449 | 462 |
450 ExternalTwoByteStringUtf16CharacterStream | 463 ExternalTwoByteStringUtf16CharacterStream:: |
451 ::ExternalTwoByteStringUtf16CharacterStream( | 464 ExternalTwoByteStringUtf16CharacterStream( |
452 Handle<ExternalTwoByteString> data, | 465 Handle<ExternalTwoByteString> data, int start_position, |
453 int start_position, | |
454 int end_position) | 466 int end_position) |
455 : Utf16CharacterStream(), | 467 : Utf16CharacterStream(), |
456 source_(data), | 468 source_(data), |
457 raw_data_(data->GetTwoByteData(start_position)) { | 469 raw_data_(data->GetTwoByteData(start_position)), |
| 470 bookmark_(-1) { |
458 buffer_cursor_ = raw_data_, | 471 buffer_cursor_ = raw_data_, |
459 buffer_end_ = raw_data_ + (end_position - start_position); | 472 buffer_end_ = raw_data_ + (end_position - start_position); |
460 pos_ = start_position; | 473 pos_ = start_position; |
461 } | 474 } |
462 | 475 |
| 476 |
| 477 bool ExternalTwoByteStringUtf16CharacterStream::SetBookmark() { |
| 478 bookmark_ = pos_; |
| 479 return true; |
| 480 } |
| 481 |
| 482 |
| 483 void ExternalTwoByteStringUtf16CharacterStream::ResetToBookmark() { |
| 484 DCHECK(bookmark_ != -1); |
| 485 pos_ = bookmark_; |
| 486 buffer_cursor_ = raw_data_ + bookmark_; |
| 487 } |
463 } } // namespace v8::internal | 488 } } // namespace v8::internal |
OLD | NEW |