| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 28 matching lines...) Expand all Loading... |
| 39 // BufferedUtf16CharacterStreams | 39 // BufferedUtf16CharacterStreams |
| 40 | 40 |
| 41 BufferedUtf16CharacterStream::BufferedUtf16CharacterStream() | 41 BufferedUtf16CharacterStream::BufferedUtf16CharacterStream() |
| 42 : Utf16CharacterStream(), | 42 : Utf16CharacterStream(), |
| 43 pushback_limit_(NULL) { | 43 pushback_limit_(NULL) { |
| 44 // Initialize buffer as being empty. First read will fill the buffer. | 44 // Initialize buffer as being empty. First read will fill the buffer. |
| 45 buffer_cursor_ = buffer_; | 45 buffer_cursor_ = buffer_; |
| 46 buffer_end_ = buffer_; | 46 buffer_end_ = buffer_; |
| 47 } | 47 } |
| 48 | 48 |
| 49 |
| 49 BufferedUtf16CharacterStream::~BufferedUtf16CharacterStream() { } | 50 BufferedUtf16CharacterStream::~BufferedUtf16CharacterStream() { } |
| 50 | 51 |
| 51 void BufferedUtf16CharacterStream::PushBack(uc32 character) { | 52 void BufferedUtf16CharacterStream::PushBack(uc32 character) { |
| 52 if (character == kEndOfInput) { | 53 if (character == kEndOfInput) { |
| 53 pos_--; | 54 pos_--; |
| 54 return; | 55 return; |
| 55 } | 56 } |
| 56 if (pushback_limit_ == NULL && buffer_cursor_ > buffer_) { | 57 if (pushback_limit_ == NULL && buffer_cursor_ > buffer_) { |
| 57 // buffer_ is writable, buffer_cursor_ is const pointer. | 58 // buffer_ is writable, buffer_cursor_ is const pointer. |
| 58 buffer_[--buffer_cursor_ - buffer_] = static_cast<uc16>(character); | 59 buffer_[--buffer_cursor_ - buffer_] = static_cast<uc16>(character); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 107 } |
| 107 | 108 |
| 108 | 109 |
| 109 unsigned BufferedUtf16CharacterStream::SlowSeekForward(unsigned delta) { | 110 unsigned BufferedUtf16CharacterStream::SlowSeekForward(unsigned delta) { |
| 110 // Leave pushback mode (i.e., ignore that there might be valid data | 111 // Leave pushback mode (i.e., ignore that there might be valid data |
| 111 // in the buffer before the pushback_limit_ point). | 112 // in the buffer before the pushback_limit_ point). |
| 112 pushback_limit_ = NULL; | 113 pushback_limit_ = NULL; |
| 113 return BufferSeekForward(delta); | 114 return BufferSeekForward(delta); |
| 114 } | 115 } |
| 115 | 116 |
| 117 |
| 116 // ---------------------------------------------------------------------------- | 118 // ---------------------------------------------------------------------------- |
| 117 // GenericStringUtf16CharacterStream | 119 // GenericStringUtf16CharacterStream |
| 118 | 120 |
| 119 | 121 |
| 120 GenericStringUtf16CharacterStream::GenericStringUtf16CharacterStream( | 122 GenericStringUtf16CharacterStream::GenericStringUtf16CharacterStream( |
| 121 Handle<String> data, | 123 Handle<String> data, |
| 122 unsigned start_position, | 124 unsigned start_position, |
| 123 unsigned end_position) | 125 unsigned end_position) |
| 124 : string_(data), | 126 : string_(data), |
| 125 length_(end_position) { | 127 length_(end_position) { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 int end_position) | 316 int end_position) |
| 315 : Utf16CharacterStream(), | 317 : Utf16CharacterStream(), |
| 316 source_(data), | 318 source_(data), |
| 317 raw_data_(data->GetTwoByteData(start_position)) { | 319 raw_data_(data->GetTwoByteData(start_position)) { |
| 318 buffer_cursor_ = raw_data_, | 320 buffer_cursor_ = raw_data_, |
| 319 buffer_end_ = raw_data_ + (end_position - start_position); | 321 buffer_end_ = raw_data_ + (end_position - start_position); |
| 320 pos_ = start_position; | 322 pos_ = start_position; |
| 321 } | 323 } |
| 322 | 324 |
| 323 } } // namespace v8::internal | 325 } } // namespace v8::internal |
| OLD | NEW |