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

Side by Side Diff: src/parser.h

Issue 5122007: Made some functions virtual that were previously hit by templating. (Closed)
Patch Set: Created 10 years, 1 month 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 | « no previous file | no next file » | 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 static const char* ReadString(unsigned* start, int* chars); 174 static const char* ReadString(unsigned* start, int* chars);
175 175
176 friend class ScriptData; 176 friend class ScriptData;
177 }; 177 };
178 178
179 179
180 // Record only functions. 180 // Record only functions.
181 class PartialParserRecorder { 181 class PartialParserRecorder {
182 public: 182 public:
183 PartialParserRecorder(); 183 PartialParserRecorder();
184 virtual ~PartialParserRecorder() {}
184 185
185 void LogFunction(int start, int end, int literals, int properties) { 186 void LogFunction(int start, int end, int literals, int properties) {
186 function_store_.Add(start); 187 function_store_.Add(start);
187 function_store_.Add(end); 188 function_store_.Add(end);
188 function_store_.Add(literals); 189 function_store_.Add(literals);
189 function_store_.Add(properties); 190 function_store_.Add(properties);
190 } 191 }
191 192
192 void LogSymbol(int start, const char* symbol, int length) { } 193 virtual void LogSymbol(int start, const char* symbol, int length) { }
193 194
194 // Logs an error message and marks the log as containing an error. 195 // Logs an error message and marks the log as containing an error.
195 // Further logging will be ignored, and ExtractData will return a vector 196 // Further logging will be ignored, and ExtractData will return a vector
196 // representing the error only. 197 // representing the error only.
197 void LogMessage(int start, 198 void LogMessage(int start,
198 int end, 199 int end,
199 const char* message, 200 const char* message,
200 const char* argument_opt) { 201 const char* argument_opt) {
201 Scanner::Location location(start, end); 202 Scanner::Location location(start, end);
202 Vector<const char*> arguments; 203 Vector<const char*> arguments;
203 if (argument_opt != NULL) { 204 if (argument_opt != NULL) {
204 arguments = Vector<const char*>(&argument_opt, 1); 205 arguments = Vector<const char*>(&argument_opt, 1);
205 } 206 }
206 this->LogMessage(location, message, arguments); 207 this->LogMessage(location, message, arguments);
207 } 208 }
208 209
209 int function_position() { return function_store_.size(); } 210 int function_position() { return function_store_.size(); }
210 211
211 void LogMessage(Scanner::Location loc, 212 void LogMessage(Scanner::Location loc,
212 const char* message, 213 const char* message,
213 Vector<const char*> args); 214 Vector<const char*> args);
214 215
215 Vector<unsigned> ExtractData(); 216 virtual Vector<unsigned> ExtractData();
216 217
217 void PauseRecording() { 218 void PauseRecording() {
218 pause_count_++; 219 pause_count_++;
219 is_recording_ = false; 220 is_recording_ = false;
220 } 221 }
221 222
222 void ResumeRecording() { 223 void ResumeRecording() {
223 ASSERT(pause_count_ > 0); 224 ASSERT(pause_count_ > 0);
224 if (--pause_count_ == 0) is_recording_ = !has_error(); 225 if (--pause_count_ == 0) is_recording_ = !has_error();
225 } 226 }
(...skipping 20 matching lines...) Expand all
246 #ifdef DEBUG 247 #ifdef DEBUG
247 int prev_start_; 248 int prev_start_;
248 #endif 249 #endif
249 }; 250 };
250 251
251 252
252 // Record both functions and symbols. 253 // Record both functions and symbols.
253 class CompleteParserRecorder: public PartialParserRecorder { 254 class CompleteParserRecorder: public PartialParserRecorder {
254 public: 255 public:
255 CompleteParserRecorder(); 256 CompleteParserRecorder();
257 virtual ~CompleteParserRecorder() { }
256 258
257 void LogSymbol(int start, Vector<const char> literal); 259 void LogSymbol(int start, Vector<const char> literal);
258 260
259 void LogSymbol(int start, const char* symbol, int length) { 261 virtual void LogSymbol(int start, const char* symbol, int length) {
260 LogSymbol(start, Vector<const char>(symbol, length)); 262 LogSymbol(start, Vector<const char>(symbol, length));
261 } 263 }
262 264
263 Vector<unsigned> ExtractData(); 265 virtual Vector<unsigned> ExtractData();
264 266
265 int symbol_position() { return symbol_store_.size(); } 267 int symbol_position() { return symbol_store_.size(); }
266 int symbol_ids() { return symbol_id_; } 268 int symbol_ids() { return symbol_id_; }
267 269
268 private: 270 private:
269 static int vector_hash(Vector<const char> string) { 271 static int vector_hash(Vector<const char> string) {
270 int hash = 0; 272 int hash = 0;
271 for (int i = 0; i < string.length(); i++) { 273 for (int i = 0; i < string.length(); i++) {
272 int c = string[i]; 274 int c = string[i];
273 hash += c; 275 hash += c;
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 // return a null handle. Primarily for readability. 852 // return a null handle. Primarily for readability.
851 Handle<Object> ReportUnexpectedToken() { return Handle<Object>::null(); } 853 Handle<Object> ReportUnexpectedToken() { return Handle<Object>::null(); }
852 // Converts the currently parsed literal to a JavaScript String. 854 // Converts the currently parsed literal to a JavaScript String.
853 Handle<String> GetString(); 855 Handle<String> GetString();
854 856
855 JsonScanner scanner_; 857 JsonScanner scanner_;
856 }; 858 };
857 } } // namespace v8::internal 859 } } // namespace v8::internal
858 860
859 #endif // V8_PARSER_H_ 861 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698