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/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/hashmap.h" | 10 #include "src/base/hashmap.h" |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 return return_expr_context_; | 465 return return_expr_context_; |
466 } | 466 } |
467 void set_return_expr_context(ReturnExprContext context) { | 467 void set_return_expr_context(ReturnExprContext context) { |
468 return_expr_context_ = context; | 468 return_expr_context_ = context; |
469 } | 469 } |
470 | 470 |
471 ZoneList<ExpressionT>* non_patterns_to_rewrite() { | 471 ZoneList<ExpressionT>* non_patterns_to_rewrite() { |
472 return &non_patterns_to_rewrite_; | 472 return &non_patterns_to_rewrite_; |
473 } | 473 } |
474 | 474 |
475 void next_function_is_parenthesized(bool parenthesized) { | 475 bool next_function_is_parenthesized() const { |
| 476 return next_function_is_parenthesized_; |
| 477 } |
| 478 |
| 479 void set_next_function_is_parenthesized(bool parenthesized) { |
476 next_function_is_parenthesized_ = parenthesized; | 480 next_function_is_parenthesized_ = parenthesized; |
477 } | 481 } |
478 | 482 |
479 bool this_function_is_parenthesized() const { | 483 bool this_function_is_parenthesized() const { |
480 return this_function_is_parenthesized_; | 484 return this_function_is_parenthesized_; |
481 } | 485 } |
482 | 486 |
483 private: | 487 private: |
484 void AddDestructuringAssignment(DestructuringAssignment pair) { | 488 void AddDestructuringAssignment(DestructuringAssignment pair) { |
485 destructuring_assignments_to_rewrite_.Add(pair, this->zone()); | 489 destructuring_assignments_to_rewrite_.Add(pair, this->zone()); |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 bool allow_lazy_; | 1242 bool allow_lazy_; |
1239 bool allow_natives_; | 1243 bool allow_natives_; |
1240 bool allow_tailcalls_; | 1244 bool allow_tailcalls_; |
1241 bool allow_harmony_restrictive_declarations_; | 1245 bool allow_harmony_restrictive_declarations_; |
1242 bool allow_harmony_do_expressions_; | 1246 bool allow_harmony_do_expressions_; |
1243 bool allow_harmony_for_in_; | 1247 bool allow_harmony_for_in_; |
1244 bool allow_harmony_function_sent_; | 1248 bool allow_harmony_function_sent_; |
1245 bool allow_harmony_async_await_; | 1249 bool allow_harmony_async_await_; |
1246 bool allow_harmony_restrictive_generators_; | 1250 bool allow_harmony_restrictive_generators_; |
1247 bool allow_harmony_trailing_commas_; | 1251 bool allow_harmony_trailing_commas_; |
| 1252 |
| 1253 friend class DiscardableZoneScope; |
1248 }; | 1254 }; |
1249 | 1255 |
1250 template <class Traits> | 1256 template <class Traits> |
1251 ParserBase<Traits>::FunctionState::FunctionState( | 1257 ParserBase<Traits>::FunctionState::FunctionState( |
1252 FunctionState** function_state_stack, ScopeState** scope_stack, | 1258 FunctionState** function_state_stack, ScopeState** scope_stack, |
1253 Scope* scope, FunctionKind kind) | 1259 Scope* scope, FunctionKind kind) |
1254 : ScopeState(scope_stack, scope), | 1260 : ScopeState(scope_stack, scope), |
1255 next_materialized_literal_index_(0), | 1261 next_materialized_literal_index_(0), |
1256 expected_property_count_(0), | 1262 expected_property_count_(0), |
1257 kind_(kind), | 1263 kind_(kind), |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 ReportMessageAt(scanner()->peek_location(), | 1637 ReportMessageAt(scanner()->peek_location(), |
1632 MessageTemplate::kParamAfterRest); | 1638 MessageTemplate::kParamAfterRest); |
1633 *ok = false; | 1639 *ok = false; |
1634 return this->EmptyExpression(); | 1640 return this->EmptyExpression(); |
1635 } | 1641 } |
1636 Expect(Token::RPAREN, CHECK_OK); | 1642 Expect(Token::RPAREN, CHECK_OK); |
1637 return factory()->NewSpread(expr, ellipsis_pos, expr_pos); | 1643 return factory()->NewSpread(expr, ellipsis_pos, expr_pos); |
1638 } | 1644 } |
1639 // Heuristically try to detect immediately called functions before | 1645 // Heuristically try to detect immediately called functions before |
1640 // seeing the call parentheses. | 1646 // seeing the call parentheses. |
1641 function_state_->next_function_is_parenthesized(peek() == | 1647 function_state_->set_next_function_is_parenthesized(peek() == |
1642 Token::FUNCTION); | 1648 Token::FUNCTION); |
1643 ExpressionT expr = this->ParseExpression(true, classifier, CHECK_OK); | 1649 ExpressionT expr = this->ParseExpression(true, classifier, CHECK_OK); |
1644 Expect(Token::RPAREN, CHECK_OK); | 1650 Expect(Token::RPAREN, CHECK_OK); |
1645 return expr; | 1651 return expr; |
1646 } | 1652 } |
1647 | 1653 |
1648 case Token::CLASS: { | 1654 case Token::CLASS: { |
1649 BindingPatternUnexpectedToken(classifier); | 1655 BindingPatternUnexpectedToken(classifier); |
1650 Consume(Token::CLASS); | 1656 Consume(Token::CLASS); |
1651 int class_token_position = position(); | 1657 int class_token_position = position(); |
1652 IdentifierT name = this->EmptyIdentifier(); | 1658 IdentifierT name = this->EmptyIdentifier(); |
(...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3677 has_seen_constructor_ = true; | 3683 has_seen_constructor_ = true; |
3678 return; | 3684 return; |
3679 } | 3685 } |
3680 } | 3686 } |
3681 | 3687 |
3682 | 3688 |
3683 } // namespace internal | 3689 } // namespace internal |
3684 } // namespace v8 | 3690 } // namespace v8 |
3685 | 3691 |
3686 #endif // V8_PARSING_PARSER_BASE_H | 3692 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |