| 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 "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #include "scanner-character-streams.h" | 7 #include "scanner-character-streams.h" |
| 8 | 8 |
| 9 #include "handles.h" | 9 #include "handles.h" |
| 10 #include "unicode-inl.h" | 10 #include "unicode-inl.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 } | 277 } |
| 278 | 278 |
| 279 | 279 |
| 280 // ---------------------------------------------------------------------------- | 280 // ---------------------------------------------------------------------------- |
| 281 // ExternalTwoByteStringUtf16CharacterStream | 281 // ExternalTwoByteStringUtf16CharacterStream |
| 282 | 282 |
| 283 ExternalTwoByteStringUtf16CharacterStream:: | 283 ExternalTwoByteStringUtf16CharacterStream:: |
| 284 ~ExternalTwoByteStringUtf16CharacterStream() { } | 284 ~ExternalTwoByteStringUtf16CharacterStream() { } |
| 285 | 285 |
| 286 | 286 |
| 287 ExternalTwoByteStringUtf16CharacterStream | 287 ExternalTwoByteStringUtf16CharacterStream:: |
| 288 ::ExternalTwoByteStringUtf16CharacterStream( | 288 ExternalTwoByteStringUtf16CharacterStream(const uint16_t* raw_data, |
| 289 Handle<ExternalTwoByteString> data, | 289 int start_position, |
| 290 int start_position, | 290 int end_position) |
| 291 int end_position) | 291 : Utf16CharacterStream(), raw_data_(raw_data + start_position) { |
| 292 : Utf16CharacterStream(), | 292 buffer_cursor_ = raw_data_; |
| 293 source_(data), | |
| 294 raw_data_(data->GetTwoByteData(start_position)) { | |
| 295 buffer_cursor_ = raw_data_, | |
| 296 buffer_end_ = raw_data_ + (end_position - start_position); | 293 buffer_end_ = raw_data_ + (end_position - start_position); |
| 297 pos_ = start_position; | 294 pos_ = start_position; |
| 298 } | 295 } |
| 299 | 296 |
| 297 |
| 298 // ---------------------------------------------------------------------------- |
| 299 // ExternalOneByteStringUtf16CharacterStream |
| 300 |
| 301 ExternalOneByteStringUtf16CharacterStream:: |
| 302 ExternalOneByteStringUtf16CharacterStream(const uint8_t* raw_data, |
| 303 int start_position, |
| 304 int end_position) |
| 305 : raw_data_(raw_data + start_position), |
| 306 length_(end_position) { |
| 307 pos_ = start_position; |
| 308 } |
| 309 |
| 310 |
| 311 ExternalOneByteStringUtf16CharacterStream:: |
| 312 ~ExternalOneByteStringUtf16CharacterStream() {} |
| 313 |
| 314 |
| 315 unsigned ExternalOneByteStringUtf16CharacterStream::BufferSeekForward( |
| 316 unsigned delta) { |
| 317 unsigned old_pos = pos_; |
| 318 pos_ = Min(pos_ + delta, length_); |
| 319 ReadBlock(); |
| 320 return pos_ - old_pos; |
| 321 } |
| 322 |
| 323 |
| 324 unsigned ExternalOneByteStringUtf16CharacterStream::FillBuffer( |
| 325 unsigned from_pos, unsigned length) { |
| 326 if (from_pos >= length_) return 0; |
| 327 if (from_pos + length > length_) { |
| 328 length = length_ - from_pos; |
| 329 } |
| 330 CopyChars(buffer_, raw_data_ + from_pos, length); |
| 331 return length; |
| 332 } |
| 333 |
| 334 |
| 300 } } // namespace v8::internal | 335 } } // namespace v8::internal |
| OLD | NEW |