| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // include/v8.h) subclass implemented by the embedder. | 80 // include/v8.h) subclass implemented by the embedder. |
| 81 class ExternalStreamingStream : public BufferedUtf16CharacterStream { | 81 class ExternalStreamingStream : public BufferedUtf16CharacterStream { |
| 82 public: | 82 public: |
| 83 ExternalStreamingStream(ScriptCompiler::ExternalSourceStream* source_stream, | 83 ExternalStreamingStream(ScriptCompiler::ExternalSourceStream* source_stream, |
| 84 v8::ScriptCompiler::StreamedSource::Encoding encoding) | 84 v8::ScriptCompiler::StreamedSource::Encoding encoding) |
| 85 : source_stream_(source_stream), | 85 : source_stream_(source_stream), |
| 86 encoding_(encoding), | 86 encoding_(encoding), |
| 87 current_data_(NULL), | 87 current_data_(NULL), |
| 88 current_data_offset_(0), | 88 current_data_offset_(0), |
| 89 current_data_length_(0), | 89 current_data_length_(0), |
| 90 utf8_split_char_buffer_length_(0) {} | 90 utf8_split_char_buffer_length_(0), |
| 91 first_chunk_(true) {} |
| 91 | 92 |
| 92 virtual ~ExternalStreamingStream() { delete[] current_data_; } | 93 virtual ~ExternalStreamingStream() { delete[] current_data_; } |
| 93 | 94 |
| 94 virtual unsigned BufferSeekForward(unsigned delta) OVERRIDE { | 95 virtual unsigned BufferSeekForward(unsigned delta) OVERRIDE { |
| 95 // We never need to seek forward when streaming scripts. We only seek | 96 // We never need to seek forward when streaming scripts. We only seek |
| 96 // forward when we want to parse a function whose location we already know, | 97 // forward when we want to parse a function whose location we already know, |
| 97 // and when streaming, we don't know the locations of anything we haven't | 98 // and when streaming, we don't know the locations of anything we haven't |
| 98 // seen yet. | 99 // seen yet. |
| 99 UNREACHABLE(); | 100 UNREACHABLE(); |
| 100 return 0; | 101 return 0; |
| 101 } | 102 } |
| 102 | 103 |
| 103 virtual unsigned FillBuffer(unsigned position) OVERRIDE; | 104 virtual unsigned FillBuffer(unsigned position) OVERRIDE; |
| 104 | 105 |
| 105 private: | 106 private: |
| 106 void HandleUtf8SplitCharacters(unsigned* data_in_buffer); | 107 void HandleUtf8SplitCharacters(unsigned* data_in_buffer); |
| 107 | 108 |
| 108 ScriptCompiler::ExternalSourceStream* source_stream_; | 109 ScriptCompiler::ExternalSourceStream* source_stream_; |
| 109 v8::ScriptCompiler::StreamedSource::Encoding encoding_; | 110 v8::ScriptCompiler::StreamedSource::Encoding encoding_; |
| 110 const uint8_t* current_data_; | 111 const uint8_t* current_data_; |
| 111 unsigned current_data_offset_; | 112 unsigned current_data_offset_; |
| 112 unsigned current_data_length_; | 113 unsigned current_data_length_; |
| 113 // For converting UTF-8 characters which are split across two data chunks. | 114 // For converting UTF-8 characters which are split across two data chunks. |
| 114 uint8_t utf8_split_char_buffer_[4]; | 115 uint8_t utf8_split_char_buffer_[4]; |
| 115 unsigned utf8_split_char_buffer_length_; | 116 unsigned utf8_split_char_buffer_length_; |
| 117 bool first_chunk_; |
| 116 }; | 118 }; |
| 117 | 119 |
| 118 | 120 |
| 119 // UTF16 buffer to read characters from an external string. | 121 // UTF16 buffer to read characters from an external string. |
| 120 class ExternalTwoByteStringUtf16CharacterStream: public Utf16CharacterStream { | 122 class ExternalTwoByteStringUtf16CharacterStream: public Utf16CharacterStream { |
| 121 public: | 123 public: |
| 122 ExternalTwoByteStringUtf16CharacterStream(Handle<ExternalTwoByteString> data, | 124 ExternalTwoByteStringUtf16CharacterStream(Handle<ExternalTwoByteString> data, |
| 123 int start_position, | 125 int start_position, |
| 124 int end_position); | 126 int end_position); |
| 125 virtual ~ExternalTwoByteStringUtf16CharacterStream(); | 127 virtual ~ExternalTwoByteStringUtf16CharacterStream(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 139 // Entire string is read at start. | 141 // Entire string is read at start. |
| 140 return false; | 142 return false; |
| 141 } | 143 } |
| 142 Handle<ExternalTwoByteString> source_; | 144 Handle<ExternalTwoByteString> source_; |
| 143 const uc16* raw_data_; // Pointer to the actual array of characters. | 145 const uc16* raw_data_; // Pointer to the actual array of characters. |
| 144 }; | 146 }; |
| 145 | 147 |
| 146 } } // namespace v8::internal | 148 } } // namespace v8::internal |
| 147 | 149 |
| 148 #endif // V8_SCANNER_CHARACTER_STREAMS_H_ | 150 #endif // V8_SCANNER_CHARACTER_STREAMS_H_ |
| OLD | NEW |