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

Side by Side Diff: src/parser.cc

Issue 194713013: Parser: fix confusion when there are multiple errors to report. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased 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 | « 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 return identifier.is_identical_to( 445 return identifier.is_identical_to(
446 parser_->isolate()->factory()->eval_string()) || 446 parser_->isolate()->factory()->eval_string()) ||
447 identifier.is_identical_to( 447 identifier.is_identical_to(
448 parser_->isolate()->factory()->arguments_string()); 448 parser_->isolate()->factory()->arguments_string());
449 } 449 }
450 450
451 451
452 void ParserTraits::ReportMessageAt(Scanner::Location source_location, 452 void ParserTraits::ReportMessageAt(Scanner::Location source_location,
453 const char* message, 453 const char* message,
454 Vector<const char*> args) { 454 Vector<const char*> args) {
455 if (parser_->stack_overflow()) {
456 // Suppress the error message (syntax error or such) in the presence of a
457 // stack overflow. The isolate allows only one pending exception at at time
458 // and we want to report the stack overflow later.
459 return;
460 }
455 MessageLocation location(parser_->script_, 461 MessageLocation location(parser_->script_,
456 source_location.beg_pos, 462 source_location.beg_pos,
457 source_location.end_pos); 463 source_location.end_pos);
458 Factory* factory = parser_->isolate()->factory(); 464 Factory* factory = parser_->isolate()->factory();
459 Handle<FixedArray> elements = factory->NewFixedArray(args.length()); 465 Handle<FixedArray> elements = factory->NewFixedArray(args.length());
460 for (int i = 0; i < args.length(); i++) { 466 for (int i = 0; i < args.length(); i++) {
461 Handle<String> arg_string = factory->NewStringFromUtf8(CStrVector(args[i])); 467 Handle<String> arg_string = factory->NewStringFromUtf8(CStrVector(args[i]));
462 elements->set(i, *arg_string); 468 elements->set(i, *arg_string);
463 } 469 }
464 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); 470 Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
465 Handle<Object> result = factory->NewSyntaxError(message, array); 471 Handle<Object> result = factory->NewSyntaxError(message, array);
466 parser_->isolate()->Throw(*result, &location); 472 parser_->isolate()->Throw(*result, &location);
467 } 473 }
468 474
469 475
470 void ParserTraits::ReportMessage(const char* message, 476 void ParserTraits::ReportMessage(const char* message,
471 Vector<Handle<String> > args) { 477 Vector<Handle<String> > args) {
472 Scanner::Location source_location = parser_->scanner()->location(); 478 Scanner::Location source_location = parser_->scanner()->location();
473 ReportMessageAt(source_location, message, args); 479 ReportMessageAt(source_location, message, args);
474 } 480 }
475 481
476 482
477 void ParserTraits::ReportMessageAt(Scanner::Location source_location, 483 void ParserTraits::ReportMessageAt(Scanner::Location source_location,
478 const char* message, 484 const char* message,
479 Vector<Handle<String> > args) { 485 Vector<Handle<String> > args) {
486 if (parser_->stack_overflow()) {
487 // Suppress the error message (syntax error or such) in the presence of a
488 // stack overflow. The isolate allows only one pending exception at at time
489 // and we want to report the stack overflow later.
490 return;
491 }
480 MessageLocation location(parser_->script_, 492 MessageLocation location(parser_->script_,
481 source_location.beg_pos, 493 source_location.beg_pos,
482 source_location.end_pos); 494 source_location.end_pos);
483 Factory* factory = parser_->isolate()->factory(); 495 Factory* factory = parser_->isolate()->factory();
484 Handle<FixedArray> elements = factory->NewFixedArray(args.length()); 496 Handle<FixedArray> elements = factory->NewFixedArray(args.length());
485 for (int i = 0; i < args.length(); i++) { 497 for (int i = 0; i < args.length(); i++) {
486 elements->set(i, *args[i]); 498 elements->set(i, *args[i]);
487 } 499 }
488 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); 500 Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
489 Handle<Object> result = factory->NewSyntaxError(message, array); 501 Handle<Object> result = factory->NewSyntaxError(message, array);
(...skipping 4688 matching lines...) Expand 10 before | Expand all | Expand 10 after
5178 ASSERT(info()->isolate()->has_pending_exception()); 5190 ASSERT(info()->isolate()->has_pending_exception());
5179 } else { 5191 } else {
5180 result = ParseProgram(); 5192 result = ParseProgram();
5181 } 5193 }
5182 } 5194 }
5183 info()->SetFunction(result); 5195 info()->SetFunction(result);
5184 return (result != NULL); 5196 return (result != NULL);
5185 } 5197 }
5186 5198
5187 } } // namespace v8::internal 5199 } } // namespace v8::internal
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