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