| 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 "scanner.h" | 8 #include "scanner.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 75 | 75 |
| 76 // UTF16 buffer to read characters from an external string. | 76 // UTF16 buffer to read characters from an external two byte (UTF-16) |
| 77 // string. The caller is responsible for keeping the memory alive. |
| 77 class ExternalTwoByteStringUtf16CharacterStream: public Utf16CharacterStream { | 78 class ExternalTwoByteStringUtf16CharacterStream: public Utf16CharacterStream { |
| 78 public: | 79 public: |
| 79 ExternalTwoByteStringUtf16CharacterStream(Handle<ExternalTwoByteString> data, | 80 ExternalTwoByteStringUtf16CharacterStream(const uint16_t* raw_data, |
| 80 int start_position, | 81 int start_position, |
| 81 int end_position); | 82 int end_position); |
| 82 virtual ~ExternalTwoByteStringUtf16CharacterStream(); | 83 virtual ~ExternalTwoByteStringUtf16CharacterStream(); |
| 83 | 84 |
| 84 virtual void PushBack(uc32 character) { | 85 virtual void PushBack(uc32 character) { |
| 85 ASSERT(buffer_cursor_ > raw_data_); | 86 ASSERT(buffer_cursor_ > raw_data_); |
| 86 buffer_cursor_--; | 87 buffer_cursor_--; |
| 87 pos_--; | 88 pos_--; |
| 88 } | 89 } |
| 89 | 90 |
| 90 protected: | 91 protected: |
| 91 virtual unsigned SlowSeekForward(unsigned delta) { | 92 virtual unsigned SlowSeekForward(unsigned delta) { |
| 92 // Fast case always handles seeking. | 93 // Fast case always handles seeking. |
| 93 return 0; | 94 return 0; |
| 94 } | 95 } |
| 95 virtual bool ReadBlock() { | 96 virtual bool ReadBlock() { |
| 96 // Entire string is read at start. | 97 // Entire string is read at start. |
| 97 return false; | 98 return false; |
| 98 } | 99 } |
| 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 |
| 104 // UTF16 buffer to read characters from an external one byte (latin1) |
| 105 // string. Note that "ascii" in ExternalAsciiString is actually latin1. The |
| 106 // caller is responsible for keeping the memory alive. |
| 107 class ExternalOneByteStringUtf16CharacterStream |
| 108 : public BufferedUtf16CharacterStream { |
| 109 public: |
| 110 ExternalOneByteStringUtf16CharacterStream(const uint8_t* raw_data, |
| 111 int start_position, |
| 112 int end_position); |
| 113 virtual ~ExternalOneByteStringUtf16CharacterStream(); |
| 114 |
| 115 protected: |
| 116 virtual unsigned BufferSeekForward(unsigned delta); |
| 117 virtual unsigned FillBuffer(unsigned position, unsigned length); |
| 118 |
| 119 const uint8_t* raw_data_; // Pointer to the actual array of characters. |
| 120 unsigned length_; |
| 121 }; |
| 122 |
| 103 } } // namespace v8::internal | 123 } } // namespace v8::internal |
| 104 | 124 |
| 105 #endif // V8_SCANNER_CHARACTER_STREAMS_H_ | 125 #endif // V8_SCANNER_CHARACTER_STREAMS_H_ |
| OLD | NEW |