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

Side by Side Diff: src/scanner.h

Issue 6246004: Fix bug when the scanner does a pushback at the end of input. (Closed)
Patch Set: Created 9 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 25 matching lines...) Expand all
36 namespace internal { 36 namespace internal {
37 37
38 // A buffered character stream based on a random access character 38 // A buffered character stream based on a random access character
39 // source (ReadBlock can be called with pos_ pointing to any position, 39 // source (ReadBlock can be called with pos_ pointing to any position,
40 // even positions before the current). 40 // even positions before the current).
41 class BufferedUC16CharacterStream: public UC16CharacterStream { 41 class BufferedUC16CharacterStream: public UC16CharacterStream {
42 public: 42 public:
43 BufferedUC16CharacterStream(); 43 BufferedUC16CharacterStream();
44 virtual ~BufferedUC16CharacterStream(); 44 virtual ~BufferedUC16CharacterStream();
45 45
46 virtual void PushBack(uc16 character); 46 virtual void PushBack(uc32 character);
47 47
48 protected: 48 protected:
49 static const unsigned kBufferSize = 512; 49 static const unsigned kBufferSize = 512;
50 static const unsigned kPushBackStepSize = 16; 50 static const unsigned kPushBackStepSize = 16;
51 51
52 virtual unsigned SlowSeekForward(unsigned delta); 52 virtual unsigned SlowSeekForward(unsigned delta);
53 virtual bool ReadBlock(); 53 virtual bool ReadBlock();
54 virtual void SlowPushBack(uc16 character); 54 virtual void SlowPushBack(uc16 character);
55 55
56 virtual unsigned BufferSeekForward(unsigned delta) = 0; 56 virtual unsigned BufferSeekForward(unsigned delta) = 0;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 101
102 // UTF16 buffer to read characters from an external string. 102 // UTF16 buffer to read characters from an external string.
103 class ExternalTwoByteStringUC16CharacterStream: public UC16CharacterStream { 103 class ExternalTwoByteStringUC16CharacterStream: public UC16CharacterStream {
104 public: 104 public:
105 ExternalTwoByteStringUC16CharacterStream(Handle<ExternalTwoByteString> data, 105 ExternalTwoByteStringUC16CharacterStream(Handle<ExternalTwoByteString> data,
106 int start_position, 106 int start_position,
107 int end_position); 107 int end_position);
108 virtual ~ExternalTwoByteStringUC16CharacterStream(); 108 virtual ~ExternalTwoByteStringUC16CharacterStream();
109 109
110 virtual void PushBack(uc16 character) { 110 virtual void PushBack(uc32 character) {
111 ASSERT(buffer_cursor_ > raw_data_); 111 ASSERT(buffer_cursor_ > raw_data_);
112 buffer_cursor_--; 112 buffer_cursor_--;
113 pos_--; 113 pos_--;
114 } 114 }
115
115 protected: 116 protected:
116 virtual unsigned SlowSeekForward(unsigned delta) { 117 virtual unsigned SlowSeekForward(unsigned delta) {
117 // Fast case always handles seeking. 118 // Fast case always handles seeking.
118 return 0; 119 return 0;
119 } 120 }
120 virtual bool ReadBlock() { 121 virtual bool ReadBlock() {
121 // Entire string is read at start. 122 // Entire string is read at start.
122 return false; 123 return false;
123 } 124 }
124 Handle<ExternalTwoByteString> source_; 125 Handle<ExternalTwoByteString> source_;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 176
176 // Used to recognizes one of the literals "true", "false", or "null". These 177 // Used to recognizes one of the literals "true", "false", or "null". These
177 // are the only valid JSON identifiers (productions JSONBooleanLiteral, 178 // are the only valid JSON identifiers (productions JSONBooleanLiteral,
178 // JSONNullLiteral). 179 // JSONNullLiteral).
179 Token::Value ScanJsonIdentifier(const char* text, Token::Value token); 180 Token::Value ScanJsonIdentifier(const char* text, Token::Value token);
180 }; 181 };
181 182
182 } } // namespace v8::internal 183 } } // namespace v8::internal
183 184
184 #endif // V8_SCANNER_H_ 185 #endif // V8_SCANNER_H_
OLDNEW
« no previous file with comments | « src/preparser-api.cc ('k') | src/scanner.cc » ('j') | src/scanner-base.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698