Commit f511f11a authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Remove RETURN_IF* part 11

Bug: v8:8363, v8:7926
Change-Id: Icfc8c02573a92d655ee14f563ad9c67fe5655029
Reviewed-on: https://chromium-review.googlesource.com/c/1304440
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57087}
parent ca166b28
This diff is collapsed.
...@@ -139,7 +139,7 @@ void Parser::GetUnexpectedTokenMessage(Token::Value token, ...@@ -139,7 +139,7 @@ void Parser::GetUnexpectedTokenMessage(Token::Value token,
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// The RETURN_IF_PARSE_ERROR macro is a convenient macro to enforce error // The RETURN_IF_PARSE_ERROR macro is a convenient macro to enforce error
// handling for functions that may fail (by returning if there was an parser // handling for functions that may fail (by returning if there was an parser
// error scanner()->has_parser_error_set). // error scanner()->has_parser_error()).
// //
// Usage: // Usage:
// foo = ParseFoo(); // may fail // foo = ParseFoo(); // may fail
...@@ -148,7 +148,7 @@ void Parser::GetUnexpectedTokenMessage(Token::Value token, ...@@ -148,7 +148,7 @@ void Parser::GetUnexpectedTokenMessage(Token::Value token,
// SAFE_USE(foo); // SAFE_USE(foo);
#define RETURN_IF_PARSE_ERROR_VALUE(x) \ #define RETURN_IF_PARSE_ERROR_VALUE(x) \
if (scanner()->has_parser_error_set()) { \ if (scanner()->has_parser_error()) { \
return x; \ return x; \
} }
...@@ -589,7 +589,7 @@ FunctionLiteral* Parser::DoParseProgram(Isolate* isolate, ParseInfo* info) { ...@@ -589,7 +589,7 @@ FunctionLiteral* Parser::DoParseProgram(Isolate* isolate, ParseInfo* info) {
zone()); zone());
ParseModuleItemList(body); ParseModuleItemList(body);
ok = !scanner_.has_parser_error_set() && ok = !scanner_.has_parser_error() &&
module()->Validate(this->scope()->AsModuleScope(), module()->Validate(this->scope()->AsModuleScope(),
pending_error_handler(), zone()); pending_error_handler(), zone());
} else if (info->is_wrapped_as_function()) { } else if (info->is_wrapped_as_function()) {
...@@ -600,7 +600,7 @@ FunctionLiteral* Parser::DoParseProgram(Isolate* isolate, ParseInfo* info) { ...@@ -600,7 +600,7 @@ FunctionLiteral* Parser::DoParseProgram(Isolate* isolate, ParseInfo* info) {
this->scope()->SetLanguageMode(info->language_mode()); this->scope()->SetLanguageMode(info->language_mode());
ParseStatementList(body, Token::EOS); ParseStatementList(body, Token::EOS);
} }
ok = ok && !scanner_.has_parser_error_set(); ok = ok && !scanner_.has_parser_error();
// The parser will peek but not consume EOS. Our scope logically goes all // The parser will peek but not consume EOS. Our scope logically goes all
// the way to the EOS, though. // the way to the EOS, though.
...@@ -608,7 +608,7 @@ FunctionLiteral* Parser::DoParseProgram(Isolate* isolate, ParseInfo* info) { ...@@ -608,7 +608,7 @@ FunctionLiteral* Parser::DoParseProgram(Isolate* isolate, ParseInfo* info) {
if (ok && is_strict(language_mode())) { if (ok && is_strict(language_mode())) {
CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos); CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos);
ok = !scanner_.has_parser_error_set(); ok = !scanner_.has_parser_error();
} }
if (ok && is_sloppy(language_mode())) { if (ok && is_sloppy(language_mode())) {
// TODO(littledan): Function bindings on the global object that modify // TODO(littledan): Function bindings on the global object that modify
...@@ -619,7 +619,7 @@ FunctionLiteral* Parser::DoParseProgram(Isolate* isolate, ParseInfo* info) { ...@@ -619,7 +619,7 @@ FunctionLiteral* Parser::DoParseProgram(Isolate* isolate, ParseInfo* info) {
} }
if (ok) { if (ok) {
CheckConflictingVarDeclarations(scope); CheckConflictingVarDeclarations(scope);
ok = !scanner_.has_parser_error_set(); ok = !scanner_.has_parser_error();
} }
if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) { if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) {
...@@ -816,12 +816,12 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info, ...@@ -816,12 +816,12 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info,
if (Check(Token::LPAREN)) { if (Check(Token::LPAREN)) {
// '(' StrictFormalParameters ')' // '(' StrictFormalParameters ')'
ParseFormalParameterList(&formals); ParseFormalParameterList(&formals);
ok = !scanner_.has_parser_error_set(); ok = !scanner_.has_parser_error();
if (ok) ok = Check(Token::RPAREN); if (ok) ok = Check(Token::RPAREN);
} else { } else {
// BindingIdentifier // BindingIdentifier
ParseFormalParameter(&formals); ParseFormalParameter(&formals);
ok = !scanner_.has_parser_error_set(); ok = !scanner_.has_parser_error();
if (ok) { if (ok) {
DeclareFormalParameters(&formals); DeclareFormalParameters(&formals);
} }
...@@ -854,7 +854,7 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info, ...@@ -854,7 +854,7 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info,
const int rewritable_length = 0; const int rewritable_length = 0;
Expression* expression = Expression* expression =
ParseArrowFunctionLiteral(accept_IN, formals, rewritable_length); ParseArrowFunctionLiteral(accept_IN, formals, rewritable_length);
ok = !scanner_.has_parser_error_set(); ok = !scanner_.has_parser_error();
if (ok) { if (ok) {
// Scanning must end at the same position that was recorded // Scanning must end at the same position that was recorded
// previously. If not, parsing has been interrupted due to a stack // previously. If not, parsing has been interrupted due to a stack
...@@ -885,10 +885,10 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info, ...@@ -885,10 +885,10 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info,
raw_name, Scanner::Location::invalid(), kSkipFunctionNameCheck, kind, raw_name, Scanner::Location::invalid(), kSkipFunctionNameCheck, kind,
kNoSourcePosition, function_type, info->language_mode(), kNoSourcePosition, function_type, info->language_mode(),
arguments_for_wrapped_function); arguments_for_wrapped_function);
ok = !scanner_.has_parser_error_set(); ok = !scanner_.has_parser_error();
} }
DCHECK_EQ(ok, !scanner_.has_parser_error_set()); DCHECK_EQ(ok, !scanner_.has_parser_error());
if (ok) { if (ok) {
result->set_requires_instance_fields_initializer( result->set_requires_instance_fields_initializer(
info->requires_instance_fields_initializer()); info->requires_instance_fields_initializer());
...@@ -1461,7 +1461,7 @@ Declaration* Parser::DeclareVariable(const AstRawString* name, ...@@ -1461,7 +1461,7 @@ Declaration* Parser::DeclareVariable(const AstRawString* name,
} }
Declare(declaration, DeclarationDescriptor::NORMAL, mode, init, nullptr, Declare(declaration, DeclarationDescriptor::NORMAL, mode, init, nullptr,
scanner()->location().end_pos); scanner()->location().end_pos);
if (scanner()->has_parser_error_set()) return nullptr; if (scanner()->has_parser_error()) return nullptr;
return declaration; return declaration;
} }
...@@ -1477,7 +1477,7 @@ Variable* Parser::Declare(Declaration* declaration, ...@@ -1477,7 +1477,7 @@ Variable* Parser::Declare(Declaration* declaration,
Variable* variable = scope->DeclareVariable( Variable* variable = scope->DeclareVariable(
declaration, mode, init, &sloppy_mode_block_scope_function_redefinition, declaration, mode, init, &sloppy_mode_block_scope_function_redefinition,
&local_ok); &local_ok);
if (!local_ok | scanner()->has_parser_error_set()) { if (!local_ok | scanner()->has_parser_error()) {
// If we only have the start position of a proxy, we can't highlight the // If we only have the start position of a proxy, we can't highlight the
// whole variable name. Pretend its length is 1 so that we highlight at // whole variable name. Pretend its length is 1 so that we highlight at
// least the first character. // least the first character.
...@@ -1788,7 +1788,7 @@ void Parser::ParseAndRewriteGeneratorFunctionBody( ...@@ -1788,7 +1788,7 @@ void Parser::ParseAndRewriteGeneratorFunctionBody(
Expression* initial_yield = BuildInitialYield(pos, kind); Expression* initial_yield = BuildInitialYield(pos, kind);
body->Add(factory()->NewExpressionStatement(initial_yield, kNoSourcePosition), body->Add(factory()->NewExpressionStatement(initial_yield, kNoSourcePosition),
zone()); zone());
ParseStatementList(body, Token::RBRACE, !scanner()->has_parser_error_set()); ParseStatementList(body, Token::RBRACE, !scanner()->has_parser_error());
} }
void Parser::ParseAndRewriteAsyncGeneratorFunctionBody( void Parser::ParseAndRewriteAsyncGeneratorFunctionBody(
...@@ -1821,7 +1821,7 @@ void Parser::ParseAndRewriteAsyncGeneratorFunctionBody( ...@@ -1821,7 +1821,7 @@ void Parser::ParseAndRewriteAsyncGeneratorFunctionBody(
factory()->NewExpressionStatement(initial_yield, kNoSourcePosition), factory()->NewExpressionStatement(initial_yield, kNoSourcePosition),
zone()); zone());
ParseStatementList(try_block->statements(), Token::RBRACE, ParseStatementList(try_block->statements(), Token::RBRACE,
!scanner()->has_parser_error_set()); !scanner()->has_parser_error());
RETURN_IF_PARSE_ERROR_VOID; RETURN_IF_PARSE_ERROR_VOID;
// Don't create iterator result for async generators, as the resume methods // Don't create iterator result for async generators, as the resume methods
...@@ -2843,7 +2843,7 @@ bool Parser::SkipFunction( ...@@ -2843,7 +2843,7 @@ bool Parser::SkipFunction(
pending_error_handler()->clear_unidentifiable_error(); pending_error_handler()->clear_unidentifiable_error();
return false; return false;
} else if (pending_error_handler()->has_pending_error()) { } else if (pending_error_handler()->has_pending_error()) {
DCHECK(scanner()->has_parser_error_set()); DCHECK(scanner()->has_parser_error());
} else { } else {
set_allow_eval_cache(reusable_preparser()->allow_eval_cache()); set_allow_eval_cache(reusable_preparser()->allow_eval_cache());
......
...@@ -498,7 +498,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { ...@@ -498,7 +498,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
} }
void AddExpression(Expression* expression, Zone* zone) { void AddExpression(Expression* expression, Zone* zone) {
DCHECK_NOT_NULL(expression);
expressions_.Add(expression, zone); expressions_.Add(expression, zone);
} }
......
...@@ -237,7 +237,7 @@ void PatternRewriter::VisitVariableProxy(VariableProxy* pattern) { ...@@ -237,7 +237,7 @@ void PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
declaration, descriptor_->declaration_kind, descriptor_->mode, declaration, descriptor_->declaration_kind, descriptor_->mode,
Variable::DefaultInitializationFlag(descriptor_->mode), Variable::DefaultInitializationFlag(descriptor_->mode),
outer_function_scope); outer_function_scope);
if (parser_->scanner_.has_parser_error_set()) return; if (parser_->scanner_.has_parser_error()) return;
DCHECK_NOT_NULL(var); DCHECK_NOT_NULL(var);
DCHECK(proxy->is_resolved()); DCHECK(proxy->is_resolved());
DCHECK_NE(initializer_position_, kNoSourcePosition); DCHECK_NE(initializer_position_, kNoSourcePosition);
......
...@@ -21,7 +21,7 @@ namespace internal { ...@@ -21,7 +21,7 @@ namespace internal {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// The RETURN_IF_PARSE_ERROR macro is a convenient macro to enforce error // The RETURN_IF_PARSE_ERROR macro is a convenient macro to enforce error
// handling for functions that may fail (by returning if there was an parser // handling for functions that may fail (by returning if there was an parser
// error scanner()->has_parser_error_set). // error scanner()->has_parser_error).
// //
// Usage: // Usage:
// foo = ParseFoo(); // may fail // foo = ParseFoo(); // may fail
...@@ -30,7 +30,7 @@ namespace internal { ...@@ -30,7 +30,7 @@ namespace internal {
// SAFE_USE(foo); // SAFE_USE(foo);
#define RETURN_IF_PARSE_ERROR_VALUE(x) \ #define RETURN_IF_PARSE_ERROR_VALUE(x) \
if (scanner()->has_parser_error_set()) { \ if (scanner()->has_parser_error()) { \
return x; \ return x; \
} }
...@@ -104,7 +104,7 @@ PreParser::PreParseResult PreParser::PreParseProgram() { ...@@ -104,7 +104,7 @@ PreParser::PreParseResult PreParser::PreParseProgram() {
int start_position = scanner()->peek_location().beg_pos; int start_position = scanner()->peek_location().beg_pos;
PreParserStatementList body; PreParserStatementList body;
ParseStatementList(body, Token::EOS); ParseStatementList(body, Token::EOS);
ok = !scanner()->has_parser_error_set(); ok = !scanner()->has_parser_error();
original_scope_ = nullptr; original_scope_ = nullptr;
if (stack_overflow()) return kPreParseStackOverflow; if (stack_overflow()) return kPreParseStackOverflow;
if (!ok) { if (!ok) {
...@@ -219,7 +219,7 @@ PreParser::PreParseResult PreParser::PreParseFunction( ...@@ -219,7 +219,7 @@ PreParser::PreParseResult PreParser::PreParseFunction(
return kPreParseStackOverflow; return kPreParseStackOverflow;
} else if (pending_error_handler()->has_error_unidentifiable_by_preparser()) { } else if (pending_error_handler()->has_error_unidentifiable_by_preparser()) {
return kPreParseNotIdentifiableError; return kPreParseNotIdentifiableError;
} else if (scanner()->has_parser_error_set()) { } else if (scanner()->has_parser_error()) {
DCHECK(pending_error_handler()->has_pending_error()); DCHECK(pending_error_handler()->has_pending_error());
} else { } else {
DCHECK_EQ(Token::RBRACE, scanner()->peek()); DCHECK_EQ(Token::RBRACE, scanner()->peek());
...@@ -229,7 +229,7 @@ PreParser::PreParseResult PreParser::PreParseFunction( ...@@ -229,7 +229,7 @@ PreParser::PreParseResult PreParser::PreParseFunction(
// Validate parameter names. We can do this only after parsing the // Validate parameter names. We can do this only after parsing the
// function, since the function can declare itself strict. // function, since the function can declare itself strict.
ValidateFormalParameters(language_mode(), allow_duplicate_parameters); ValidateFormalParameters(language_mode(), allow_duplicate_parameters);
if (scanner()->has_parser_error_set()) { if (scanner()->has_parser_error()) {
if (pending_error_handler()->has_error_unidentifiable_by_preparser()) { if (pending_error_handler()->has_error_unidentifiable_by_preparser()) {
return kPreParseNotIdentifiableError; return kPreParseNotIdentifiableError;
} else { } else {
......
...@@ -544,6 +544,7 @@ void Scanner::Scan() { ...@@ -544,6 +544,7 @@ void Scanner::Scan() {
next().invalid_template_escape_message = MessageTemplate::kNone; next().invalid_template_escape_message = MessageTemplate::kNone;
next().token = ScanSingleToken(); next().token = ScanSingleToken();
DCHECK_IMPLIES(has_parser_error(), next().token == Token::ILLEGAL);
next().location.end_pos = source_pos(); next().location.end_pos = source_pos();
#ifdef DEBUG #ifdef DEBUG
......
...@@ -214,7 +214,7 @@ class Scanner { ...@@ -214,7 +214,7 @@ class Scanner {
explicit BookmarkScope(Scanner* scanner) explicit BookmarkScope(Scanner* scanner)
: scanner_(scanner), : scanner_(scanner),
bookmark_(kNoBookmark), bookmark_(kNoBookmark),
had_parser_error_(scanner->has_parser_error_set()) { had_parser_error_(scanner->has_parser_error()) {
DCHECK_NOT_NULL(scanner_); DCHECK_NOT_NULL(scanner_);
} }
~BookmarkScope() = default; ~BookmarkScope() = default;
...@@ -251,7 +251,7 @@ class Scanner { ...@@ -251,7 +251,7 @@ class Scanner {
V8_INLINE void reset_parser_error_flag() { V8_INLINE void reset_parser_error_flag() {
source_->reset_parser_error_flag(); source_->reset_parser_error_flag();
} }
V8_INLINE bool has_parser_error_set() const { V8_INLINE bool has_parser_error() const {
return source_->has_parser_error(); return source_->has_parser_error();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment