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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 DCHECK_NOT_NULL(variable); | 431 DCHECK_NOT_NULL(variable); |
432 DCHECK(IsResumableFunction(kind())); | 432 DCHECK(IsResumableFunction(kind())); |
433 DCHECK(scope()->has_forced_context_allocation()); | 433 DCHECK(scope()->has_forced_context_allocation()); |
434 generator_object_variable_ = variable; | 434 generator_object_variable_ = variable; |
435 } | 435 } |
436 typename Types::Variable* generator_object_variable() const { | 436 typename Types::Variable* generator_object_variable() const { |
437 return generator_object_variable_; | 437 return generator_object_variable_; |
438 } | 438 } |
439 | 439 |
440 void set_promise_variable(typename Types::Variable* variable) { | 440 void set_promise_variable(typename Types::Variable* variable) { |
441 DCHECK(variable != NULL); | 441 DCHECK_NOT_NULL(variable); |
442 DCHECK(IsAsyncFunction(kind())); | 442 DCHECK(IsAsyncFunction(kind())); |
443 promise_variable_ = variable; | 443 promise_variable_ = variable; |
444 } | 444 } |
445 typename Types::Variable* promise_variable() const { | 445 typename Types::Variable* promise_variable() const { |
446 return promise_variable_; | 446 return promise_variable_; |
447 } | 447 } |
448 | 448 |
| 449 void set_async_return_variable(typename Types::Variable* variable) { |
| 450 DCHECK_NOT_NULL(variable); |
| 451 DCHECK(IsAsyncFunction(kind())); |
| 452 async_return_variable_ = variable; |
| 453 } |
| 454 typename Types::Variable* async_return_variable() const { |
| 455 return async_return_variable_; |
| 456 } |
| 457 |
449 const ZoneList<DestructuringAssignment>& | 458 const ZoneList<DestructuringAssignment>& |
450 destructuring_assignments_to_rewrite() const { | 459 destructuring_assignments_to_rewrite() const { |
451 return destructuring_assignments_to_rewrite_; | 460 return destructuring_assignments_to_rewrite_; |
452 } | 461 } |
453 | 462 |
454 TailCallExpressionList& tail_call_expressions() { | 463 TailCallExpressionList& tail_call_expressions() { |
455 return tail_call_expressions_; | 464 return tail_call_expressions_; |
456 } | 465 } |
457 void AddImplicitTailCallExpression(ExpressionT expression) { | 466 void AddImplicitTailCallExpression(ExpressionT expression) { |
458 if (return_expr_context() == | 467 if (return_expr_context() == |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 // Properties count estimation. | 517 // Properties count estimation. |
509 int expected_property_count_; | 518 int expected_property_count_; |
510 | 519 |
511 // For generators, this variable may hold the generator object. It variable | 520 // For generators, this variable may hold the generator object. It variable |
512 // is used by yield expressions and return statements. It is not necessary | 521 // is used by yield expressions and return statements. It is not necessary |
513 // for generator functions to have this variable set. | 522 // for generator functions to have this variable set. |
514 Variable* generator_object_variable_; | 523 Variable* generator_object_variable_; |
515 // For async functions, this variable holds a temporary for the Promise | 524 // For async functions, this variable holds a temporary for the Promise |
516 // being created as output of the async function. | 525 // being created as output of the async function. |
517 Variable* promise_variable_; | 526 Variable* promise_variable_; |
| 527 Variable* async_return_variable_; |
| 528 Variable* is_rejection_variable_; |
518 | 529 |
519 FunctionState** function_state_stack_; | 530 FunctionState** function_state_stack_; |
520 FunctionState* outer_function_state_; | 531 FunctionState* outer_function_state_; |
521 | 532 |
522 ZoneList<DestructuringAssignment> destructuring_assignments_to_rewrite_; | 533 ZoneList<DestructuringAssignment> destructuring_assignments_to_rewrite_; |
523 TailCallExpressionList tail_call_expressions_; | 534 TailCallExpressionList tail_call_expressions_; |
524 ReturnExprContext return_expr_context_; | 535 ReturnExprContext return_expr_context_; |
525 ZoneList<ExpressionT> non_patterns_to_rewrite_; | 536 ZoneList<ExpressionT> non_patterns_to_rewrite_; |
526 | 537 |
527 ZoneList<typename ExpressionClassifier::Error> reported_errors_; | 538 ZoneList<typename ExpressionClassifier::Error> reported_errors_; |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 | 1522 |
1512 template <typename Impl> | 1523 template <typename Impl> |
1513 ParserBase<Impl>::FunctionState::FunctionState( | 1524 ParserBase<Impl>::FunctionState::FunctionState( |
1514 FunctionState** function_state_stack, ScopeState** scope_stack, | 1525 FunctionState** function_state_stack, ScopeState** scope_stack, |
1515 DeclarationScope* scope) | 1526 DeclarationScope* scope) |
1516 : ScopeState(scope_stack, scope), | 1527 : ScopeState(scope_stack, scope), |
1517 next_materialized_literal_index_(0), | 1528 next_materialized_literal_index_(0), |
1518 expected_property_count_(0), | 1529 expected_property_count_(0), |
1519 generator_object_variable_(nullptr), | 1530 generator_object_variable_(nullptr), |
1520 promise_variable_(nullptr), | 1531 promise_variable_(nullptr), |
| 1532 async_return_variable_(nullptr), |
| 1533 is_rejection_variable_(nullptr), |
1521 function_state_stack_(function_state_stack), | 1534 function_state_stack_(function_state_stack), |
1522 outer_function_state_(*function_state_stack), | 1535 outer_function_state_(*function_state_stack), |
1523 destructuring_assignments_to_rewrite_(16, scope->zone()), | 1536 destructuring_assignments_to_rewrite_(16, scope->zone()), |
1524 tail_call_expressions_(scope->zone()), | 1537 tail_call_expressions_(scope->zone()), |
1525 return_expr_context_(ReturnExprContext::kInsideValidBlock), | 1538 return_expr_context_(ReturnExprContext::kInsideValidBlock), |
1526 non_patterns_to_rewrite_(0, scope->zone()), | 1539 non_patterns_to_rewrite_(0, scope->zone()), |
1527 reported_errors_(16, scope->zone()), | 1540 reported_errors_(16, scope->zone()), |
1528 next_function_is_likely_called_(false), | 1541 next_function_is_likely_called_(false), |
1529 previous_function_was_likely_called_(false) { | 1542 previous_function_was_likely_called_(false) { |
1530 *function_state_stack = this; | 1543 *function_state_stack = this; |
(...skipping 2516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4047 impl()->SetLanguageMode(function_scope, inner_scope->language_mode()); | 4060 impl()->SetLanguageMode(function_scope, inner_scope->language_mode()); |
4048 BlockT init_block = | 4061 BlockT init_block = |
4049 impl()->BuildParameterInitializationBlock(parameters, CHECK_OK_VOID); | 4062 impl()->BuildParameterInitializationBlock(parameters, CHECK_OK_VOID); |
4050 | 4063 |
4051 if (is_sloppy(inner_scope->language_mode())) { | 4064 if (is_sloppy(inner_scope->language_mode())) { |
4052 impl()->InsertSloppyBlockFunctionVarBindings(inner_scope); | 4065 impl()->InsertSloppyBlockFunctionVarBindings(inner_scope); |
4053 } | 4066 } |
4054 | 4067 |
4055 // TODO(littledan): Merge the two rejection blocks into one | 4068 // TODO(littledan): Merge the two rejection blocks into one |
4056 if (IsAsyncFunction(kind)) { | 4069 if (IsAsyncFunction(kind)) { |
4057 init_block = impl()->BuildRejectPromiseOnException(init_block); | 4070 init_block = |
| 4071 impl()->BuildRejectPromiseOnExceptionForParameters(init_block); |
4058 } | 4072 } |
4059 | 4073 |
4060 inner_scope->set_end_position(scanner()->location().end_pos); | 4074 inner_scope->set_end_position(scanner()->location().end_pos); |
4061 if (inner_scope->FinalizeBlockScope() != nullptr) { | 4075 if (inner_scope->FinalizeBlockScope() != nullptr) { |
4062 impl()->CheckConflictingVarDeclarations(inner_scope, CHECK_OK_VOID); | 4076 impl()->CheckConflictingVarDeclarations(inner_scope, CHECK_OK_VOID); |
4063 impl()->InsertShadowingVarBindingInitializers(inner_block); | 4077 impl()->InsertShadowingVarBindingInitializers(inner_block); |
4064 } | 4078 } |
4065 inner_scope = nullptr; | 4079 inner_scope = nullptr; |
4066 | 4080 |
4067 result->Add(init_block, zone()); | 4081 result->Add(init_block, zone()); |
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5774 } | 5788 } |
5775 | 5789 |
5776 #undef CHECK_OK | 5790 #undef CHECK_OK |
5777 #undef CHECK_OK_CUSTOM | 5791 #undef CHECK_OK_CUSTOM |
5778 #undef CHECK_OK_VOID | 5792 #undef CHECK_OK_VOID |
5779 | 5793 |
5780 } // namespace internal | 5794 } // namespace internal |
5781 } // namespace v8 | 5795 } // namespace v8 |
5782 | 5796 |
5783 #endif // V8_PARSING_PARSER_BASE_H | 5797 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |