| 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_SCANNER_CHARACTER_STREAMS_H_ | 5 #ifndef V8_SCANNER_CHARACTER_STREAMS_H_ |
| 6 #define V8_SCANNER_CHARACTER_STREAMS_H_ | 6 #define V8_SCANNER_CHARACTER_STREAMS_H_ |
| 7 | 7 |
| 8 #include "src/scanner.h" | 8 #include "src/scanner.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 | 38 |
| 39 // Generic string stream. | 39 // Generic string stream. |
| 40 class GenericStringUtf16CharacterStream: public BufferedUtf16CharacterStream { | 40 class GenericStringUtf16CharacterStream: public BufferedUtf16CharacterStream { |
| 41 public: | 41 public: |
| 42 GenericStringUtf16CharacterStream(Handle<String> data, size_t start_position, | 42 GenericStringUtf16CharacterStream(Handle<String> data, size_t start_position, |
| 43 size_t end_position); | 43 size_t end_position); |
| 44 virtual ~GenericStringUtf16CharacterStream(); | 44 virtual ~GenericStringUtf16CharacterStream(); |
| 45 | 45 |
| 46 virtual bool SetBookmark(); |
| 47 virtual void ResetToBookmark(); |
| 48 |
| 46 protected: | 49 protected: |
| 47 virtual size_t BufferSeekForward(size_t delta); | 50 virtual size_t BufferSeekForward(size_t delta); |
| 48 virtual size_t FillBuffer(size_t position); | 51 virtual size_t FillBuffer(size_t position); |
| 49 | 52 |
| 50 Handle<String> string_; | 53 Handle<String> string_; |
| 51 size_t length_; | 54 size_t length_; |
| 55 size_t bookmark_; |
| 52 }; | 56 }; |
| 53 | 57 |
| 54 | 58 |
| 55 // Utf16 stream based on a literal UTF-8 string. | 59 // Utf16 stream based on a literal UTF-8 string. |
| 56 class Utf8ToUtf16CharacterStream: public BufferedUtf16CharacterStream { | 60 class Utf8ToUtf16CharacterStream: public BufferedUtf16CharacterStream { |
| 57 public: | 61 public: |
| 58 Utf8ToUtf16CharacterStream(const byte* data, size_t length); | 62 Utf8ToUtf16CharacterStream(const byte* data, size_t length); |
| 59 virtual ~Utf8ToUtf16CharacterStream(); | 63 virtual ~Utf8ToUtf16CharacterStream(); |
| 60 | 64 |
| 61 static size_t CopyChars(uint16_t* dest, size_t length, const byte* src, | 65 static size_t CopyChars(uint16_t* dest, size_t length, const byte* src, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 int start_position, | 126 int start_position, |
| 123 int end_position); | 127 int end_position); |
| 124 virtual ~ExternalTwoByteStringUtf16CharacterStream(); | 128 virtual ~ExternalTwoByteStringUtf16CharacterStream(); |
| 125 | 129 |
| 126 virtual void PushBack(uc32 character) { | 130 virtual void PushBack(uc32 character) { |
| 127 DCHECK(buffer_cursor_ > raw_data_); | 131 DCHECK(buffer_cursor_ > raw_data_); |
| 128 buffer_cursor_--; | 132 buffer_cursor_--; |
| 129 pos_--; | 133 pos_--; |
| 130 } | 134 } |
| 131 | 135 |
| 136 virtual bool SetBookmark(); |
| 137 virtual void ResetToBookmark(); |
| 138 |
| 132 protected: | 139 protected: |
| 133 virtual size_t SlowSeekForward(size_t delta) { | 140 virtual size_t SlowSeekForward(size_t delta) { |
| 134 // Fast case always handles seeking. | 141 // Fast case always handles seeking. |
| 135 return 0; | 142 return 0; |
| 136 } | 143 } |
| 137 virtual bool ReadBlock() { | 144 virtual bool ReadBlock() { |
| 138 // Entire string is read at start. | 145 // Entire string is read at start. |
| 139 return false; | 146 return false; |
| 140 } | 147 } |
| 141 Handle<ExternalTwoByteString> source_; | 148 Handle<ExternalTwoByteString> source_; |
| 142 const uc16* raw_data_; // Pointer to the actual array of characters. | 149 const uc16* raw_data_; // Pointer to the actual array of characters. |
| 150 |
| 151 private: |
| 152 static const size_t kNoBookmark = -1; |
| 153 |
| 154 size_t bookmark_; |
| 143 }; | 155 }; |
| 144 | 156 |
| 145 } } // namespace v8::internal | 157 } } // namespace v8::internal |
| 146 | 158 |
| 147 #endif // V8_SCANNER_CHARACTER_STREAMS_H_ | 159 #endif // V8_SCANNER_CHARACTER_STREAMS_H_ |
| OLD | NEW |