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

Side by Side Diff: src/scanner.h

Issue 6529032: Merge 6168:6800 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/safepoint-table.cc ('k') | src/scanner.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 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 15 matching lines...) Expand all
140 141
141 class JsonScanner : public Scanner { 142 class JsonScanner : public Scanner {
142 public: 143 public:
143 JsonScanner(); 144 JsonScanner();
144 145
145 void Initialize(UC16CharacterStream* source); 146 void Initialize(UC16CharacterStream* source);
146 147
147 // Returns the next token. 148 // Returns the next token.
148 Token::Value Next(); 149 Token::Value Next();
149 150
151 // Returns the value of a number token.
152 double number() {
153 return number_;
154 }
155
156
150 protected: 157 protected:
151 // Skip past JSON whitespace (only space, tab, newline and carrige-return). 158 // Skip past JSON whitespace (only space, tab, newline and carrige-return).
152 bool SkipJsonWhiteSpace(); 159 bool SkipJsonWhiteSpace();
153 160
154 // Scan a single JSON token. The JSON lexical grammar is specified in the 161 // Scan a single JSON token. The JSON lexical grammar is specified in the
155 // ECMAScript 5 standard, section 15.12.1.1. 162 // ECMAScript 5 standard, section 15.12.1.1.
156 // Recognizes all of the single-character tokens directly, or calls a function 163 // Recognizes all of the single-character tokens directly, or calls a function
157 // to scan a number, string or identifier literal. 164 // to scan a number, string or identifier literal.
158 // The only allowed whitespace characters between tokens are tab, 165 // The only allowed whitespace characters between tokens are tab,
159 // carriage-return, newline and space. 166 // carriage-return, newline and space.
(...skipping 10 matching lines...) Expand all
170 // A JSON string (production JSONString) is subset of valid JavaScript string 177 // A JSON string (production JSONString) is subset of valid JavaScript string
171 // literals. The string must only be double-quoted (not single-quoted), and 178 // literals. The string must only be double-quoted (not single-quoted), and
172 // the only allowed backslash-escapes are ", /, \, b, f, n, r, t and 179 // the only allowed backslash-escapes are ", /, \, b, f, n, r, t and
173 // four-digit hex escapes (uXXXX). Any other use of backslashes is invalid. 180 // four-digit hex escapes (uXXXX). Any other use of backslashes is invalid.
174 Token::Value ScanJsonString(); 181 Token::Value ScanJsonString();
175 182
176 // Used to recognizes one of the literals "true", "false", or "null". These 183 // Used to recognizes one of the literals "true", "false", or "null". These
177 // are the only valid JSON identifiers (productions JSONBooleanLiteral, 184 // are the only valid JSON identifiers (productions JSONBooleanLiteral,
178 // JSONNullLiteral). 185 // JSONNullLiteral).
179 Token::Value ScanJsonIdentifier(const char* text, Token::Value token); 186 Token::Value ScanJsonIdentifier(const char* text, Token::Value token);
187
188 // Holds the value of a scanned number token.
189 double number_;
180 }; 190 };
181 191
182 } } // namespace v8::internal 192 } } // namespace v8::internal
183 193
184 #endif // V8_SCANNER_H_ 194 #endif // V8_SCANNER_H_
OLDNEW
« no previous file with comments | « src/safepoint-table.cc ('k') | src/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698