| Index: src/parsing/parser.cc
|
| diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
|
| index 0aa62c59d8e6cefac0ed4654f7083ddc26a5dc4d..2418e78187df22c6d909d35cd5f8d92714d2cb7f 100644
|
| --- a/src/parsing/parser.cc
|
| +++ b/src/parsing/parser.cc
|
| @@ -308,15 +308,14 @@ class TargetScope BASE_EMBEDDED {
|
| // thus it must never be used where only a single statement
|
| // is correct (e.g. an if statement branch w/o braces)!
|
|
|
| -#define CHECK_OK ok); \
|
| - if (!*ok) return NULL; \
|
| +#define CHECK_OK ok); \
|
| + if (!*ok) return nullptr; \
|
| ((void)0
|
| #define DUMMY ) // to make indentation work
|
| #undef DUMMY
|
|
|
| -// Used in functions where the return type is not ExpressionT.
|
| -#define CHECK_OK_CUSTOM(x) ok); \
|
| - if (!*ok) return this->x(); \
|
| +#define CHECK_OK_VOID ok); \
|
| + if (!*ok) return; \
|
| ((void)0
|
| #define DUMMY ) // to make indentation work
|
| #undef DUMMY
|
| @@ -1201,8 +1200,8 @@ FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info,
|
| }
|
|
|
|
|
| -void* Parser::ParseStatementList(ZoneList<Statement*>* body, int end_token,
|
| - bool* ok) {
|
| +void Parser::ParseStatementList(ZoneList<Statement*>* body, int end_token,
|
| + bool* ok) {
|
| // StatementList ::
|
| // (StatementListItem)* <end_token>
|
|
|
| @@ -1221,7 +1220,7 @@ void* Parser::ParseStatementList(ZoneList<Statement*>* body, int end_token,
|
| }
|
|
|
| Scanner::Location token_loc = scanner()->peek_location();
|
| - Statement* stat = ParseStatementListItem(CHECK_OK);
|
| + Statement* stat = ParseStatementListItem(CHECK_OK_VOID);
|
| if (stat == NULL || stat->IsEmpty()) {
|
| directive_prologue = false; // End of directive prologue.
|
| continue;
|
| @@ -1255,7 +1254,7 @@ void* Parser::ParseStatementList(ZoneList<Statement*>* body, int end_token,
|
| token_loc, MessageTemplate::kIllegalLanguageModeDirective,
|
| string);
|
| *ok = false;
|
| - return nullptr;
|
| + return;
|
| }
|
| // Because declarations in strict eval code don't leak into the scope
|
| // of the eval call, it is likely that functions declared in strict
|
| @@ -1286,8 +1285,6 @@ void* Parser::ParseStatementList(ZoneList<Statement*>* body, int end_token,
|
|
|
| body->Add(stat, zone());
|
| }
|
| -
|
| - return 0;
|
| }
|
|
|
|
|
| @@ -1345,7 +1342,7 @@ Statement* Parser::ParseModuleItem(bool* ok) {
|
| }
|
|
|
|
|
| -void* Parser::ParseModuleItemList(ZoneList<Statement*>* body, bool* ok) {
|
| +void Parser::ParseModuleItemList(ZoneList<Statement*>* body, bool* ok) {
|
| // ecma262/#prod-Module
|
| // Module :
|
| // ModuleBody?
|
| @@ -1356,12 +1353,11 @@ void* Parser::ParseModuleItemList(ZoneList<Statement*>* body, bool* ok) {
|
|
|
| DCHECK(scope_->is_module_scope());
|
| while (peek() != Token::EOS) {
|
| - Statement* stat = ParseModuleItem(CHECK_OK);
|
| + Statement* stat = ParseModuleItem(CHECK_OK_VOID);
|
| if (stat && !stat->IsEmpty()) {
|
| body->Add(stat, zone());
|
| }
|
| }
|
| - return nullptr;
|
| }
|
|
|
|
|
| @@ -1374,10 +1370,10 @@ const AstRawString* Parser::ParseModuleSpecifier(bool* ok) {
|
| }
|
|
|
|
|
| -void* Parser::ParseExportClause(ZoneList<const AstRawString*>* export_names,
|
| - ZoneList<Scanner::Location>* export_locations,
|
| - ZoneList<const AstRawString*>* local_names,
|
| - Scanner::Location* reserved_loc, bool* ok) {
|
| +void Parser::ParseExportClause(ZoneList<const AstRawString*>* export_names,
|
| + ZoneList<Scanner::Location>* export_locations,
|
| + ZoneList<const AstRawString*>* local_names,
|
| + Scanner::Location* reserved_loc, bool* ok) {
|
| // ExportClause :
|
| // '{' '}'
|
| // '{' ExportsList '}'
|
| @@ -1391,7 +1387,7 @@ void* Parser::ParseExportClause(ZoneList<const AstRawString*>* export_names,
|
| // IdentifierName
|
| // IdentifierName 'as' IdentifierName
|
|
|
| - Expect(Token::LBRACE, CHECK_OK);
|
| + Expect(Token::LBRACE, CHECK_OK_VOID);
|
|
|
| Token::Value name_tok;
|
| while ((name_tok = peek()) != Token::RBRACE) {
|
| @@ -1401,10 +1397,10 @@ void* Parser::ParseExportClause(ZoneList<const AstRawString*>* export_names,
|
| !Token::IsIdentifier(name_tok, STRICT, false, parsing_module_)) {
|
| *reserved_loc = scanner()->location();
|
| }
|
| - const AstRawString* local_name = ParseIdentifierName(CHECK_OK);
|
| + const AstRawString* local_name = ParseIdentifierName(CHECK_OK_VOID);
|
| const AstRawString* export_name = NULL;
|
| if (CheckContextualKeyword(CStrVector("as"))) {
|
| - export_name = ParseIdentifierName(CHECK_OK);
|
| + export_name = ParseIdentifierName(CHECK_OK_VOID);
|
| }
|
| if (export_name == NULL) {
|
| export_name = local_name;
|
| @@ -1413,12 +1409,10 @@ void* Parser::ParseExportClause(ZoneList<const AstRawString*>* export_names,
|
| local_names->Add(local_name, zone());
|
| export_locations->Add(scanner()->location(), zone());
|
| if (peek() == Token::RBRACE) break;
|
| - Expect(Token::COMMA, CHECK_OK);
|
| + Expect(Token::COMMA, CHECK_OK_VOID);
|
| }
|
|
|
| - Expect(Token::RBRACE, CHECK_OK);
|
| -
|
| - return nullptr;
|
| + Expect(Token::RBRACE, CHECK_OK_VOID);
|
| }
|
|
|
|
|
| @@ -1475,7 +1469,7 @@ ZoneList<const Parser::NamedImport*>* Parser::ParseNamedImports(
|
| }
|
|
|
|
|
| -void* Parser::ParseImportDeclaration(bool* ok) {
|
| +void Parser::ParseImportDeclaration(bool* ok) {
|
| // ImportDeclaration :
|
| // 'import' ImportClause 'from' ModuleSpecifier ';'
|
| // 'import' ModuleSpecifier ';'
|
| @@ -1491,17 +1485,17 @@ void* Parser::ParseImportDeclaration(bool* ok) {
|
| // '*' 'as' ImportedBinding
|
|
|
| int pos = peek_position();
|
| - Expect(Token::IMPORT, CHECK_OK);
|
| + Expect(Token::IMPORT, CHECK_OK_VOID);
|
|
|
| Token::Value tok = peek();
|
|
|
| // 'import' ModuleSpecifier ';'
|
| if (tok == Token::STRING) {
|
| - const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK);
|
| - ExpectSemicolon(CHECK_OK);
|
| + const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK_VOID);
|
| + ExpectSemicolon(CHECK_OK_VOID);
|
| scope_->module()->AddEmptyImport(
|
| module_specifier, scanner()->location(), zone());
|
| - return nullptr;
|
| + return;
|
| }
|
|
|
| // Parse ImportedDefaultBinding if present.
|
| @@ -1509,9 +1503,9 @@ void* Parser::ParseImportDeclaration(bool* ok) {
|
| Scanner::Location import_default_binding_loc;
|
| if (tok != Token::MUL && tok != Token::LBRACE) {
|
| import_default_binding =
|
| - ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK);
|
| + ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK_VOID);
|
| import_default_binding_loc = scanner()->location();
|
| - DeclareImport(import_default_binding, pos, CHECK_OK);
|
| + DeclareImport(import_default_binding, pos, CHECK_OK_VOID);
|
| }
|
|
|
| // Parse NameSpaceImport or NamedImports if present.
|
| @@ -1522,27 +1516,27 @@ void* Parser::ParseImportDeclaration(bool* ok) {
|
| switch (peek()) {
|
| case Token::MUL: {
|
| Consume(Token::MUL);
|
| - ExpectContextualKeyword(CStrVector("as"), CHECK_OK);
|
| + ExpectContextualKeyword(CStrVector("as"), CHECK_OK_VOID);
|
| module_namespace_binding =
|
| - ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK);
|
| + ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK_VOID);
|
| module_namespace_binding_loc = scanner()->location();
|
| break;
|
| }
|
|
|
| case Token::LBRACE:
|
| - named_imports = ParseNamedImports(pos, CHECK_OK);
|
| + named_imports = ParseNamedImports(pos, CHECK_OK_VOID);
|
| break;
|
|
|
| default:
|
| *ok = false;
|
| ReportUnexpectedToken(scanner()->current_token());
|
| - return nullptr;
|
| + return;
|
| }
|
| }
|
|
|
| - ExpectContextualKeyword(CStrVector("from"), CHECK_OK);
|
| - const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK);
|
| - ExpectSemicolon(CHECK_OK);
|
| + ExpectContextualKeyword(CStrVector("from"), CHECK_OK_VOID);
|
| + const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK_VOID);
|
| + ExpectSemicolon(CHECK_OK_VOID);
|
|
|
| // Now that we have all the information, we can make the appropriate
|
| // declarations.
|
| @@ -1563,7 +1557,7 @@ void* Parser::ParseImportDeclaration(bool* ok) {
|
| scope_->module()->AddImport(
|
| ast_value_factory()->default_string(), import_default_binding,
|
| module_specifier, import_default_binding_loc, zone());
|
| - // DeclareImport(import_default_binding, pos, CHECK_OK);
|
| + // DeclareImport(import_default_binding, pos, CHECK_OK_VOID);
|
| }
|
|
|
| if (named_imports != nullptr) {
|
| @@ -1576,12 +1570,10 @@ void* Parser::ParseImportDeclaration(bool* ok) {
|
| scope_->module()->AddImport(
|
| import->import_name, import->local_name,
|
| module_specifier, import->location, zone());
|
| - // DeclareImport(import->local_name, pos, CHECK_OK);
|
| + // DeclareImport(import->local_name, pos, CHECK_OK_VOID);
|
| }
|
| }
|
| }
|
| -
|
| - return nullptr;
|
| }
|
|
|
|
|
| @@ -1918,13 +1910,12 @@ VariableProxy* Parser::NewUnresolved(const AstRawString* name,
|
| }
|
|
|
|
|
| -void* Parser::DeclareImport(const AstRawString* local_name, int pos, bool* ok) {
|
| +void Parser::DeclareImport(const AstRawString* local_name, int pos, bool* ok) {
|
| DCHECK_NOT_NULL(local_name);
|
| VariableProxy* proxy = NewUnresolved(local_name, IMPORT);
|
| Declaration* declaration =
|
| factory()->NewVariableDeclaration(proxy, IMPORT, scope_, pos);
|
| - Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK);
|
| - return nullptr;
|
| + Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK_VOID);
|
| }
|
|
|
|
|
| @@ -4096,7 +4087,7 @@ void ParserTraits::ParseArrowFunctionFormalParameters(
|
| Expression* right = binop->right();
|
| int comma_pos = binop->position();
|
| ParseArrowFunctionFormalParameters(parameters, left, comma_pos,
|
| - CHECK_OK_CUSTOM(Void));
|
| + CHECK_OK_VOID);
|
| // LHS of comma expression should be unparenthesized.
|
| expr = right;
|
| }
|
| @@ -4175,12 +4166,12 @@ void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name,
|
|
|
| Expression* return_value = nullptr;
|
| if (body_type == FunctionBody::Normal) {
|
| - ParseStatementList(inner_body, Token::RBRACE, CHECK_OK_CUSTOM(Void));
|
| + ParseStatementList(inner_body, Token::RBRACE, CHECK_OK_VOID);
|
| return_value = factory()->NewUndefinedLiteral(kNoSourcePosition);
|
| } else {
|
| return_value =
|
| - ParseAssignmentExpression(accept_IN, classifier, CHECK_OK_CUSTOM(Void));
|
| - ParserTraits::RewriteNonPattern(classifier, CHECK_OK_CUSTOM(Void));
|
| + ParseAssignmentExpression(accept_IN, classifier, CHECK_OK_VOID);
|
| + ParserTraits::RewriteNonPattern(classifier, CHECK_OK_VOID);
|
| }
|
|
|
| return_value = BuildPromiseResolve(return_value, return_value->position());
|
| @@ -4217,7 +4208,7 @@ void ParserTraits::ParseArrowFunctionFormalParameterList(
|
| if (expr->IsEmptyParentheses()) return;
|
|
|
| ParseArrowFunctionFormalParameters(parameters, expr, params_loc.end_pos,
|
| - CHECK_OK_CUSTOM(Void));
|
| + CHECK_OK_VOID);
|
|
|
| if (parameters->Arity() > Code::kMaxArguments) {
|
| ReportMessageAt(params_loc, MessageTemplate::kMalformedArrowFunParamList);
|
| @@ -4541,7 +4532,7 @@ void Parser::SkipLazyFunctionBody(int* materialized_literal_count,
|
| scanner()->SeekForward(entry.end_pos() - 1);
|
|
|
| scope_->set_end_position(entry.end_pos());
|
| - Expect(Token::RBRACE, CHECK_OK_CUSTOM(Void));
|
| + Expect(Token::RBRACE, CHECK_OK_VOID);
|
| total_preparse_skipped_ += scope_->end_position() - function_block_pos;
|
| *materialized_literal_count = entry.literal_count();
|
| *expected_property_count = entry.property_count();
|
| @@ -4574,7 +4565,7 @@ void Parser::SkipLazyFunctionBody(int* materialized_literal_count,
|
| return;
|
| }
|
| scope_->set_end_position(logger.end());
|
| - Expect(Token::RBRACE, CHECK_OK_CUSTOM(Void));
|
| + Expect(Token::RBRACE, CHECK_OK_VOID);
|
| total_preparse_skipped_ += scope_->end_position() - function_block_pos;
|
| *materialized_literal_count = logger.literals();
|
| *expected_property_count = logger.properties();
|
| @@ -5863,7 +5854,7 @@ class NonPatternRewriter : public AstExpressionRewriter {
|
|
|
|
|
| void Parser::RewriteNonPattern(ExpressionClassifier* classifier, bool* ok) {
|
| - ValidateExpression(classifier, CHECK_OK_CUSTOM(Void));
|
| + ValidateExpression(classifier, CHECK_OK_VOID);
|
| auto non_patterns_to_rewrite = function_state_->non_patterns_to_rewrite();
|
| int begin = classifier->GetNonPatternBegin();
|
| int end = non_patterns_to_rewrite->length();
|
| @@ -7065,7 +7056,7 @@ void Parser::Print(AstNode* node) {
|
| #endif // DEBUG
|
|
|
| #undef CHECK_OK
|
| -#undef CHECK_OK_CUSTOM
|
| +#undef CHECK_OK_VOID
|
| #undef CHECK_FAILED
|
|
|
| } // namespace internal
|
|
|