| 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 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 protected: | 23 protected: |
| 24 static const unsigned kBufferSize = 512; | 24 static const unsigned kBufferSize = 512; |
| 25 static const unsigned kPushBackStepSize = 16; | 25 static const unsigned kPushBackStepSize = 16; |
| 26 | 26 |
| 27 virtual unsigned SlowSeekForward(unsigned delta); | 27 virtual unsigned SlowSeekForward(unsigned delta); |
| 28 virtual bool ReadBlock(); | 28 virtual bool ReadBlock(); |
| 29 virtual void SlowPushBack(uc16 character); | 29 virtual void SlowPushBack(uc16 character); |
| 30 | 30 |
| 31 virtual unsigned BufferSeekForward(unsigned delta) = 0; | 31 virtual unsigned BufferSeekForward(unsigned delta) = 0; |
| 32 virtual unsigned FillBuffer(unsigned position, unsigned length) = 0; | 32 virtual unsigned FillBuffer(unsigned position) = 0; |
| 33 | 33 |
| 34 const uc16* pushback_limit_; | 34 const uc16* pushback_limit_; |
| 35 uc16 buffer_[kBufferSize]; | 35 uc16 buffer_[kBufferSize]; |
| 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, | 42 GenericStringUtf16CharacterStream(Handle<String> data, |
| 43 unsigned start_position, | 43 unsigned start_position, |
| 44 unsigned end_position); | 44 unsigned end_position); |
| 45 virtual ~GenericStringUtf16CharacterStream(); | 45 virtual ~GenericStringUtf16CharacterStream(); |
| 46 | 46 |
| 47 protected: | 47 protected: |
| 48 virtual unsigned BufferSeekForward(unsigned delta); | 48 virtual unsigned BufferSeekForward(unsigned delta); |
| 49 virtual unsigned FillBuffer(unsigned position, unsigned length); | 49 virtual unsigned FillBuffer(unsigned position); |
| 50 | 50 |
| 51 Handle<String> string_; | 51 Handle<String> string_; |
| 52 unsigned length_; | 52 unsigned length_; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 | 55 |
| 56 // Utf16 stream based on a literal UTF-8 string. | 56 // Utf16 stream based on a literal UTF-8 string. |
| 57 class Utf8ToUtf16CharacterStream: public BufferedUtf16CharacterStream { | 57 class Utf8ToUtf16CharacterStream: public BufferedUtf16CharacterStream { |
| 58 public: | 58 public: |
| 59 Utf8ToUtf16CharacterStream(const byte* data, unsigned length); | 59 Utf8ToUtf16CharacterStream(const byte* data, unsigned length); |
| 60 virtual ~Utf8ToUtf16CharacterStream(); | 60 virtual ~Utf8ToUtf16CharacterStream(); |
| 61 | 61 |
| 62 protected: | 62 protected: |
| 63 virtual unsigned BufferSeekForward(unsigned delta); | 63 virtual unsigned BufferSeekForward(unsigned delta); |
| 64 virtual unsigned FillBuffer(unsigned char_position, unsigned length); | 64 virtual unsigned FillBuffer(unsigned char_position); |
| 65 void SetRawPosition(unsigned char_position); | 65 void SetRawPosition(unsigned char_position); |
| 66 | 66 |
| 67 const byte* raw_data_; | 67 const byte* raw_data_; |
| 68 unsigned raw_data_length_; // Measured in bytes, not characters. | 68 unsigned raw_data_length_; // Measured in bytes, not characters. |
| 69 unsigned raw_data_pos_; | 69 unsigned raw_data_pos_; |
| 70 // The character position of the character at raw_data[raw_data_pos_]. | 70 // The character position of the character at raw_data[raw_data_pos_]. |
| 71 // Not necessarily the same as pos_. | 71 // Not necessarily the same as pos_. |
| 72 unsigned raw_character_position_; | 72 unsigned raw_character_position_; |
| 73 }; | 73 }; |
| 74 | 74 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 96 // Entire string is read at start. | 96 // Entire string is read at start. |
| 97 return false; | 97 return false; |
| 98 } | 98 } |
| 99 Handle<ExternalTwoByteString> source_; | 99 Handle<ExternalTwoByteString> source_; |
| 100 const uc16* raw_data_; // Pointer to the actual array of characters. | 100 const uc16* raw_data_; // Pointer to the actual array of characters. |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 } } // namespace v8::internal | 103 } } // namespace v8::internal |
| 104 | 104 |
| 105 #endif // V8_SCANNER_CHARACTER_STREAMS_H_ | 105 #endif // V8_SCANNER_CHARACTER_STREAMS_H_ |
| OLD | NEW |