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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // include/v8.h) subclass implemented by the embedder. | 85 // include/v8.h) subclass implemented by the embedder. |
86 class ExternalStreamingStream : public BufferedUtf16CharacterStream { | 86 class ExternalStreamingStream : public BufferedUtf16CharacterStream { |
87 public: | 87 public: |
88 ExternalStreamingStream(ScriptCompiler::ExternalSourceStream* source_stream, | 88 ExternalStreamingStream(ScriptCompiler::ExternalSourceStream* source_stream, |
89 v8::ScriptCompiler::StreamedSource::Encoding encoding) | 89 v8::ScriptCompiler::StreamedSource::Encoding encoding) |
90 : source_stream_(source_stream), | 90 : source_stream_(source_stream), |
91 encoding_(encoding), | 91 encoding_(encoding), |
92 current_data_(NULL), | 92 current_data_(NULL), |
93 current_data_offset_(0), | 93 current_data_offset_(0), |
94 current_data_length_(0), | 94 current_data_length_(0), |
95 utf8_split_char_buffer_length_(0) {} | 95 utf8_split_char_buffer_length_(0), |
| 96 bookmark_(0) {} |
96 | 97 |
97 virtual ~ExternalStreamingStream() { delete[] current_data_; } | 98 virtual ~ExternalStreamingStream() { |
| 99 delete[] current_data_; |
| 100 bookmark_buffer_.Dispose(); |
| 101 bookmark_data_.Dispose(); |
| 102 } |
98 | 103 |
99 size_t BufferSeekForward(size_t delta) override { | 104 size_t BufferSeekForward(size_t delta) override { |
100 // We never need to seek forward when streaming scripts. We only seek | 105 // We never need to seek forward when streaming scripts. We only seek |
101 // forward when we want to parse a function whose location we already know, | 106 // forward when we want to parse a function whose location we already know, |
102 // and when streaming, we don't know the locations of anything we haven't | 107 // and when streaming, we don't know the locations of anything we haven't |
103 // seen yet. | 108 // seen yet. |
104 UNREACHABLE(); | 109 UNREACHABLE(); |
105 return 0; | 110 return 0; |
106 } | 111 } |
107 | 112 |
108 size_t FillBuffer(size_t position) override; | 113 size_t FillBuffer(size_t position) override; |
109 | 114 |
| 115 virtual bool SetBookmark() override; |
| 116 virtual void ResetToBookmark() override; |
| 117 |
110 private: | 118 private: |
111 void HandleUtf8SplitCharacters(size_t* data_in_buffer); | 119 void HandleUtf8SplitCharacters(size_t* data_in_buffer); |
| 120 void FlushCurrent(); |
112 | 121 |
113 ScriptCompiler::ExternalSourceStream* source_stream_; | 122 ScriptCompiler::ExternalSourceStream* source_stream_; |
114 v8::ScriptCompiler::StreamedSource::Encoding encoding_; | 123 v8::ScriptCompiler::StreamedSource::Encoding encoding_; |
115 const uint8_t* current_data_; | 124 const uint8_t* current_data_; |
116 size_t current_data_offset_; | 125 size_t current_data_offset_; |
117 size_t current_data_length_; | 126 size_t current_data_length_; |
118 // For converting UTF-8 characters which are split across two data chunks. | 127 // For converting UTF-8 characters which are split across two data chunks. |
119 uint8_t utf8_split_char_buffer_[4]; | 128 uint8_t utf8_split_char_buffer_[4]; |
120 size_t utf8_split_char_buffer_length_; | 129 size_t utf8_split_char_buffer_length_; |
| 130 |
| 131 // Bookmark support. See comments in ExternalStreamingStream::SetBookmark |
| 132 // for additional details. |
| 133 size_t bookmark_; |
| 134 Vector<uint16_t> bookmark_buffer_; |
| 135 Vector<uint8_t> bookmark_data_; |
121 }; | 136 }; |
122 | 137 |
123 | 138 |
124 // UTF16 buffer to read characters from an external string. | 139 // UTF16 buffer to read characters from an external string. |
125 class ExternalTwoByteStringUtf16CharacterStream: public Utf16CharacterStream { | 140 class ExternalTwoByteStringUtf16CharacterStream: public Utf16CharacterStream { |
126 public: | 141 public: |
127 ExternalTwoByteStringUtf16CharacterStream(Handle<ExternalTwoByteString> data, | 142 ExternalTwoByteStringUtf16CharacterStream(Handle<ExternalTwoByteString> data, |
128 int start_position, | 143 int start_position, |
129 int end_position); | 144 int end_position); |
130 virtual ~ExternalTwoByteStringUtf16CharacterStream(); | 145 virtual ~ExternalTwoByteStringUtf16CharacterStream(); |
(...skipping 21 matching lines...) Expand all Loading... |
152 | 167 |
153 private: | 168 private: |
154 static const size_t kNoBookmark = -1; | 169 static const size_t kNoBookmark = -1; |
155 | 170 |
156 size_t bookmark_; | 171 size_t bookmark_; |
157 }; | 172 }; |
158 | 173 |
159 } } // namespace v8::internal | 174 } } // namespace v8::internal |
160 | 175 |
161 #endif // V8_SCANNER_CHARACTER_STREAMS_H_ | 176 #endif // V8_SCANNER_CHARACTER_STREAMS_H_ |
OLD | NEW |