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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 return source_stream_->SetBookmark(); | 427 return source_stream_->SetBookmark(); |
428 } | 428 } |
429 | 429 |
430 | 430 |
431 void ExternalStreamingStream::ResetToBookmark() { | 431 void ExternalStreamingStream::ResetToBookmark() { |
432 source_stream_->ResetToBookmark(); | 432 source_stream_->ResetToBookmark(); |
433 FlushCurrent(); | 433 FlushCurrent(); |
434 | 434 |
435 pos_ = bookmark_; | 435 pos_ = bookmark_; |
436 | 436 |
437 // current_data_ can point to bookmark_data_'s buffer. | 437 // bookmark_data_* => current_data_* |
438 current_data_ = bookmark_data_.start(); | 438 // (current_data_ assumes ownership of its memory.) |
| 439 uint8_t* data = new uint8_t[bookmark_data_.length()]; |
439 current_data_offset_ = 0; | 440 current_data_offset_ = 0; |
440 current_data_length_ = bookmark_data_.length(); | 441 current_data_length_ = bookmark_data_.length(); |
| 442 CopyCharsUnsigned(data, bookmark_data_.begin(), bookmark_data_.length()); |
| 443 delete[] current_data_; |
| 444 current_data_ = data; |
441 | 445 |
442 // bookmark_buffer_ needs to be copied to buffer_. | 446 // bookmark_buffer_ needs to be copied to buffer_. |
443 CopyCharsUnsigned(buffer_, bookmark_buffer_.begin(), | 447 CopyCharsUnsigned(buffer_, bookmark_buffer_.begin(), |
444 bookmark_buffer_.length()); | 448 bookmark_buffer_.length()); |
445 buffer_cursor_ = buffer_; | 449 buffer_cursor_ = buffer_; |
446 buffer_end_ = buffer_ + bookmark_buffer_.length(); | 450 buffer_end_ = buffer_ + bookmark_buffer_.length(); |
447 | 451 |
448 // utf8 split char buffer | 452 // utf8 split char buffer |
449 utf8_split_char_buffer_length_ = bookmark_utf8_split_char_buffer_length_; | 453 utf8_split_char_buffer_length_ = bookmark_utf8_split_char_buffer_length_; |
450 for (size_t i = 0; i < bookmark_utf8_split_char_buffer_length_; i++) { | 454 for (size_t i = 0; i < bookmark_utf8_split_char_buffer_length_; i++) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 return true; | 553 return true; |
550 } | 554 } |
551 | 555 |
552 | 556 |
553 void ExternalTwoByteStringUtf16CharacterStream::ResetToBookmark() { | 557 void ExternalTwoByteStringUtf16CharacterStream::ResetToBookmark() { |
554 DCHECK(bookmark_ != kNoBookmark); | 558 DCHECK(bookmark_ != kNoBookmark); |
555 pos_ = bookmark_; | 559 pos_ = bookmark_; |
556 buffer_cursor_ = raw_data_ + bookmark_; | 560 buffer_cursor_ = raw_data_ + bookmark_; |
557 } | 561 } |
558 } } // namespace v8::internal | 562 } } // namespace v8::internal |
OLD | NEW |