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

Side by Side Diff: src/parsing/scanner-character-streams.h

Issue 1439693002: [runtime] Support Proxy setPrototypeOf trap (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2015-11-09_new_Proxy_1417063011
Patch Set: merging with master Created 5 years 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 unified diff | Download patch
« no previous file with comments | « src/parsing/scanner.cc ('k') | src/parsing/scanner-character-streams.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_PARSING_SCANNER_CHARACTER_STREAMS_H_ 5 #ifndef V8_PARSING_SCANNER_CHARACTER_STREAMS_H_
6 #define V8_PARSING_SCANNER_CHARACTER_STREAMS_H_ 6 #define V8_PARSING_SCANNER_CHARACTER_STREAMS_H_
7 7
8 #include "src/handles.h" 8 #include "src/handles.h"
9 #include "src/parsing/scanner.h" 9 #include "src/parsing/scanner.h"
10 #include "src/vector.h" 10 #include "src/vector.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 // Forward declarations. 15 // Forward declarations.
16 class ExternalTwoByteString; 16 class ExternalTwoByteString;
17 17
18 // A buffered character stream based on a random access character 18 // A buffered character stream based on a random access character
19 // source (ReadBlock can be called with pos_ pointing to any position, 19 // source (ReadBlock can be called with pos_ pointing to any position,
20 // even positions before the current). 20 // even positions before the current).
21 class BufferedUtf16CharacterStream: public Utf16CharacterStream { 21 class BufferedUtf16CharacterStream : public Utf16CharacterStream {
22 public: 22 public:
23 BufferedUtf16CharacterStream(); 23 BufferedUtf16CharacterStream();
24 ~BufferedUtf16CharacterStream() override; 24 ~BufferedUtf16CharacterStream() override;
25 25
26 void PushBack(uc32 character) override; 26 void PushBack(uc32 character) override;
27 27
28 protected: 28 protected:
29 static const size_t kBufferSize = 512; 29 static const size_t kBufferSize = 512;
30 static const size_t kPushBackStepSize = 16; 30 static const size_t kPushBackStepSize = 16;
31 31
32 size_t SlowSeekForward(size_t delta) override; 32 size_t SlowSeekForward(size_t delta) override;
33 bool ReadBlock() override; 33 bool ReadBlock() override;
34 virtual void SlowPushBack(uc16 character); 34 virtual void SlowPushBack(uc16 character);
35 35
36 virtual size_t BufferSeekForward(size_t delta) = 0; 36 virtual size_t BufferSeekForward(size_t delta) = 0;
37 virtual size_t FillBuffer(size_t position) = 0; 37 virtual size_t FillBuffer(size_t position) = 0;
38 38
39 const uc16* pushback_limit_; 39 const uc16* pushback_limit_;
40 uc16 buffer_[kBufferSize]; 40 uc16 buffer_[kBufferSize];
41 }; 41 };
42 42
43 43
44 // Generic string stream. 44 // Generic string stream.
45 class GenericStringUtf16CharacterStream: public BufferedUtf16CharacterStream { 45 class GenericStringUtf16CharacterStream : public BufferedUtf16CharacterStream {
46 public: 46 public:
47 GenericStringUtf16CharacterStream(Handle<String> data, size_t start_position, 47 GenericStringUtf16CharacterStream(Handle<String> data, size_t start_position,
48 size_t end_position); 48 size_t end_position);
49 ~GenericStringUtf16CharacterStream() override; 49 ~GenericStringUtf16CharacterStream() override;
50 50
51 bool SetBookmark() override; 51 bool SetBookmark() override;
52 void ResetToBookmark() override; 52 void ResetToBookmark() override;
53 53
54 protected: 54 protected:
55 static const size_t kNoBookmark = -1; 55 static const size_t kNoBookmark = -1;
56 56
57 size_t BufferSeekForward(size_t delta) override; 57 size_t BufferSeekForward(size_t delta) override;
58 size_t FillBuffer(size_t position) override; 58 size_t FillBuffer(size_t position) override;
59 59
60 Handle<String> string_; 60 Handle<String> string_;
61 size_t length_; 61 size_t length_;
62 size_t bookmark_; 62 size_t bookmark_;
63 }; 63 };
64 64
65 65
66 // Utf16 stream based on a literal UTF-8 string. 66 // Utf16 stream based on a literal UTF-8 string.
67 class Utf8ToUtf16CharacterStream: public BufferedUtf16CharacterStream { 67 class Utf8ToUtf16CharacterStream : public BufferedUtf16CharacterStream {
68 public: 68 public:
69 Utf8ToUtf16CharacterStream(const byte* data, size_t length); 69 Utf8ToUtf16CharacterStream(const byte* data, size_t length);
70 ~Utf8ToUtf16CharacterStream() override; 70 ~Utf8ToUtf16CharacterStream() override;
71 71
72 static size_t CopyChars(uint16_t* dest, size_t length, const byte* src, 72 static size_t CopyChars(uint16_t* dest, size_t length, const byte* src,
73 size_t* src_pos, size_t src_length); 73 size_t* src_pos, size_t src_length);
74 74
75 protected: 75 protected:
76 size_t BufferSeekForward(size_t delta) override; 76 size_t BufferSeekForward(size_t delta) override;
77 size_t FillBuffer(size_t char_position) override; 77 size_t FillBuffer(size_t char_position) override;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 Vector<uint16_t> bookmark_buffer_; 142 Vector<uint16_t> bookmark_buffer_;
143 Vector<uint8_t> bookmark_data_; 143 Vector<uint8_t> bookmark_data_;
144 bool bookmark_data_is_from_current_data_; 144 bool bookmark_data_is_from_current_data_;
145 size_t bookmark_data_offset_; 145 size_t bookmark_data_offset_;
146 uint8_t bookmark_utf8_split_char_buffer_[4]; 146 uint8_t bookmark_utf8_split_char_buffer_[4];
147 size_t bookmark_utf8_split_char_buffer_length_; 147 size_t bookmark_utf8_split_char_buffer_length_;
148 }; 148 };
149 149
150 150
151 // UTF16 buffer to read characters from an external string. 151 // UTF16 buffer to read characters from an external string.
152 class ExternalTwoByteStringUtf16CharacterStream: public Utf16CharacterStream { 152 class ExternalTwoByteStringUtf16CharacterStream : public Utf16CharacterStream {
153 public: 153 public:
154 ExternalTwoByteStringUtf16CharacterStream(Handle<ExternalTwoByteString> data, 154 ExternalTwoByteStringUtf16CharacterStream(Handle<ExternalTwoByteString> data,
155 int start_position, 155 int start_position,
156 int end_position); 156 int end_position);
157 ~ExternalTwoByteStringUtf16CharacterStream() override; 157 ~ExternalTwoByteStringUtf16CharacterStream() override;
158 158
159 void PushBack(uc32 character) override { 159 void PushBack(uc32 character) override {
160 DCHECK(buffer_cursor_ > raw_data_); 160 DCHECK(buffer_cursor_ > raw_data_);
161 buffer_cursor_--; 161 buffer_cursor_--;
162 pos_--; 162 pos_--;
(...skipping 17 matching lines...) Expand all
180 private: 180 private:
181 static const size_t kNoBookmark = -1; 181 static const size_t kNoBookmark = -1;
182 182
183 size_t bookmark_; 183 size_t bookmark_;
184 }; 184 };
185 185
186 } // namespace internal 186 } // namespace internal
187 } // namespace v8 187 } // namespace v8
188 188
189 #endif // V8_PARSING_SCANNER_CHARACTER_STREAMS_H_ 189 #endif // V8_PARSING_SCANNER_CHARACTER_STREAMS_H_
OLDNEW
« no previous file with comments | « src/parsing/scanner.cc ('k') | src/parsing/scanner-character-streams.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698