| 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/parsing/scanner-character-streams.h" | 5 #include "src/parsing/scanner-character-streams.h" |
| 6 | 6 |
| 7 #include "include/v8.h" | 7 #include "include/v8.h" |
| 8 #include "src/globals.h" | 8 #include "src/globals.h" |
| 9 #include "src/handles.h" | 9 #include "src/handles.h" |
| 10 #include "src/list-inl.h" // TODO(mstarzinger): Temporary cycle breaker! | 10 #include "src/list-inl.h" // TODO(mstarzinger): Temporary cycle breaker! |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 ReadBlock(); | 186 ReadBlock(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 | 189 |
| 190 Utf8ToUtf16CharacterStream::~Utf8ToUtf16CharacterStream() { } | 190 Utf8ToUtf16CharacterStream::~Utf8ToUtf16CharacterStream() { } |
| 191 | 191 |
| 192 | 192 |
| 193 size_t Utf8ToUtf16CharacterStream::CopyChars(uint16_t* dest, size_t length, | 193 size_t Utf8ToUtf16CharacterStream::CopyChars(uint16_t* dest, size_t length, |
| 194 const byte* src, size_t* src_pos, | 194 const byte* src, size_t* src_pos, |
| 195 size_t src_length) { | 195 size_t src_length) { |
| 196 static const unibrow::uchar kMaxUtf16Character = 0xffff; | 196 static const unibrow::uchar kMaxUtf16Character = |
| 197 unibrow::Utf16::kMaxNonSurrogateCharCode; |
| 197 size_t i = 0; | 198 size_t i = 0; |
| 198 // Because of the UTF-16 lead and trail surrogates, we stop filling the buffer | 199 // Because of the UTF-16 lead and trail surrogates, we stop filling the buffer |
| 199 // one character early (in the normal case), because we need to have at least | 200 // one character early (in the normal case), because we need to have at least |
| 200 // two free spaces in the buffer to be sure that the next character will fit. | 201 // two free spaces in the buffer to be sure that the next character will fit. |
| 201 while (i < length - 1) { | 202 while (i < length - 1) { |
| 202 if (*src_pos == src_length) break; | 203 if (*src_pos == src_length) break; |
| 203 unibrow::uchar c = src[*src_pos]; | 204 unibrow::uchar c = src[*src_pos]; |
| 204 if (c <= unibrow::Utf8::kMaxOneByteChar) { | 205 if (c <= unibrow::Utf8::kMaxOneByteChar) { |
| 205 *src_pos = *src_pos + 1; | 206 *src_pos = *src_pos + 1; |
| 206 } else { | 207 } else { |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 } | 580 } |
| 580 | 581 |
| 581 | 582 |
| 582 void ExternalTwoByteStringUtf16CharacterStream::ResetToBookmark() { | 583 void ExternalTwoByteStringUtf16CharacterStream::ResetToBookmark() { |
| 583 DCHECK(bookmark_ != kNoBookmark); | 584 DCHECK(bookmark_ != kNoBookmark); |
| 584 pos_ = bookmark_; | 585 pos_ = bookmark_; |
| 585 buffer_cursor_ = raw_data_ + bookmark_; | 586 buffer_cursor_ = raw_data_ + bookmark_; |
| 586 } | 587 } |
| 587 } // namespace internal | 588 } // namespace internal |
| 588 } // namespace v8 | 589 } // namespace v8 |
| OLD | NEW |