[parser] Use has_error rather than has_parser_error and inline.
Bug: v8:7926 Change-Id: Icbdd05b799afd26a8eaaa67905516d82f4b1d2bd Reviewed-on: https://chromium-review.googlesource.com/c/1309815 Commit-Queue: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Igor Sheludko <ishell@chromium.org> Cr-Commit-Position: refs/heads/master@{#57168}
This commit is contained in:
parent
ed2dd24087
commit
6627bdb14c
@ -98,7 +98,7 @@ class SourceRangeScope final {
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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
|
||||
// error scanner()->has_parser_error()).
|
||||
// error).
|
||||
//
|
||||
// Usage:
|
||||
// foo = ParseFoo(); // may fail
|
||||
@ -274,7 +274,7 @@ class ParserBase {
|
||||
|
||||
#undef ALLOW_ACCESSORS
|
||||
|
||||
bool has_error() const { return scanner()->has_parser_error(); }
|
||||
V8_INLINE bool has_error() const { return scanner()->has_parser_error(); }
|
||||
bool allow_harmony_numeric_separator() const {
|
||||
return scanner()->allow_harmony_numeric_separator();
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ void Parser::GetUnexpectedTokenMessage(Token::Value token,
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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
|
||||
// error scanner()->has_parser_error()).
|
||||
// error).
|
||||
//
|
||||
// Usage:
|
||||
// foo = ParseFoo(); // may fail
|
||||
@ -148,13 +148,11 @@ void Parser::GetUnexpectedTokenMessage(Token::Value token,
|
||||
// SAFE_USE(foo);
|
||||
|
||||
#define RETURN_IF_PARSE_ERROR_VALUE(x) \
|
||||
if (scanner()->has_parser_error()) { \
|
||||
return x; \
|
||||
}
|
||||
if (has_error()) return x;
|
||||
|
||||
#define RETURN_IF_PARSE_ERROR RETURN_IF_PARSE_ERROR_VALUE(nullptr)
|
||||
#define RETURN_IF_PARSE_ERROR_VOID \
|
||||
if (scanner()->has_parser_error()) return;
|
||||
if (has_error()) return;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Implementation of Parser
|
||||
@ -590,9 +588,8 @@ FunctionLiteral* Parser::DoParseProgram(Isolate* isolate, ParseInfo* info) {
|
||||
zone());
|
||||
|
||||
ParseModuleItemList(body);
|
||||
ok = !scanner_.has_parser_error() &&
|
||||
module()->Validate(this->scope()->AsModuleScope(),
|
||||
pending_error_handler(), zone());
|
||||
ok = !has_error() && module()->Validate(this->scope()->AsModuleScope(),
|
||||
pending_error_handler(), zone());
|
||||
} else if (info->is_wrapped_as_function()) {
|
||||
ParseWrapped(isolate, info, body, scope, zone(), &ok);
|
||||
} else {
|
||||
@ -601,7 +598,7 @@ FunctionLiteral* Parser::DoParseProgram(Isolate* isolate, ParseInfo* info) {
|
||||
this->scope()->SetLanguageMode(info->language_mode());
|
||||
ParseStatementList(body, Token::EOS);
|
||||
}
|
||||
ok = ok && !scanner_.has_parser_error();
|
||||
ok = ok && !has_error();
|
||||
|
||||
// The parser will peek but not consume EOS. Our scope logically goes all
|
||||
// the way to the EOS, though.
|
||||
@ -609,7 +606,7 @@ FunctionLiteral* Parser::DoParseProgram(Isolate* isolate, ParseInfo* info) {
|
||||
|
||||
if (ok && is_strict(language_mode())) {
|
||||
CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos);
|
||||
ok = !scanner_.has_parser_error();
|
||||
ok = !has_error();
|
||||
}
|
||||
if (ok && is_sloppy(language_mode())) {
|
||||
// TODO(littledan): Function bindings on the global object that modify
|
||||
@ -620,7 +617,7 @@ FunctionLiteral* Parser::DoParseProgram(Isolate* isolate, ParseInfo* info) {
|
||||
}
|
||||
if (ok) {
|
||||
CheckConflictingVarDeclarations(scope);
|
||||
ok = !scanner_.has_parser_error();
|
||||
ok = !has_error();
|
||||
}
|
||||
|
||||
if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) {
|
||||
@ -816,12 +813,12 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info,
|
||||
if (Check(Token::LPAREN)) {
|
||||
// '(' StrictFormalParameters ')'
|
||||
ParseFormalParameterList(&formals);
|
||||
ok = !scanner_.has_parser_error();
|
||||
ok = !has_error();
|
||||
if (ok) ok = Check(Token::RPAREN);
|
||||
} else {
|
||||
// BindingIdentifier
|
||||
ParseFormalParameter(&formals);
|
||||
ok = !scanner_.has_parser_error();
|
||||
ok = !has_error();
|
||||
if (ok) {
|
||||
DeclareFormalParameters(&formals);
|
||||
}
|
||||
@ -854,7 +851,7 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info,
|
||||
const int rewritable_length = 0;
|
||||
Expression* expression =
|
||||
ParseArrowFunctionLiteral(accept_IN, formals, rewritable_length);
|
||||
ok = !scanner_.has_parser_error();
|
||||
ok = !has_error();
|
||||
if (ok) {
|
||||
// Scanning must end at the same position that was recorded
|
||||
// previously. If not, parsing has been interrupted due to a stack
|
||||
@ -885,10 +882,10 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info,
|
||||
raw_name, Scanner::Location::invalid(), kSkipFunctionNameCheck, kind,
|
||||
kNoSourcePosition, function_type, info->language_mode(),
|
||||
arguments_for_wrapped_function);
|
||||
ok = !scanner_.has_parser_error();
|
||||
ok = !has_error();
|
||||
}
|
||||
|
||||
DCHECK_EQ(ok, !scanner_.has_parser_error());
|
||||
DCHECK_EQ(ok, !has_error());
|
||||
if (ok) {
|
||||
result->set_requires_instance_fields_initializer(
|
||||
info->requires_instance_fields_initializer());
|
||||
@ -1735,7 +1732,7 @@ void Parser::ParseAndRewriteGeneratorFunctionBody(
|
||||
Expression* initial_yield = BuildInitialYield(pos, kind);
|
||||
body->Add(factory()->NewExpressionStatement(initial_yield, kNoSourcePosition),
|
||||
zone());
|
||||
ParseStatementList(body, Token::RBRACE, !scanner()->has_parser_error());
|
||||
ParseStatementList(body, Token::RBRACE, !has_error());
|
||||
}
|
||||
|
||||
void Parser::ParseAndRewriteAsyncGeneratorFunctionBody(
|
||||
@ -1767,8 +1764,7 @@ void Parser::ParseAndRewriteAsyncGeneratorFunctionBody(
|
||||
try_block->statements()->Add(
|
||||
factory()->NewExpressionStatement(initial_yield, kNoSourcePosition),
|
||||
zone());
|
||||
ParseStatementList(try_block->statements(), Token::RBRACE,
|
||||
!scanner()->has_parser_error());
|
||||
ParseStatementList(try_block->statements(), Token::RBRACE, !has_error());
|
||||
|
||||
// Don't create iterator result for async generators, as the resume methods
|
||||
// will create it.
|
||||
@ -2780,7 +2776,7 @@ bool Parser::SkipFunction(
|
||||
return false;
|
||||
} else if (pending_error_handler()->has_pending_error()) {
|
||||
DCHECK(!pending_error_handler()->stack_overflow());
|
||||
DCHECK(scanner()->has_parser_error());
|
||||
DCHECK(has_error());
|
||||
} else {
|
||||
DCHECK(!pending_error_handler()->stack_overflow());
|
||||
set_allow_eval_cache(reusable_preparser()->allow_eval_cache());
|
||||
|
@ -237,7 +237,7 @@ void PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
|
||||
declaration, descriptor_->declaration_kind, descriptor_->mode,
|
||||
Variable::DefaultInitializationFlag(descriptor_->mode),
|
||||
outer_function_scope);
|
||||
if (parser_->scanner_.has_parser_error()) return;
|
||||
if (parser_->has_error()) return;
|
||||
DCHECK_NOT_NULL(var);
|
||||
DCHECK(proxy->is_resolved());
|
||||
DCHECK_NE(initializer_position_, kNoSourcePosition);
|
||||
|
@ -85,7 +85,7 @@ PreParser::PreParseResult PreParser::PreParseProgram() {
|
||||
int start_position = scanner()->peek_location().beg_pos;
|
||||
PreParserStatementList body;
|
||||
ParseStatementList(body, Token::EOS);
|
||||
ok = !scanner()->has_parser_error();
|
||||
ok = !has_error();
|
||||
original_scope_ = nullptr;
|
||||
if (stack_overflow()) return kPreParseStackOverflow;
|
||||
if (!ok) {
|
||||
@ -190,7 +190,7 @@ PreParser::PreParseResult PreParser::PreParseFunction(
|
||||
return kPreParseStackOverflow;
|
||||
} else if (pending_error_handler()->has_error_unidentifiable_by_preparser()) {
|
||||
return kPreParseNotIdentifiableError;
|
||||
} else if (scanner()->has_parser_error()) {
|
||||
} else if (has_error()) {
|
||||
DCHECK(pending_error_handler()->has_pending_error());
|
||||
} else if (result == kLazyParsingAborted) {
|
||||
DCHECK(!pending_error_handler()->has_error_unidentifiable_by_preparser());
|
||||
@ -203,7 +203,7 @@ PreParser::PreParseResult PreParser::PreParseFunction(
|
||||
// Validate parameter names. We can do this only after parsing the
|
||||
// function, since the function can declare itself strict.
|
||||
ValidateFormalParameters(language_mode(), allow_duplicate_parameters);
|
||||
if (scanner()->has_parser_error()) {
|
||||
if (has_error()) {
|
||||
if (pending_error_handler()->has_error_unidentifiable_by_preparser()) {
|
||||
return kPreParseNotIdentifiableError;
|
||||
} else {
|
||||
|
@ -239,7 +239,7 @@ class Scanner {
|
||||
// Sets the Scanner into an error state to stop further scanning and terminate
|
||||
// the parsing by only returning ILLEGAL tokens after that.
|
||||
V8_INLINE void set_parser_error() {
|
||||
if (!source_->has_parser_error()) {
|
||||
if (!has_parser_error()) {
|
||||
c0_ = kEndOfInput;
|
||||
source_->set_parser_error();
|
||||
for (TokenDesc& desc : token_storage_) {
|
||||
|
Loading…
Reference in New Issue
Block a user