Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Unified Diff: src/scanner-character-streams.h

Issue 566553002: Add script streaming API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.cc ('k') | src/scanner-character-streams.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner-character-streams.h
diff --git a/src/scanner-character-streams.h b/src/scanner-character-streams.h
index eeb40e260f62727610c52c9591cb62ca231885c9..afca13f1807b0ce167340773ab8f70c852d49aa7 100644
--- a/src/scanner-character-streams.h
+++ b/src/scanner-character-streams.h
@@ -59,6 +59,9 @@ class Utf8ToUtf16CharacterStream: public BufferedUtf16CharacterStream {
Utf8ToUtf16CharacterStream(const byte* data, unsigned length);
virtual ~Utf8ToUtf16CharacterStream();
+ static unsigned CopyChars(uint16_t* dest, unsigned length, const byte* src,
+ unsigned* src_pos, unsigned src_length);
+
protected:
virtual unsigned BufferSeekForward(unsigned delta);
virtual unsigned FillBuffer(unsigned char_position);
@@ -73,6 +76,46 @@ class Utf8ToUtf16CharacterStream: public BufferedUtf16CharacterStream {
};
+// ExternalStreamingStream is a wrapper around an ExternalSourceStream (see
+// include/v8.h) subclass implemented by the embedder.
+class ExternalStreamingStream : public BufferedUtf16CharacterStream {
+ public:
+ ExternalStreamingStream(ScriptCompiler::ExternalSourceStream* source_stream,
+ v8::ScriptCompiler::StreamedSource::Encoding encoding)
+ : source_stream_(source_stream),
+ encoding_(encoding),
+ current_data_(NULL),
+ current_data_offset_(0),
+ current_data_length_(0),
+ utf8_split_char_buffer_length_(0) {}
+
+ virtual ~ExternalStreamingStream() { delete[] current_data_; }
+
+ virtual unsigned BufferSeekForward(unsigned delta) OVERRIDE {
+ // We never need to seek forward when streaming scripts. We only seek
+ // forward when we want to parse a function whose location we already know,
+ // and when streaming, we don't know the locations of anything we haven't
+ // seen yet.
+ UNREACHABLE();
+ return 0;
+ }
+
+ virtual unsigned FillBuffer(unsigned position);
+
+ private:
+ void HandleUtf8SplitCharacters(unsigned* data_in_buffer);
+
+ ScriptCompiler::ExternalSourceStream* source_stream_;
+ v8::ScriptCompiler::StreamedSource::Encoding encoding_;
+ const uint8_t* current_data_;
+ unsigned current_data_offset_;
+ unsigned current_data_length_;
+ // For converting UTF-8 characters which are split across two data chunks.
+ uint8_t utf8_split_char_buffer_[4];
+ unsigned utf8_split_char_buffer_length_;
+};
+
+
// UTF16 buffer to read characters from an external string.
class ExternalTwoByteStringUtf16CharacterStream: public Utf16CharacterStream {
public:
« no previous file with comments | « src/parser.cc ('k') | src/scanner-character-streams.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698