| 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 #ifndef V8_PARSING_SCANNER_CHARACTER_STREAMS_H_ | 5 #ifndef V8_PARSING_SCANNER_CHARACTER_STREAMS_H_ |
| 6 #define V8_PARSING_SCANNER_CHARACTER_STREAMS_H_ | 6 #define V8_PARSING_SCANNER_CHARACTER_STREAMS_H_ |
| 7 | 7 |
| 8 #include "src/handles.h" | 8 #include "src/handles.h" |
| 9 #include "src/parsing/scanner.h" | 9 #include "src/parsing/scanner.h" |
| 10 #include "src/vector.h" | 10 #include "src/vector.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // UTF16 buffer to read characters from an external string. | 151 // UTF16 buffer to read characters from an external string. |
| 152 class ExternalTwoByteStringUtf16CharacterStream: public Utf16CharacterStream { | 152 class ExternalTwoByteStringUtf16CharacterStream: public Utf16CharacterStream { |
| 153 public: | 153 public: |
| 154 ExternalTwoByteStringUtf16CharacterStream(Handle<ExternalTwoByteString> data, | 154 ExternalTwoByteStringUtf16CharacterStream(Handle<ExternalTwoByteString> data, |
| 155 int start_position, | 155 int start_position, |
| 156 int end_position); | 156 int end_position); |
| 157 ~ExternalTwoByteStringUtf16CharacterStream() override; | 157 ~ExternalTwoByteStringUtf16CharacterStream() override; |
| 158 | 158 |
| 159 void PushBack(uc32 character) override { | 159 void PushBack(uc32 character) override { |
| 160 DCHECK(buffer_cursor_ > raw_data_); | 160 DCHECK(buffer_cursor_ > raw_data_); |
| 161 buffer_cursor_--; | |
| 162 pos_--; | 161 pos_--; |
| 162 if (character != kEndOfInput) { |
| 163 buffer_cursor_--; |
| 164 } |
| 163 } | 165 } |
| 164 | 166 |
| 165 bool SetBookmark() override; | 167 bool SetBookmark() override; |
| 166 void ResetToBookmark() override; | 168 void ResetToBookmark() override; |
| 167 | 169 |
| 168 protected: | 170 protected: |
| 169 size_t SlowSeekForward(size_t delta) override { | 171 size_t SlowSeekForward(size_t delta) override { |
| 170 // Fast case always handles seeking. | 172 // Fast case always handles seeking. |
| 171 return 0; | 173 return 0; |
| 172 } | 174 } |
| 173 bool ReadBlock() override { | 175 bool ReadBlock() override { |
| 174 // Entire string is read at start. | 176 // Entire string is read at start. |
| 175 return false; | 177 return false; |
| 176 } | 178 } |
| 177 Handle<ExternalTwoByteString> source_; | 179 Handle<ExternalTwoByteString> source_; |
| 178 const uc16* raw_data_; // Pointer to the actual array of characters. | 180 const uc16* raw_data_; // Pointer to the actual array of characters. |
| 179 | 181 |
| 180 private: | 182 private: |
| 181 static const size_t kNoBookmark = -1; | 183 static const size_t kNoBookmark = -1; |
| 182 | 184 |
| 183 size_t bookmark_; | 185 size_t bookmark_; |
| 184 }; | 186 }; |
| 185 | 187 |
| 186 } // namespace internal | 188 } // namespace internal |
| 187 } // namespace v8 | 189 } // namespace v8 |
| 188 | 190 |
| 189 #endif // V8_PARSING_SCANNER_CHARACTER_STREAMS_H_ | 191 #endif // V8_PARSING_SCANNER_CHARACTER_STREAMS_H_ |
| OLD | NEW |