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

Side by Side Diff: src/lexer/lexer-shell.cc

Issue 196473026: Experimental parser: fix build after merge (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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/lexer/lexer.cc ('k') | 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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 public: 211 public:
212 Token::Value value; 212 Token::Value value;
213 int beg; 213 int beg;
214 int end; 214 int end;
215 bool is_one_byte; 215 bool is_one_byte;
216 SmartArrayPointer<const uint16_t> literal; 216 SmartArrayPointer<const uint16_t> literal;
217 int literal_length; 217 int literal_length;
218 // The location of the latest octal position when the token was seen. 218 // The location of the latest octal position when the token was seen.
219 int octal_beg; 219 int octal_beg;
220 int octal_end; 220 int octal_end;
221 TokenWithLocation(Token::Value token, Scanner* scanner) : value(token) { 221 TokenWithLocation(Token::Value token,
222 Scanner* scanner,
223 Handle<String> literal_string)
224 : value(token) {
222 beg = scanner->location().beg_pos; 225 beg = scanner->location().beg_pos;
223 end = scanner->location().end_pos; 226 end = scanner->location().end_pos;
224 octal_beg = scanner->octal_position().beg_pos; 227 octal_beg = scanner->octal_position().beg_pos;
225 octal_end = scanner->octal_position().end_pos; 228 octal_end = scanner->octal_position().end_pos;
226 is_one_byte = false; 229 is_one_byte = false;
227 literal_length = 0; 230 literal_length = 0;
228 if (HasLiteral(token)) { 231 if (!literal_string.is_null()) {
229 is_one_byte = scanner->is_literal_ascii(); 232 DisallowHeapAllocation no_alloc;
230 if (scanner->is_literal_ascii()) { 233 String::FlatContent content = literal_string->GetFlatContent();
231 Copy(scanner->literal_ascii_string(), &literal, &literal_length); 234 if (content.IsAscii()) {
235 Copy(content.ToOneByteVector(), &literal, &literal_length);
232 } else { 236 } else {
233 Copy(scanner->literal_utf16_string(), &literal, &literal_length); 237 Copy(content.ToUC16Vector(), &literal, &literal_length);
234 } 238 }
235 } 239 }
236 } 240 }
237 void Print(bool do_compare) const { 241 void Print(bool do_compare) const {
238 if (value == Token::ILLEGAL && do_compare) { 242 if (value == Token::ILLEGAL && do_compare) {
239 printf("%-15s (%d)\n", Token::Name(value), beg); 243 printf("%-15s (%d)\n", Token::Name(value), beg);
240 return; 244 return;
241 } 245 }
242 printf("%-15s (%d, %d)", Token::Name(value), beg, end); 246 printf("%-15s (%d, %d)", Token::Name(value), beg, end);
243 if (literal_length > 0) { 247 if (literal_length > 0) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 scanner.SetHarmonyNumericLiterals(settings.harmony_numeric_literals); 295 scanner.SetHarmonyNumericLiterals(settings.harmony_numeric_literals);
292 scanner.SetHarmonyModules(settings.harmony_modules); 296 scanner.SetHarmonyModules(settings.harmony_modules);
293 scanner.SetHarmonyScoping(settings.harmony_scoping); 297 scanner.SetHarmonyScoping(settings.harmony_scoping);
294 ElapsedTimer timer; 298 ElapsedTimer timer;
295 std::vector<TokenWithLocation*> tokens; 299 std::vector<TokenWithLocation*> tokens;
296 timer.Start(); 300 timer.Start();
297 scanner.Initialize(stream.get()); 301 scanner.Initialize(stream.get());
298 Token::Value token; 302 Token::Value token;
299 do { 303 do {
300 token = scanner.Next(); 304 token = scanner.Next();
305 Handle<String> literal;
306 if (HasLiteral(token)) {
307 literal = scanner.AllocateInternalizedString(isolate);
308 }
301 if (settings.print_tokens) { 309 if (settings.print_tokens) {
302 tokens.push_back(new TokenWithLocation(token, &scanner)); 310 tokens.push_back(new TokenWithLocation(token, &scanner, literal));
303 } else if (HasLiteral(token)) {
304 if (scanner.is_literal_ascii()) {
305 scanner.literal_ascii_string();
306 } else {
307 scanner.literal_utf16_string();
308 }
309 } 311 }
310 if (token == Token::ILLEGAL && settings.break_after_illegal) break; 312 if (token == Token::ILLEGAL && settings.break_after_illegal) break;
311 } while (token != Token::EOS); 313 } while (token != Token::EOS);
312 // Dump tokens. 314 // Dump tokens.
313 if (settings.print_tokens) { 315 if (settings.print_tokens) {
314 if (!settings.print_tokens_for_compare) { 316 if (!settings.print_tokens_for_compare) {
315 printf("No of tokens:\t%d\n", static_cast<int>(tokens.size())); 317 printf("No of tokens:\t%d\n", static_cast<int>(tokens.size()));
316 } 318 }
317 for (size_t i = 0; i < tokens.size(); ++i) { 319 for (size_t i = 0; i < tokens.size(); ++i) {
318 tokens[i]->Print(settings.print_tokens_for_compare); 320 tokens[i]->Print(settings.print_tokens_for_compare);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 ++truncate_by; 424 ++truncate_by;
423 } while (can_truncate); 425 } while (can_truncate);
424 } 426 }
425 if (!settings.print_tokens_for_compare) { 427 if (!settings.print_tokens_for_compare) {
426 printf("RunTime: %.f ms\n", total_time); 428 printf("RunTime: %.f ms\n", total_time);
427 } 429 }
428 } 430 }
429 v8::V8::Dispose(); 431 v8::V8::Dispose();
430 return 0; 432 return 0;
431 } 433 }
OLDNEW
« no previous file with comments | « src/lexer/lexer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698