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

[parser] Remove RETURN_IF* part 5

Bug: v8:8363, v8:7926
Change-Id: Ia1662720a9a6f9b688dd097718597b44425bb134
Reviewed-on: https://chromium-review.googlesource.com/c/1299017
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56994}
parent 7bd9eb7e
...@@ -3646,7 +3646,6 @@ void ParserBase<Impl>::ParseFormalParameterList(FormalParametersT* parameters) { ...@@ -3646,7 +3646,6 @@ void ParserBase<Impl>::ParseFormalParameterList(FormalParametersT* parameters) {
} }
parameters->has_rest = Check(Token::ELLIPSIS); parameters->has_rest = Check(Token::ELLIPSIS);
ParseFormalParameter(parameters); ParseFormalParameter(parameters);
RETURN_IF_PARSE_ERROR_CUSTOM(Void);
if (parameters->has_rest) { if (parameters->has_rest) {
parameters->is_simple = false; parameters->is_simple = false;
...@@ -3666,6 +3665,7 @@ void ParserBase<Impl>::ParseFormalParameterList(FormalParametersT* parameters) { ...@@ -3666,6 +3665,7 @@ void ParserBase<Impl>::ParseFormalParameterList(FormalParametersT* parameters) {
} }
} }
RETURN_IF_PARSE_ERROR_CUSTOM(Void);
impl()->DeclareFormalParameters(parameters); impl()->DeclareFormalParameters(parameters);
} }
...@@ -3727,11 +3727,12 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseVariableDeclarations( ...@@ -3727,11 +3727,12 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseVariableDeclarations(
if (IsLexicalVariableMode(parsing_result->descriptor.mode)) { if (IsLexicalVariableMode(parsing_result->descriptor.mode)) {
ValidateLetPattern(); ValidateLetPattern();
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
} }
} }
Scanner::Location variable_loc = scanner()->location(); Scanner::Location variable_loc = scanner()->location();
// TODO(verwaest): Remove once we have FailureExpression.
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
bool single_name = impl()->IsIdentifier(pattern); bool single_name = impl()->IsIdentifier(pattern);
if (single_name) { if (single_name) {
impl()->PushVariableName(impl()->AsIdentifier(pattern)); impl()->PushVariableName(impl()->AsIdentifier(pattern));
...@@ -3745,15 +3746,16 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseVariableDeclarations( ...@@ -3745,15 +3746,16 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseVariableDeclarations(
ExpressionClassifier classifier(this); ExpressionClassifier classifier(this);
value = ParseAssignmentExpression(var_context != kForStatement); value = ParseAssignmentExpression(var_context != kForStatement);
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
ValidateExpression(); ValidateExpression();
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
variable_loc.end_pos = end_position(); variable_loc.end_pos = end_position();
if (!parsing_result->first_initializer_loc.IsValid()) { if (!parsing_result->first_initializer_loc.IsValid()) {
parsing_result->first_initializer_loc = variable_loc; parsing_result->first_initializer_loc = variable_loc;
} }
// TODO(verwaest): Remove once we have FailureExpression.
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
// Don't infer if it is "a = function(){...}();"-like expression. // Don't infer if it is "a = function(){...}();"-like expression.
if (single_name) { if (single_name) {
if (!value->IsCall() && !value->IsCallNew()) { if (!value->IsCall() && !value->IsCallNew()) {
...@@ -3801,14 +3803,12 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseVariableDeclarations( ...@@ -3801,14 +3803,12 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseVariableDeclarations(
// and adding VariableProxies to the Scope (see bug 4699). // and adding VariableProxies to the Scope (see bug 4699).
impl()->DeclareAndInitializeVariables( impl()->DeclareAndInitializeVariables(
init_block, &parsing_result->descriptor, &decl, names); init_block, &parsing_result->descriptor, &decl, names);
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
} }
} while (Check(Token::COMMA)); } while (Check(Token::COMMA));
parsing_result->bindings_loc = parsing_result->bindings_loc =
Scanner::Location(bindings_start, end_position()); Scanner::Location(bindings_start, end_position());
DCHECK(!scanner()->has_parser_error_set());
return init_block; return init_block;
} }
...@@ -3878,13 +3878,14 @@ ParserBase<Impl>::ParseHoistableDeclaration( ...@@ -3878,13 +3878,14 @@ ParserBase<Impl>::ParseHoistableDeclaration(
bool is_strict_reserved; bool is_strict_reserved;
bool is_await = false; bool is_await = false;
name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved, &is_await); name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved, &is_await);
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
name_validity = is_strict_reserved ? kFunctionNameIsStrictReserved name_validity = is_strict_reserved ? kFunctionNameIsStrictReserved
: kFunctionNameValidityUnknown; : kFunctionNameValidityUnknown;
variable_name = name; variable_name = name;
} }
FuncNameInferrerState fni_state(&fni_); FuncNameInferrerState fni_state(&fni_);
// TODO(verwaest): Remove once we have FailureIdentifier.
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
impl()->PushEnclosingName(name); impl()->PushEnclosingName(name);
FunctionKind kind = FunctionKindFor(flags); FunctionKind kind = FunctionKindFor(flags);
...@@ -3892,7 +3893,6 @@ ParserBase<Impl>::ParseHoistableDeclaration( ...@@ -3892,7 +3893,6 @@ ParserBase<Impl>::ParseHoistableDeclaration(
FunctionLiteralT function = impl()->ParseFunctionLiteral( FunctionLiteralT function = impl()->ParseFunctionLiteral(
name, scanner()->location(), name_validity, kind, pos, name, scanner()->location(), name_validity, kind, pos,
FunctionLiteral::kDeclaration, language_mode(), nullptr); FunctionLiteral::kDeclaration, language_mode(), nullptr);
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
// In ES6, a function behaves as a lexical binding, except in // In ES6, a function behaves as a lexical binding, except in
// a script scope, or the initial scope of eval or another function. // a script scope, or the initial scope of eval or another function.
...@@ -3909,6 +3909,7 @@ ParserBase<Impl>::ParseHoistableDeclaration( ...@@ -3909,6 +3909,7 @@ ParserBase<Impl>::ParseHoistableDeclaration(
!scope()->is_declaration_scope() && !scope()->is_declaration_scope() &&
flags == ParseFunctionFlag::kIsNormal; flags == ParseFunctionFlag::kIsNormal;
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
return impl()->DeclareFunction(variable_name, function, mode, pos, return impl()->DeclareFunction(variable_name, function, mode, pos,
is_sloppy_block_function, names); is_sloppy_block_function, names);
} }
...@@ -3943,15 +3944,14 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseClassDeclaration( ...@@ -3943,15 +3944,14 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseClassDeclaration(
} else { } else {
bool is_await = false; bool is_await = false;
name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved, &is_await); name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved, &is_await);
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
variable_name = name; variable_name = name;
} }
ExpressionClassifier no_classifier(this); ExpressionClassifier no_classifier(this);
ExpressionT value = ParseClassLiteral(name, scanner()->location(), ExpressionT value = ParseClassLiteral(name, scanner()->location(),
is_strict_reserved, class_token_pos); is_strict_reserved, class_token_pos);
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
int end_pos = position(); int end_pos = position();
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
return impl()->DeclareClass(variable_name, value, names, class_token_pos, return impl()->DeclareClass(variable_name, value, names, class_token_pos,
end_pos); end_pos);
} }
...@@ -3969,17 +3969,13 @@ ParserBase<Impl>::ParseNativeDeclaration() { ...@@ -3969,17 +3969,13 @@ ParserBase<Impl>::ParseNativeDeclaration() {
Consume(Token::FUNCTION); Consume(Token::FUNCTION);
// Allow "eval" or "arguments" for backward compatibility. // Allow "eval" or "arguments" for backward compatibility.
IdentifierT name = ParseIdentifier(kAllowRestrictedIdentifiers); IdentifierT name = ParseIdentifier(kAllowRestrictedIdentifiers);
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
Expect(Token::LPAREN); Expect(Token::LPAREN);
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
if (peek() != Token::RPAREN) { if (peek() != Token::RPAREN) {
do { do {
ParseIdentifier(kAllowRestrictedIdentifiers); ParseIdentifier(kAllowRestrictedIdentifiers);
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
} while (Check(Token::COMMA)); } while (Check(Token::COMMA));
} }
Expect(Token::RPAREN); Expect(Token::RPAREN);
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
Expect(Token::SEMICOLON); Expect(Token::SEMICOLON);
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement); RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
return impl()->DeclareNative(name, pos); return impl()->DeclareNative(name, pos);
...@@ -4027,14 +4023,13 @@ void ParserBase<Impl>::ParseFunctionBody( ...@@ -4027,14 +4023,13 @@ void ParserBase<Impl>::ParseFunctionBody(
if (body_type == FunctionBodyType::kExpression) { if (body_type == FunctionBodyType::kExpression) {
ExpressionClassifier classifier(this); ExpressionClassifier classifier(this);
ExpressionT expression = ParseAssignmentExpression(accept_IN); ExpressionT expression = ParseAssignmentExpression(accept_IN);
RETURN_IF_PARSE_ERROR_VOID;
ValidateExpression(); ValidateExpression();
RETURN_IF_PARSE_ERROR_VOID;
// TODO(verwaest): Remove once we have FailureExpression.
RETURN_IF_PARSE_ERROR_VOID;
if (IsAsyncFunction(kind)) { if (IsAsyncFunction(kind)) {
BlockT block = factory()->NewBlock(1, true); BlockT block = factory()->NewBlock(1, true);
impl()->RewriteAsyncFunctionBody(body, block, expression); impl()->RewriteAsyncFunctionBody(body, block, expression);
RETURN_IF_PARSE_ERROR_VOID;
} else { } else {
body->Add(BuildReturnStatement(expression, expression->position()), body->Add(BuildReturnStatement(expression, expression->position()),
zone()); zone());
...@@ -4050,16 +4045,12 @@ void ParserBase<Impl>::ParseFunctionBody( ...@@ -4050,16 +4045,12 @@ void ParserBase<Impl>::ParseFunctionBody(
if (IsAsyncGeneratorFunction(kind)) { if (IsAsyncGeneratorFunction(kind)) {
impl()->ParseAndRewriteAsyncGeneratorFunctionBody(pos, kind, body); impl()->ParseAndRewriteAsyncGeneratorFunctionBody(pos, kind, body);
RETURN_IF_PARSE_ERROR_VOID;
} else if (IsGeneratorFunction(kind)) { } else if (IsGeneratorFunction(kind)) {
impl()->ParseAndRewriteGeneratorFunctionBody(pos, kind, body); impl()->ParseAndRewriteGeneratorFunctionBody(pos, kind, body);
RETURN_IF_PARSE_ERROR_VOID;
} else if (IsAsyncFunction(kind)) { } else if (IsAsyncFunction(kind)) {
ParseAsyncFunctionBody(inner_scope, body); ParseAsyncFunctionBody(inner_scope, body);
RETURN_IF_PARSE_ERROR_VOID;
} else { } else {
ParseStatementList(body, closing_token); ParseStatementList(body, closing_token);
RETURN_IF_PARSE_ERROR_VOID;
} }
if (IsDerivedConstructor(kind)) { if (IsDerivedConstructor(kind)) {
...@@ -4068,7 +4059,6 @@ void ParserBase<Impl>::ParseFunctionBody( ...@@ -4068,7 +4059,6 @@ void ParserBase<Impl>::ParseFunctionBody(
zone()); zone());
} }
Expect(closing_token); Expect(closing_token);
RETURN_IF_PARSE_ERROR_VOID;
} }
} }
...@@ -4090,7 +4080,6 @@ void ParserBase<Impl>::ParseFunctionBody( ...@@ -4090,7 +4080,6 @@ void ParserBase<Impl>::ParseFunctionBody(
DCHECK_EQ(function_scope, inner_scope->outer_scope()); DCHECK_EQ(function_scope, inner_scope->outer_scope());
impl()->SetLanguageMode(function_scope, inner_scope->language_mode()); impl()->SetLanguageMode(function_scope, inner_scope->language_mode());
BlockT init_block = impl()->BuildParameterInitializationBlock(parameters); BlockT init_block = impl()->BuildParameterInitializationBlock(parameters);
RETURN_IF_PARSE_ERROR_VOID;
if (is_sloppy(inner_scope->language_mode())) { if (is_sloppy(inner_scope->language_mode())) {
impl()->InsertSloppyBlockFunctionVarBindings(inner_scope); impl()->InsertSloppyBlockFunctionVarBindings(inner_scope);
...@@ -4104,7 +4093,6 @@ void ParserBase<Impl>::ParseFunctionBody( ...@@ -4104,7 +4093,6 @@ void ParserBase<Impl>::ParseFunctionBody(
inner_scope->set_end_position(end_position()); inner_scope->set_end_position(end_position());
if (inner_scope->FinalizeBlockScope() != nullptr) { if (inner_scope->FinalizeBlockScope() != nullptr) {
impl()->CheckConflictingVarDeclarations(inner_scope); impl()->CheckConflictingVarDeclarations(inner_scope);
RETURN_IF_PARSE_ERROR_VOID;
impl()->InsertShadowingVarBindingInitializers(inner_block); impl()->InsertShadowingVarBindingInitializers(inner_block);
} else { } else {
inner_block->set_scope(nullptr); inner_block->set_scope(nullptr);
...@@ -4116,7 +4104,6 @@ void ParserBase<Impl>::ParseFunctionBody( ...@@ -4116,7 +4104,6 @@ void ParserBase<Impl>::ParseFunctionBody(
} }
ValidateFormalParameters(language_mode(), allow_duplicate_parameters); ValidateFormalParameters(language_mode(), allow_duplicate_parameters);
RETURN_IF_PARSE_ERROR_VOID;
if (!IsArrowFunction(kind)) { if (!IsArrowFunction(kind)) {
// Declare arguments after parsing the function since lexical 'arguments' // Declare arguments after parsing the function since lexical 'arguments'
...@@ -4125,6 +4112,7 @@ void ParserBase<Impl>::ParseFunctionBody( ...@@ -4125,6 +4112,7 @@ void ParserBase<Impl>::ParseFunctionBody(
function_scope->DeclareArguments(ast_value_factory()); function_scope->DeclareArguments(ast_value_factory());
} }
RETURN_IF_PARSE_ERROR_VOID;
impl()->DeclareFunctionNameVar(function_name, function_type, function_scope); impl()->DeclareFunctionNameVar(function_name, function_type, function_scope);
} }
......
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