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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 return return_expr_context_; | 439 return return_expr_context_; |
440 } | 440 } |
441 void set_return_expr_context(ReturnExprContext context) { | 441 void set_return_expr_context(ReturnExprContext context) { |
442 return_expr_context_ = context; | 442 return_expr_context_ = context; |
443 } | 443 } |
444 | 444 |
445 ZoneList<ExpressionT>* non_patterns_to_rewrite() { | 445 ZoneList<ExpressionT>* non_patterns_to_rewrite() { |
446 return &non_patterns_to_rewrite_; | 446 return &non_patterns_to_rewrite_; |
447 } | 447 } |
448 | 448 |
449 void next_function_is_parenthesized(bool parenthesized) { | 449 bool next_function_is_parenthesized() const { |
| 450 return next_function_is_parenthesized_; |
| 451 } |
| 452 |
| 453 void set_next_function_is_parenthesized(bool parenthesized) { |
450 next_function_is_parenthesized_ = parenthesized; | 454 next_function_is_parenthesized_ = parenthesized; |
451 } | 455 } |
452 | 456 |
453 bool this_function_is_parenthesized() const { | 457 bool this_function_is_parenthesized() const { |
454 return this_function_is_parenthesized_; | 458 return this_function_is_parenthesized_; |
455 } | 459 } |
456 | 460 |
457 private: | 461 private: |
458 void AddDestructuringAssignment(DestructuringAssignment pair) { | 462 void AddDestructuringAssignment(DestructuringAssignment pair) { |
459 destructuring_assignments_to_rewrite_.Add(pair, this->zone()); | 463 destructuring_assignments_to_rewrite_.Add(pair, this->zone()); |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 bool allow_lazy_; | 1218 bool allow_lazy_; |
1215 bool allow_natives_; | 1219 bool allow_natives_; |
1216 bool allow_tailcalls_; | 1220 bool allow_tailcalls_; |
1217 bool allow_harmony_restrictive_declarations_; | 1221 bool allow_harmony_restrictive_declarations_; |
1218 bool allow_harmony_do_expressions_; | 1222 bool allow_harmony_do_expressions_; |
1219 bool allow_harmony_for_in_; | 1223 bool allow_harmony_for_in_; |
1220 bool allow_harmony_function_sent_; | 1224 bool allow_harmony_function_sent_; |
1221 bool allow_harmony_async_await_; | 1225 bool allow_harmony_async_await_; |
1222 bool allow_harmony_restrictive_generators_; | 1226 bool allow_harmony_restrictive_generators_; |
1223 bool allow_harmony_trailing_commas_; | 1227 bool allow_harmony_trailing_commas_; |
| 1228 |
| 1229 friend class DiscardableZoneScope; |
1224 }; | 1230 }; |
1225 | 1231 |
1226 template <class Traits> | 1232 template <class Traits> |
1227 ParserBase<Traits>::FunctionState::FunctionState( | 1233 ParserBase<Traits>::FunctionState::FunctionState( |
1228 FunctionState** function_state_stack, ScopeState** scope_stack, | 1234 FunctionState** function_state_stack, ScopeState** scope_stack, |
1229 Scope* scope, FunctionKind kind) | 1235 Scope* scope, FunctionKind kind) |
1230 : ScopeState(scope_stack, scope), | 1236 : ScopeState(scope_stack, scope), |
1231 next_materialized_literal_index_(0), | 1237 next_materialized_literal_index_(0), |
1232 expected_property_count_(0), | 1238 expected_property_count_(0), |
1233 kind_(kind), | 1239 kind_(kind), |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 ReportMessageAt(scanner()->peek_location(), | 1614 ReportMessageAt(scanner()->peek_location(), |
1609 MessageTemplate::kParamAfterRest); | 1615 MessageTemplate::kParamAfterRest); |
1610 *ok = false; | 1616 *ok = false; |
1611 return this->EmptyExpression(); | 1617 return this->EmptyExpression(); |
1612 } | 1618 } |
1613 Expect(Token::RPAREN, CHECK_OK); | 1619 Expect(Token::RPAREN, CHECK_OK); |
1614 return factory()->NewSpread(expr, ellipsis_pos, expr_pos); | 1620 return factory()->NewSpread(expr, ellipsis_pos, expr_pos); |
1615 } | 1621 } |
1616 // Heuristically try to detect immediately called functions before | 1622 // Heuristically try to detect immediately called functions before |
1617 // seeing the call parentheses. | 1623 // seeing the call parentheses. |
1618 function_state_->next_function_is_parenthesized(peek() == | 1624 function_state_->set_next_function_is_parenthesized(peek() == |
1619 Token::FUNCTION); | 1625 Token::FUNCTION); |
1620 ExpressionT expr = this->ParseExpression(true, classifier, CHECK_OK); | 1626 ExpressionT expr = this->ParseExpression(true, classifier, CHECK_OK); |
1621 Expect(Token::RPAREN, CHECK_OK); | 1627 Expect(Token::RPAREN, CHECK_OK); |
1622 return expr; | 1628 return expr; |
1623 } | 1629 } |
1624 | 1630 |
1625 case Token::CLASS: { | 1631 case Token::CLASS: { |
1626 BindingPatternUnexpectedToken(classifier); | 1632 BindingPatternUnexpectedToken(classifier); |
1627 Consume(Token::CLASS); | 1633 Consume(Token::CLASS); |
1628 int class_token_position = position(); | 1634 int class_token_position = position(); |
1629 IdentifierT name = this->EmptyIdentifier(); | 1635 IdentifierT name = this->EmptyIdentifier(); |
(...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3657 has_seen_constructor_ = true; | 3663 has_seen_constructor_ = true; |
3658 return; | 3664 return; |
3659 } | 3665 } |
3660 } | 3666 } |
3661 | 3667 |
3662 | 3668 |
3663 } // namespace internal | 3669 } // namespace internal |
3664 } // namespace v8 | 3670 } // namespace v8 |
3665 | 3671 |
3666 #endif // V8_PARSING_PARSER_BASE_H | 3672 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |