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

Unified Diff: src/parser.cc

Issue 939303002: Replace is_reference_error bool argument with ParseErrorType enum (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Marja comments addressed Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.h ('k') | src/preparse-data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 336afa9a9fc5aaa95cb2d814f3ccf8c6935486cf..c27d1bed7b453786092b36bbaaf02e76095bddfc 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -600,9 +600,8 @@ Expression* ParserTraits::NewThrowError(
void ParserTraits::ReportMessageAt(Scanner::Location source_location,
- const char* message,
- const char* arg,
- bool is_reference_error) {
+ const char* message, const char* arg,
+ ParseErrorType error_type) {
if (parser_->stack_overflow()) {
// Suppress the error message (syntax error or such) in the presence of a
// stack overflow. The isolate allows only one pending exception at at time
@@ -614,30 +613,27 @@ void ParserTraits::ReportMessageAt(Scanner::Location source_location,
parser_->pending_error_message_ = message;
parser_->pending_error_char_arg_ = arg;
parser_->pending_error_arg_ = NULL;
- parser_->pending_error_is_reference_error_ = is_reference_error;
+ parser_->pending_error_type_ = error_type;
}
-void ParserTraits::ReportMessage(const char* message,
- const char* arg,
- bool is_reference_error) {
+void ParserTraits::ReportMessage(const char* message, const char* arg,
+ ParseErrorType error_type) {
Scanner::Location source_location = parser_->scanner()->location();
- ReportMessageAt(source_location, message, arg, is_reference_error);
+ ReportMessageAt(source_location, message, arg, error_type);
}
-void ParserTraits::ReportMessage(const char* message,
- const AstRawString* arg,
- bool is_reference_error) {
+void ParserTraits::ReportMessage(const char* message, const AstRawString* arg,
+ ParseErrorType error_type) {
Scanner::Location source_location = parser_->scanner()->location();
- ReportMessageAt(source_location, message, arg, is_reference_error);
+ ReportMessageAt(source_location, message, arg, error_type);
}
void ParserTraits::ReportMessageAt(Scanner::Location source_location,
- const char* message,
- const AstRawString* arg,
- bool is_reference_error) {
+ const char* message, const AstRawString* arg,
+ ParseErrorType error_type) {
if (parser_->stack_overflow()) {
// Suppress the error message (syntax error or such) in the presence of a
// stack overflow. The isolate allows only one pending exception at at time
@@ -649,7 +645,7 @@ void ParserTraits::ReportMessageAt(Scanner::Location source_location,
parser_->pending_error_message_ = message;
parser_->pending_error_char_arg_ = NULL;
parser_->pending_error_arg_ = arg;
- parser_->pending_error_is_reference_error_ = is_reference_error;
+ parser_->pending_error_type_ = error_type;
}
@@ -797,6 +793,7 @@ Parser::Parser(CompilationInfo* info, uintptr_t stack_limit, uint32_t hash_seed,
pending_error_message_(NULL),
pending_error_arg_(NULL),
pending_error_char_arg_(NULL),
+ pending_error_type_(kSyntaxError),
total_preparse_skipped_(0),
pre_parse_timer_(NULL),
parsing_on_main_thread_(true) {
@@ -3889,7 +3886,7 @@ void Parser::SkipLazyFunctionBody(const AstRawString* function_name,
if (logger.has_error()) {
ParserTraits::ReportMessageAt(
Scanner::Location(logger.start(), logger.end()), logger.message(),
- logger.argument_opt(), logger.is_reference_error());
+ logger.argument_opt(), logger.error_type());
*ok = false;
return;
}
@@ -4294,10 +4291,16 @@ void Parser::ThrowPendingError(Isolate* isolate, Handle<Script> script) {
Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
Handle<Object> error;
- MaybeHandle<Object> maybe_error =
- pending_error_is_reference_error_
- ? factory->NewReferenceError(pending_error_message_, array)
- : factory->NewSyntaxError(pending_error_message_, array);
+ MaybeHandle<Object> maybe_error;
+ switch (pending_error_type_) {
+ case kReferenceError:
+ maybe_error = factory->NewReferenceError(pending_error_message_, array);
+ break;
+ case kSyntaxError:
+ maybe_error = factory->NewSyntaxError(pending_error_message_, array);
+ break;
+ }
+ DCHECK(!maybe_error.is_null() || isolate->has_pending_exception());
if (maybe_error.ToHandle(&error)) {
Handle<JSObject> jserror = Handle<JSObject>::cast(error);
« no previous file with comments | « src/parser.h ('k') | src/preparse-data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698