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