| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_SCANNER_CHARACTER_STREAMS_H_ | 28 #ifndef V8_SCANNER_CHARACTER_STREAMS_H_ |
| 29 #define V8_SCANNER_CHARACTER_STREAMS_H_ | 29 #define V8_SCANNER_CHARACTER_STREAMS_H_ |
| 30 | 30 |
| 31 #include "scanner.h" | 31 #include "scanner.h" |
| 32 | 32 |
| 33 namespace v8 { | 33 namespace v8 { |
| 34 namespace internal { | 34 namespace internal { |
| 35 | 35 |
| 36 |
| 37 #ifndef V8_USE_GENERATED_LEXER |
| 38 |
| 39 |
| 36 // A buffered character stream based on a random access character | 40 // A buffered character stream based on a random access character |
| 37 // source (ReadBlock can be called with pos_ pointing to any position, | 41 // source (ReadBlock can be called with pos_ pointing to any position, |
| 38 // even positions before the current). | 42 // even positions before the current). |
| 39 class BufferedUtf16CharacterStream: public Utf16CharacterStream { | 43 class BufferedUtf16CharacterStream: public Utf16CharacterStream { |
| 40 public: | 44 public: |
| 41 BufferedUtf16CharacterStream(); | 45 BufferedUtf16CharacterStream(); |
| 42 virtual ~BufferedUtf16CharacterStream(); | 46 virtual ~BufferedUtf16CharacterStream(); |
| 43 | 47 |
| 44 virtual void PushBack(uc32 character); | 48 virtual void PushBack(uc32 character); |
| 45 | 49 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 return 0; | 121 return 0; |
| 118 } | 122 } |
| 119 virtual bool ReadBlock() { | 123 virtual bool ReadBlock() { |
| 120 // Entire string is read at start. | 124 // Entire string is read at start. |
| 121 return false; | 125 return false; |
| 122 } | 126 } |
| 123 Handle<ExternalTwoByteString> source_; | 127 Handle<ExternalTwoByteString> source_; |
| 124 const uc16* raw_data_; // Pointer to the actual array of characters. | 128 const uc16* raw_data_; // Pointer to the actual array of characters. |
| 125 }; | 129 }; |
| 126 | 130 |
| 131 |
| 132 #else |
| 133 |
| 134 |
| 135 class Utf8ToUtf16CharacterStream: public Utf16CharacterStream { |
| 136 public: |
| 137 Utf8ToUtf16CharacterStream(const byte* data, unsigned length) |
| 138 : Utf16CharacterStream(kUtf8ToUtf16), |
| 139 data_(reinterpret_cast<const int8_t*>(data)), |
| 140 length_(length) {} |
| 141 |
| 142 const int8_t* const data_; |
| 143 const unsigned length_; |
| 144 }; |
| 145 |
| 146 |
| 147 class GenericStringUtf16CharacterStream: public Utf16CharacterStream { |
| 148 public: |
| 149 GenericStringUtf16CharacterStream(Handle<String> data, |
| 150 unsigned start_position, |
| 151 unsigned end_position) |
| 152 : Utf16CharacterStream(kGenericStringUtf16), |
| 153 data_(data), |
| 154 start_position_(start_position), |
| 155 end_position_(end_position) {} |
| 156 |
| 157 const Handle<String> data_; |
| 158 const unsigned start_position_; |
| 159 const unsigned end_position_; |
| 160 }; |
| 161 |
| 162 |
| 163 class ExternalTwoByteStringUtf16CharacterStream: public Utf16CharacterStream { |
| 164 public: |
| 165 ExternalTwoByteStringUtf16CharacterStream(Handle<ExternalTwoByteString> data, |
| 166 int start_position, |
| 167 int end_position) |
| 168 : Utf16CharacterStream(kExternalTwoByteStringUtf16), |
| 169 data_(data), |
| 170 start_position_(start_position), |
| 171 end_position_(end_position) {} |
| 172 |
| 173 const Handle<ExternalTwoByteString> data_; |
| 174 const int start_position_; |
| 175 const int end_position_; |
| 176 }; |
| 177 |
| 178 |
| 179 #endif |
| 180 |
| 181 |
| 127 } } // namespace v8::internal | 182 } } // namespace v8::internal |
| 128 | 183 |
| 129 #endif // V8_SCANNER_CHARACTER_STREAMS_H_ | 184 #endif // V8_SCANNER_CHARACTER_STREAMS_H_ |
| OLD | NEW |