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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 return return_expr_context_; | 457 return return_expr_context_; |
458 } | 458 } |
459 void set_return_expr_context(ReturnExprContext context) { | 459 void set_return_expr_context(ReturnExprContext context) { |
460 return_expr_context_ = context; | 460 return_expr_context_ = context; |
461 } | 461 } |
462 | 462 |
463 ZoneList<ExpressionT>* non_patterns_to_rewrite() { | 463 ZoneList<ExpressionT>* non_patterns_to_rewrite() { |
464 return &non_patterns_to_rewrite_; | 464 return &non_patterns_to_rewrite_; |
465 } | 465 } |
466 | 466 |
467 void next_function_is_parenthesized(bool parenthesized) { | 467 bool next_function_is_parenthesized() const { |
| 468 return next_function_is_parenthesized_; |
| 469 } |
| 470 |
| 471 void set_next_function_is_parenthesized(bool parenthesized) { |
468 next_function_is_parenthesized_ = parenthesized; | 472 next_function_is_parenthesized_ = parenthesized; |
469 } | 473 } |
470 | 474 |
471 bool this_function_is_parenthesized() const { | 475 bool this_function_is_parenthesized() const { |
472 return this_function_is_parenthesized_; | 476 return this_function_is_parenthesized_; |
473 } | 477 } |
474 | 478 |
475 private: | 479 private: |
476 void AddDestructuringAssignment(DestructuringAssignment pair) { | 480 void AddDestructuringAssignment(DestructuringAssignment pair) { |
477 destructuring_assignments_to_rewrite_.Add(pair, this->zone()); | 481 destructuring_assignments_to_rewrite_.Add(pair, this->zone()); |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 bool allow_lazy_; | 1234 bool allow_lazy_; |
1231 bool allow_natives_; | 1235 bool allow_natives_; |
1232 bool allow_tailcalls_; | 1236 bool allow_tailcalls_; |
1233 bool allow_harmony_restrictive_declarations_; | 1237 bool allow_harmony_restrictive_declarations_; |
1234 bool allow_harmony_do_expressions_; | 1238 bool allow_harmony_do_expressions_; |
1235 bool allow_harmony_for_in_; | 1239 bool allow_harmony_for_in_; |
1236 bool allow_harmony_function_sent_; | 1240 bool allow_harmony_function_sent_; |
1237 bool allow_harmony_async_await_; | 1241 bool allow_harmony_async_await_; |
1238 bool allow_harmony_restrictive_generators_; | 1242 bool allow_harmony_restrictive_generators_; |
1239 bool allow_harmony_trailing_commas_; | 1243 bool allow_harmony_trailing_commas_; |
| 1244 |
| 1245 friend class DiscardableZoneScope; |
1240 }; | 1246 }; |
1241 | 1247 |
1242 template <class Traits> | 1248 template <class Traits> |
1243 ParserBase<Traits>::FunctionState::FunctionState( | 1249 ParserBase<Traits>::FunctionState::FunctionState( |
1244 FunctionState** function_state_stack, ScopeState** scope_stack, | 1250 FunctionState** function_state_stack, ScopeState** scope_stack, |
1245 Scope* scope, FunctionKind kind) | 1251 Scope* scope, FunctionKind kind) |
1246 : ScopeState(scope_stack, scope), | 1252 : ScopeState(scope_stack, scope), |
1247 next_materialized_literal_index_(0), | 1253 next_materialized_literal_index_(0), |
1248 expected_property_count_(0), | 1254 expected_property_count_(0), |
1249 kind_(kind), | 1255 kind_(kind), |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 ReportMessageAt(scanner()->peek_location(), | 1629 ReportMessageAt(scanner()->peek_location(), |
1624 MessageTemplate::kParamAfterRest); | 1630 MessageTemplate::kParamAfterRest); |
1625 *ok = false; | 1631 *ok = false; |
1626 return this->EmptyExpression(); | 1632 return this->EmptyExpression(); |
1627 } | 1633 } |
1628 Expect(Token::RPAREN, CHECK_OK); | 1634 Expect(Token::RPAREN, CHECK_OK); |
1629 return factory()->NewSpread(expr, ellipsis_pos, expr_pos); | 1635 return factory()->NewSpread(expr, ellipsis_pos, expr_pos); |
1630 } | 1636 } |
1631 // Heuristically try to detect immediately called functions before | 1637 // Heuristically try to detect immediately called functions before |
1632 // seeing the call parentheses. | 1638 // seeing the call parentheses. |
1633 function_state_->next_function_is_parenthesized(peek() == | 1639 function_state_->set_next_function_is_parenthesized(peek() == |
1634 Token::FUNCTION); | 1640 Token::FUNCTION); |
1635 ExpressionT expr = this->ParseExpression(true, classifier, CHECK_OK); | 1641 ExpressionT expr = this->ParseExpression(true, classifier, CHECK_OK); |
1636 Expect(Token::RPAREN, CHECK_OK); | 1642 Expect(Token::RPAREN, CHECK_OK); |
1637 return expr; | 1643 return expr; |
1638 } | 1644 } |
1639 | 1645 |
1640 case Token::CLASS: { | 1646 case Token::CLASS: { |
1641 BindingPatternUnexpectedToken(classifier); | 1647 BindingPatternUnexpectedToken(classifier); |
1642 Consume(Token::CLASS); | 1648 Consume(Token::CLASS); |
1643 int class_token_position = position(); | 1649 int class_token_position = position(); |
1644 IdentifierT name = this->EmptyIdentifier(); | 1650 IdentifierT name = this->EmptyIdentifier(); |
(...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3669 has_seen_constructor_ = true; | 3675 has_seen_constructor_ = true; |
3670 return; | 3676 return; |
3671 } | 3677 } |
3672 } | 3678 } |
3673 | 3679 |
3674 | 3680 |
3675 } // namespace internal | 3681 } // namespace internal |
3676 } // namespace v8 | 3682 } // namespace v8 |
3677 | 3683 |
3678 #endif // V8_PARSING_PARSER_BASE_H | 3684 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |