| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
| 6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
| 7 | 7 |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 void SkipMaterializedLiterals(int count) { | 420 void SkipMaterializedLiterals(int count) { |
| 421 next_materialized_literal_index_ += count; | 421 next_materialized_literal_index_ += count; |
| 422 } | 422 } |
| 423 | 423 |
| 424 void AddProperty() { expected_property_count_++; } | 424 void AddProperty() { expected_property_count_++; } |
| 425 int expected_property_count() { return expected_property_count_; } | 425 int expected_property_count() { return expected_property_count_; } |
| 426 | 426 |
| 427 FunctionKind kind() const { return scope()->function_kind(); } | 427 FunctionKind kind() const { return scope()->function_kind(); } |
| 428 FunctionState* outer() const { return outer_function_state_; } | 428 FunctionState* outer() const { return outer_function_state_; } |
| 429 | 429 |
| 430 void set_generator_object_variable(typename Types::Variable* variable) { | |
| 431 DCHECK_NOT_NULL(variable); | |
| 432 DCHECK(IsResumableFunction(kind())); | |
| 433 DCHECK(scope()->has_forced_context_allocation()); | |
| 434 generator_object_variable_ = variable; | |
| 435 } | |
| 436 typename Types::Variable* generator_object_variable() const { | 430 typename Types::Variable* generator_object_variable() const { |
| 437 return generator_object_variable_; | 431 return scope()->generator_object_var(); |
| 438 } | 432 } |
| 439 | 433 |
| 440 void set_promise_variable(typename Types::Variable* variable) { | |
| 441 DCHECK(variable != NULL); | |
| 442 DCHECK(IsAsyncFunction(kind())); | |
| 443 promise_variable_ = variable; | |
| 444 } | |
| 445 typename Types::Variable* promise_variable() const { | 434 typename Types::Variable* promise_variable() const { |
| 446 return promise_variable_; | 435 return scope()->promise_var(); |
| 447 } | 436 } |
| 448 | 437 |
| 449 const ZoneList<DestructuringAssignment>& | 438 const ZoneList<DestructuringAssignment>& |
| 450 destructuring_assignments_to_rewrite() const { | 439 destructuring_assignments_to_rewrite() const { |
| 451 return destructuring_assignments_to_rewrite_; | 440 return destructuring_assignments_to_rewrite_; |
| 452 } | 441 } |
| 453 | 442 |
| 454 TailCallExpressionList& tail_call_expressions() { | 443 TailCallExpressionList& tail_call_expressions() { |
| 455 return tail_call_expressions_; | 444 return tail_call_expressions_; |
| 456 } | 445 } |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 StatementT ParseHoistableDeclaration(ZoneList<const AstRawString*>* names, | 1215 StatementT ParseHoistableDeclaration(ZoneList<const AstRawString*>* names, |
| 1227 bool default_export, bool* ok); | 1216 bool default_export, bool* ok); |
| 1228 StatementT ParseHoistableDeclaration(int pos, ParseFunctionFlags flags, | 1217 StatementT ParseHoistableDeclaration(int pos, ParseFunctionFlags flags, |
| 1229 ZoneList<const AstRawString*>* names, | 1218 ZoneList<const AstRawString*>* names, |
| 1230 bool default_export, bool* ok); | 1219 bool default_export, bool* ok); |
| 1231 StatementT ParseClassDeclaration(ZoneList<const AstRawString*>* names, | 1220 StatementT ParseClassDeclaration(ZoneList<const AstRawString*>* names, |
| 1232 bool default_export, bool* ok); | 1221 bool default_export, bool* ok); |
| 1233 StatementT ParseNativeDeclaration(bool* ok); | 1222 StatementT ParseNativeDeclaration(bool* ok); |
| 1234 | 1223 |
| 1235 // Consumes the ending }. | 1224 // Consumes the ending }. |
| 1236 void ParseFunctionBody(StatementListT result, IdentifierT function_name, | 1225 void ParseFunctionBody(StatementListT result, BlockT* init_block, |
| 1237 int pos, const FormalParametersT& parameters, | 1226 IdentifierT function_name, int pos, |
| 1238 FunctionKind kind, | 1227 const FormalParametersT& parameters, FunctionKind kind, |
| 1239 FunctionLiteral::FunctionType function_type, bool* ok); | 1228 FunctionLiteral::FunctionType function_type, bool* ok); |
| 1240 | 1229 |
| 1241 // Under some circumstances, we allow preparsing to abort if the preparsed | 1230 // Under some circumstances, we allow preparsing to abort if the preparsed |
| 1242 // function is "long and trivial", and fully parse instead. Our current | 1231 // function is "long and trivial", and fully parse instead. Our current |
| 1243 // definition of "long and trivial" is: | 1232 // definition of "long and trivial" is: |
| 1244 // - over kLazyParseTrialLimit statements | 1233 // - over kLazyParseTrialLimit statements |
| 1245 // - all starting with an identifier (i.e., no if, for, while, etc.) | 1234 // - all starting with an identifier (i.e., no if, for, while, etc.) |
| 1246 static const int kLazyParseTrialLimit = 200; | 1235 static const int kLazyParseTrialLimit = 200; |
| 1247 | 1236 |
| 1248 // TODO(nikolaos, marja): The first argument should not really be passed | 1237 // TODO(nikolaos, marja): The first argument should not really be passed |
| (...skipping 2716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3965 impl()->ReportUnexpectedToken(scanner()->current_token()); | 3954 impl()->ReportUnexpectedToken(scanner()->current_token()); |
| 3966 return impl()->NullStatement(); | 3955 return impl()->NullStatement(); |
| 3967 } | 3956 } |
| 3968 Expect(Token::FUNCTION, CHECK_OK_CUSTOM(NullStatement)); | 3957 Expect(Token::FUNCTION, CHECK_OK_CUSTOM(NullStatement)); |
| 3969 ParseFunctionFlags flags = ParseFunctionFlags::kIsAsync; | 3958 ParseFunctionFlags flags = ParseFunctionFlags::kIsAsync; |
| 3970 return ParseHoistableDeclaration(pos, flags, names, default_export, ok); | 3959 return ParseHoistableDeclaration(pos, flags, names, default_export, ok); |
| 3971 } | 3960 } |
| 3972 | 3961 |
| 3973 template <typename Impl> | 3962 template <typename Impl> |
| 3974 void ParserBase<Impl>::ParseFunctionBody( | 3963 void ParserBase<Impl>::ParseFunctionBody( |
| 3975 typename ParserBase<Impl>::StatementListT result, IdentifierT function_name, | 3964 typename ParserBase<Impl>::StatementListT result, |
| 3965 typename ParserBase<Impl>::BlockT* init_block, IdentifierT function_name, |
| 3976 int pos, const FormalParametersT& parameters, FunctionKind kind, | 3966 int pos, const FormalParametersT& parameters, FunctionKind kind, |
| 3977 FunctionLiteral::FunctionType function_type, bool* ok) { | 3967 FunctionLiteral::FunctionType function_type, bool* ok) { |
| 3978 static const int kFunctionNameAssignmentIndex = 0; | |
| 3979 if (function_type == FunctionLiteral::kNamedExpression) { | |
| 3980 DCHECK(!impl()->IsEmptyIdentifier(function_name)); | |
| 3981 // If we have a named function expression, we add a local variable | |
| 3982 // declaration to the body of the function with the name of the | |
| 3983 // function and let it refer to the function itself (closure). | |
| 3984 // Not having parsed the function body, the language mode may still change, | |
| 3985 // so we reserve a spot and create the actual const assignment later. | |
| 3986 DCHECK_EQ(kFunctionNameAssignmentIndex, result->length()); | |
| 3987 result->Add(impl()->NullStatement(), zone()); | |
| 3988 } | |
| 3989 | |
| 3990 DeclarationScope* function_scope = scope()->AsDeclarationScope(); | 3968 DeclarationScope* function_scope = scope()->AsDeclarationScope(); |
| 3991 DeclarationScope* inner_scope = function_scope; | 3969 DeclarationScope* inner_scope = function_scope; |
| 3992 BlockT inner_block = impl()->NullBlock(); | 3970 BlockT inner_block = impl()->NullBlock(); |
| 3993 | 3971 |
| 3994 StatementListT body = result; | 3972 StatementListT body = result; |
| 3995 if (!parameters.is_simple) { | 3973 if (!parameters.is_simple) { |
| 3996 inner_scope = NewVarblockScope(); | 3974 inner_scope = NewVarblockScope(); |
| 3997 inner_scope->set_start_position(scanner()->location().beg_pos); | 3975 inner_scope->set_start_position(scanner()->location().beg_pos); |
| 3998 inner_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); | 3976 inner_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); |
| 3999 inner_block->set_scope(inner_scope); | 3977 inner_block->set_scope(inner_scope); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4021 } | 3999 } |
| 4022 | 4000 |
| 4023 Expect(Token::RBRACE, CHECK_OK_VOID); | 4001 Expect(Token::RBRACE, CHECK_OK_VOID); |
| 4024 scope()->set_end_position(scanner()->location().end_pos); | 4002 scope()->set_end_position(scanner()->location().end_pos); |
| 4025 | 4003 |
| 4026 if (!parameters.is_simple) { | 4004 if (!parameters.is_simple) { |
| 4027 DCHECK_NOT_NULL(inner_scope); | 4005 DCHECK_NOT_NULL(inner_scope); |
| 4028 DCHECK_EQ(function_scope, scope()); | 4006 DCHECK_EQ(function_scope, scope()); |
| 4029 DCHECK_EQ(function_scope, inner_scope->outer_scope()); | 4007 DCHECK_EQ(function_scope, inner_scope->outer_scope()); |
| 4030 impl()->SetLanguageMode(function_scope, inner_scope->language_mode()); | 4008 impl()->SetLanguageMode(function_scope, inner_scope->language_mode()); |
| 4031 BlockT init_block = | 4009 *init_block = |
| 4032 impl()->BuildParameterInitializationBlock(parameters, CHECK_OK_VOID); | 4010 impl()->BuildParameterInitializationBlock(parameters, CHECK_OK_VOID); |
| 4033 | 4011 |
| 4034 if (is_sloppy(inner_scope->language_mode())) { | 4012 if (is_sloppy(inner_scope->language_mode())) { |
| 4035 impl()->InsertSloppyBlockFunctionVarBindings(inner_scope); | 4013 impl()->InsertSloppyBlockFunctionVarBindings(inner_scope); |
| 4036 } | 4014 } |
| 4037 | 4015 |
| 4038 // TODO(littledan): Merge the two rejection blocks into one | |
| 4039 if (IsAsyncFunction(kind)) { | |
| 4040 init_block = impl()->BuildRejectPromiseOnException(init_block); | |
| 4041 } | |
| 4042 | |
| 4043 inner_scope->set_end_position(scanner()->location().end_pos); | 4016 inner_scope->set_end_position(scanner()->location().end_pos); |
| 4044 if (inner_scope->FinalizeBlockScope() != nullptr) { | 4017 if (inner_scope->FinalizeBlockScope() != nullptr) { |
| 4045 impl()->CheckConflictingVarDeclarations(inner_scope, CHECK_OK_VOID); | 4018 impl()->CheckConflictingVarDeclarations(inner_scope, CHECK_OK_VOID); |
| 4046 impl()->InsertShadowingVarBindingInitializers(inner_block); | 4019 impl()->InsertShadowingVarBindingInitializers(inner_block); |
| 4047 } | 4020 } |
| 4048 inner_scope = nullptr; | 4021 inner_scope = nullptr; |
| 4049 | 4022 |
| 4050 result->Add(init_block, zone()); | |
| 4051 result->Add(inner_block, zone()); | 4023 result->Add(inner_block, zone()); |
| 4052 } else { | 4024 } else { |
| 4053 DCHECK_EQ(inner_scope, function_scope); | 4025 DCHECK_EQ(inner_scope, function_scope); |
| 4054 if (is_sloppy(function_scope->language_mode())) { | 4026 if (is_sloppy(function_scope->language_mode())) { |
| 4055 impl()->InsertSloppyBlockFunctionVarBindings(function_scope); | 4027 impl()->InsertSloppyBlockFunctionVarBindings(function_scope); |
| 4056 } | 4028 } |
| 4057 } | 4029 } |
| 4058 | 4030 |
| 4059 if (!IsArrowFunction(kind)) { | 4031 if (!IsArrowFunction(kind)) { |
| 4060 // Declare arguments after parsing the function since lexical 'arguments' | 4032 // Declare arguments after parsing the function since lexical 'arguments' |
| 4061 // masks the arguments object. Declare arguments before declaring the | 4033 // masks the arguments object. Declare arguments before declaring the |
| 4062 // function var since the arguments object masks 'function arguments'. | 4034 // function var since the arguments object masks 'function arguments'. |
| 4063 function_scope->DeclareArguments(ast_value_factory()); | 4035 function_scope->DeclareArguments(ast_value_factory()); |
| 4064 } | 4036 } |
| 4065 | 4037 |
| 4066 impl()->CreateFunctionNameAssignment(function_name, pos, function_type, | 4038 impl()->CreateFunctionNameVariable(function_name, function_type, |
| 4067 function_scope, result, | 4039 function_scope); |
| 4068 kFunctionNameAssignmentIndex); | |
| 4069 impl()->MarkCollectedTailCallExpressions(); | 4040 impl()->MarkCollectedTailCallExpressions(); |
| 4070 } | 4041 } |
| 4071 | 4042 |
| 4072 template <typename Impl> | 4043 template <typename Impl> |
| 4073 void ParserBase<Impl>::CheckArityRestrictions(int param_count, | 4044 void ParserBase<Impl>::CheckArityRestrictions(int param_count, |
| 4074 FunctionKind function_kind, | 4045 FunctionKind function_kind, |
| 4075 bool has_rest, | 4046 bool has_rest, |
| 4076 int formals_start_pos, | 4047 int formals_start_pos, |
| 4077 int formals_end_pos, bool* ok) { | 4048 int formals_end_pos, bool* ok) { |
| 4078 if (IsGetterFunction(function_kind)) { | 4049 if (IsGetterFunction(function_kind)) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4156 | 4127 |
| 4157 if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) { | 4128 if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) { |
| 4158 // ASI inserts `;` after arrow parameters if a line terminator is found. | 4129 // ASI inserts `;` after arrow parameters if a line terminator is found. |
| 4159 // `=> ...` is never a valid expression, so report as syntax error. | 4130 // `=> ...` is never a valid expression, so report as syntax error. |
| 4160 // If next token is not `=>`, it's a syntax error anyways. | 4131 // If next token is not `=>`, it's a syntax error anyways. |
| 4161 ReportUnexpectedTokenAt(scanner_->peek_location(), Token::ARROW); | 4132 ReportUnexpectedTokenAt(scanner_->peek_location(), Token::ARROW); |
| 4162 *ok = false; | 4133 *ok = false; |
| 4163 return impl()->EmptyExpression(); | 4134 return impl()->EmptyExpression(); |
| 4164 } | 4135 } |
| 4165 | 4136 |
| 4137 BlockT parameter_init_block = impl()->NullBlock(); |
| 4166 StatementListT body = impl()->NullStatementList(); | 4138 StatementListT body = impl()->NullStatementList(); |
| 4167 int materialized_literal_count = -1; | 4139 int materialized_literal_count = -1; |
| 4168 int expected_property_count = -1; | 4140 int expected_property_count = -1; |
| 4169 int function_literal_id = GetNextFunctionLiteralId(); | 4141 int function_literal_id = GetNextFunctionLiteralId(); |
| 4170 | 4142 |
| 4171 FunctionKind kind = formal_parameters.scope->function_kind(); | 4143 FunctionKind kind = formal_parameters.scope->function_kind(); |
| 4172 FunctionLiteral::EagerCompileHint eager_compile_hint = | 4144 FunctionLiteral::EagerCompileHint eager_compile_hint = |
| 4173 default_eager_compile_hint_; | 4145 default_eager_compile_hint_; |
| 4174 bool can_preparse = impl()->parse_lazily() && | 4146 bool can_preparse = impl()->parse_lazily() && |
| 4175 eager_compile_hint == FunctionLiteral::kShouldLazyCompile; | 4147 eager_compile_hint == FunctionLiteral::kShouldLazyCompile; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4224 // This is probably an initialization function. Inform the compiler it | 4196 // This is probably an initialization function. Inform the compiler it |
| 4225 // should also eager-compile this function, and that we expect it to | 4197 // should also eager-compile this function, and that we expect it to |
| 4226 // be used once. | 4198 // be used once. |
| 4227 eager_compile_hint = FunctionLiteral::kShouldEagerCompile; | 4199 eager_compile_hint = FunctionLiteral::kShouldEagerCompile; |
| 4228 should_be_used_once_hint = true; | 4200 should_be_used_once_hint = true; |
| 4229 } | 4201 } |
| 4230 } | 4202 } |
| 4231 if (!is_lazy_top_level_function) { | 4203 if (!is_lazy_top_level_function) { |
| 4232 Consume(Token::LBRACE); | 4204 Consume(Token::LBRACE); |
| 4233 body = impl()->NewStatementList(8); | 4205 body = impl()->NewStatementList(8); |
| 4234 impl()->ParseFunctionBody(body, impl()->EmptyIdentifier(), | 4206 impl()->ParseFunctionBody( |
| 4235 kNoSourcePosition, formal_parameters, kind, | 4207 body, ¶meter_init_block, impl()->EmptyIdentifier(), |
| 4236 FunctionLiteral::kAnonymousExpression, | 4208 kNoSourcePosition, formal_parameters, kind, |
| 4237 CHECK_OK); | 4209 FunctionLiteral::kAnonymousExpression, CHECK_OK); |
| 4238 materialized_literal_count = | 4210 materialized_literal_count = |
| 4239 function_state.materialized_literal_count(); | 4211 function_state.materialized_literal_count(); |
| 4240 expected_property_count = function_state.expected_property_count(); | 4212 expected_property_count = function_state.expected_property_count(); |
| 4241 } | 4213 } |
| 4242 } else { | 4214 } else { |
| 4243 // Single-expression body | 4215 // Single-expression body |
| 4244 has_braces = false; | 4216 has_braces = false; |
| 4245 int pos = position(); | 4217 int pos = position(); |
| 4246 DCHECK(ReturnExprContext::kInsideValidBlock == | 4218 DCHECK(ReturnExprContext::kInsideValidBlock == |
| 4247 function_state_->return_expr_context()); | 4219 function_state_->return_expr_context()); |
| 4248 ReturnExprScope allow_tail_calls( | 4220 ReturnExprScope allow_tail_calls( |
| 4249 function_state_, ReturnExprContext::kInsideValidReturnStatement); | 4221 function_state_, ReturnExprContext::kInsideValidReturnStatement); |
| 4250 body = impl()->NewStatementList(1); | 4222 body = impl()->NewStatementList(1); |
| 4251 impl()->AddParameterInitializationBlock( | 4223 if (!formal_parameters.is_simple) { |
| 4252 formal_parameters, body, kind == kAsyncArrowFunction, CHECK_OK); | 4224 parameter_init_block = impl()->BuildParameterInitializationBlock( |
| 4225 formal_parameters, CHECK_OK); |
| 4226 } |
| 4253 ExpressionClassifier classifier(this); | 4227 ExpressionClassifier classifier(this); |
| 4254 if (kind == kAsyncArrowFunction) { | 4228 if (kind == kAsyncArrowFunction) { |
| 4255 ParseAsyncFunctionBody(scope(), body, kAsyncArrowFunction, | 4229 ParseAsyncFunctionBody(scope(), body, kAsyncArrowFunction, |
| 4256 FunctionBodyType::kSingleExpression, accept_IN, | 4230 FunctionBodyType::kSingleExpression, accept_IN, |
| 4257 pos, CHECK_OK); | 4231 pos, CHECK_OK); |
| 4258 impl()->RewriteNonPattern(CHECK_OK); | 4232 impl()->RewriteNonPattern(CHECK_OK); |
| 4259 } else { | 4233 } else { |
| 4260 ExpressionT expression = ParseAssignmentExpression(accept_IN, CHECK_OK); | 4234 ExpressionT expression = ParseAssignmentExpression(accept_IN, CHECK_OK); |
| 4261 impl()->RewriteNonPattern(CHECK_OK); | 4235 impl()->RewriteNonPattern(CHECK_OK); |
| 4262 body->Add( | 4236 body->Add( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4299 scope->start_position(), scope->end_position()); | 4273 scope->start_position(), scope->end_position()); |
| 4300 } | 4274 } |
| 4301 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( | 4275 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( |
| 4302 impl()->EmptyIdentifierString(), formal_parameters.scope, body, | 4276 impl()->EmptyIdentifierString(), formal_parameters.scope, body, |
| 4303 materialized_literal_count, expected_property_count, | 4277 materialized_literal_count, expected_property_count, |
| 4304 formal_parameters.num_parameters(), formal_parameters.function_length, | 4278 formal_parameters.num_parameters(), formal_parameters.function_length, |
| 4305 FunctionLiteral::kNoDuplicateParameters, | 4279 FunctionLiteral::kNoDuplicateParameters, |
| 4306 FunctionLiteral::kAnonymousExpression, eager_compile_hint, | 4280 FunctionLiteral::kAnonymousExpression, eager_compile_hint, |
| 4307 formal_parameters.scope->start_position(), has_braces, | 4281 formal_parameters.scope->start_position(), has_braces, |
| 4308 function_literal_id); | 4282 function_literal_id); |
| 4283 function_literal->set_parameter_init_block(parameter_init_block); |
| 4309 | 4284 |
| 4310 function_literal->set_function_token_position( | 4285 function_literal->set_function_token_position( |
| 4311 formal_parameters.scope->start_position()); | 4286 formal_parameters.scope->start_position()); |
| 4312 if (should_be_used_once_hint) { | 4287 if (should_be_used_once_hint) { |
| 4313 function_literal->set_should_be_used_once_hint(); | 4288 function_literal->set_should_be_used_once_hint(); |
| 4314 } | 4289 } |
| 4315 | 4290 |
| 4316 impl()->AddFunctionForNameInference(function_literal); | 4291 impl()->AddFunctionForNameInference(function_literal); |
| 4317 | 4292 |
| 4318 return function_literal; | 4293 return function_literal; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4391 } | 4366 } |
| 4392 | 4367 |
| 4393 template <typename Impl> | 4368 template <typename Impl> |
| 4394 void ParserBase<Impl>::ParseAsyncFunctionBody(Scope* scope, StatementListT body, | 4369 void ParserBase<Impl>::ParseAsyncFunctionBody(Scope* scope, StatementListT body, |
| 4395 FunctionKind kind, | 4370 FunctionKind kind, |
| 4396 FunctionBodyType body_type, | 4371 FunctionBodyType body_type, |
| 4397 bool accept_IN, int pos, | 4372 bool accept_IN, int pos, |
| 4398 bool* ok) { | 4373 bool* ok) { |
| 4399 impl()->PrepareAsyncFunctionBody(body, kind, pos); | 4374 impl()->PrepareAsyncFunctionBody(body, kind, pos); |
| 4400 | 4375 |
| 4401 BlockT block = factory()->NewBlock(nullptr, 8, true, kNoSourcePosition); | |
| 4402 | |
| 4403 ExpressionT return_value = impl()->EmptyExpression(); | 4376 ExpressionT return_value = impl()->EmptyExpression(); |
| 4404 if (body_type == FunctionBodyType::kNormal) { | 4377 if (body_type == FunctionBodyType::kNormal) { |
| 4405 ParseStatementList(block->statements(), Token::RBRACE, | 4378 ParseStatementList(body, Token::RBRACE, CHECK_OK_CUSTOM(Void)); |
| 4406 CHECK_OK_CUSTOM(Void)); | |
| 4407 return_value = factory()->NewUndefinedLiteral(kNoSourcePosition); | 4379 return_value = factory()->NewUndefinedLiteral(kNoSourcePosition); |
| 4408 } else { | 4380 } else { |
| 4409 return_value = ParseAssignmentExpression(accept_IN, CHECK_OK_CUSTOM(Void)); | 4381 return_value = ParseAssignmentExpression(accept_IN, CHECK_OK_CUSTOM(Void)); |
| 4410 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(Void)); | 4382 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(Void)); |
| 4411 } | 4383 } |
| 4412 | 4384 |
| 4413 impl()->RewriteAsyncFunctionBody(body, block, return_value, | 4385 impl()->RewriteAsyncFunctionBody(body, return_value, CHECK_OK_CUSTOM(Void)); |
| 4414 CHECK_OK_CUSTOM(Void)); | |
| 4415 scope->set_end_position(scanner()->location().end_pos); | 4386 scope->set_end_position(scanner()->location().end_pos); |
| 4416 } | 4387 } |
| 4417 | 4388 |
| 4418 template <typename Impl> | 4389 template <typename Impl> |
| 4419 typename ParserBase<Impl>::ExpressionT | 4390 typename ParserBase<Impl>::ExpressionT |
| 4420 ParserBase<Impl>::ParseAsyncFunctionLiteral(bool* ok) { | 4391 ParserBase<Impl>::ParseAsyncFunctionLiteral(bool* ok) { |
| 4421 // AsyncFunctionLiteral :: | 4392 // AsyncFunctionLiteral :: |
| 4422 // async [no LineTerminator here] function ( FormalParameters[Await] ) | 4393 // async [no LineTerminator here] function ( FormalParameters[Await] ) |
| 4423 // { AsyncFunctionBody } | 4394 // { AsyncFunctionBody } |
| 4424 // | 4395 // |
| (...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5751 return; | 5722 return; |
| 5752 } | 5723 } |
| 5753 } | 5724 } |
| 5754 | 5725 |
| 5755 #undef CHECK_OK_VOID | 5726 #undef CHECK_OK_VOID |
| 5756 | 5727 |
| 5757 } // namespace internal | 5728 } // namespace internal |
| 5758 } // namespace v8 | 5729 } // namespace v8 |
| 5759 | 5730 |
| 5760 #endif // V8_PARSING_PARSER_BASE_H | 5731 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |