| 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 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/ast-expression-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
| 10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 } | 757 } |
| 758 | 758 |
| 759 | 759 |
| 760 ClassLiteral* ParserTraits::ParseClassLiteral( | 760 ClassLiteral* ParserTraits::ParseClassLiteral( |
| 761 const AstRawString* name, Scanner::Location class_name_location, | 761 const AstRawString* name, Scanner::Location class_name_location, |
| 762 bool name_is_strict_reserved, int pos, bool* ok) { | 762 bool name_is_strict_reserved, int pos, bool* ok) { |
| 763 return parser_->ParseClassLiteral(name, class_name_location, | 763 return parser_->ParseClassLiteral(name, class_name_location, |
| 764 name_is_strict_reserved, pos, ok); | 764 name_is_strict_reserved, pos, ok); |
| 765 } | 765 } |
| 766 | 766 |
| 767 void ParserTraits::MarkTailPosition(Expression* expression) { |
| 768 expression->MarkTail(); |
| 769 } |
| 767 | 770 |
| 768 Parser::Parser(ParseInfo* info) | 771 Parser::Parser(ParseInfo* info) |
| 769 : ParserBase<ParserTraits>(info->zone(), &scanner_, info->stack_limit(), | 772 : ParserBase<ParserTraits>(info->zone(), &scanner_, info->stack_limit(), |
| 770 info->extension(), info->ast_value_factory(), | 773 info->extension(), info->ast_value_factory(), |
| 771 NULL, this), | 774 NULL, this), |
| 772 scanner_(info->unicode_cache()), | 775 scanner_(info->unicode_cache()), |
| 773 reusable_preparser_(NULL), | 776 reusable_preparser_(NULL), |
| 774 original_scope_(NULL), | 777 original_scope_(NULL), |
| 775 target_stack_(NULL), | 778 target_stack_(NULL), |
| 776 compile_options_(info->compile_options()), | 779 compile_options_(info->compile_options()), |
| (...skipping 2810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3587 | 3590 |
| 3588 Expect(Token::RPAREN, CHECK_OK); | 3591 Expect(Token::RPAREN, CHECK_OK); |
| 3589 | 3592 |
| 3590 Scope* body_scope = NewScope(scope_, BLOCK_SCOPE); | 3593 Scope* body_scope = NewScope(scope_, BLOCK_SCOPE); |
| 3591 body_scope->set_start_position(scanner()->location().beg_pos); | 3594 body_scope->set_start_position(scanner()->location().beg_pos); |
| 3592 | 3595 |
| 3593 Block* body_block = | 3596 Block* body_block = |
| 3594 factory()->NewBlock(NULL, 3, false, RelocInfo::kNoPosition); | 3597 factory()->NewBlock(NULL, 3, false, RelocInfo::kNoPosition); |
| 3595 | 3598 |
| 3596 { | 3599 { |
| 3600 DontCollectExpressionsInTailPositionScope no_tail_calls( |
| 3601 function_state_); |
| 3597 BlockState block_state(&scope_, body_scope); | 3602 BlockState block_state(&scope_, body_scope); |
| 3598 | 3603 |
| 3599 Statement* body = ParseScopedStatement(NULL, true, CHECK_OK); | 3604 Statement* body = ParseScopedStatement(NULL, true, CHECK_OK); |
| 3600 | 3605 |
| 3601 auto each_initialization_block = | 3606 auto each_initialization_block = |
| 3602 factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition); | 3607 factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition); |
| 3603 { | 3608 { |
| 3604 auto descriptor = parsing_result.descriptor; | 3609 auto descriptor = parsing_result.descriptor; |
| 3605 descriptor.declaration_pos = RelocInfo::kNoPosition; | 3610 descriptor.declaration_pos = RelocInfo::kNoPosition; |
| 3606 descriptor.initialization_pos = RelocInfo::kNoPosition; | 3611 descriptor.initialization_pos = RelocInfo::kNoPosition; |
| (...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4643 factory()->NewThisFunction(pos), | 4648 factory()->NewThisFunction(pos), |
| 4644 RelocInfo::kNoPosition), | 4649 RelocInfo::kNoPosition), |
| 4645 RelocInfo::kNoPosition)); | 4650 RelocInfo::kNoPosition)); |
| 4646 } | 4651 } |
| 4647 | 4652 |
| 4648 // ES6 14.6.1 Static Semantics: IsInTailPosition | 4653 // ES6 14.6.1 Static Semantics: IsInTailPosition |
| 4649 // Mark collected return expressions that are in tail call position. | 4654 // Mark collected return expressions that are in tail call position. |
| 4650 const List<Expression*>& expressions_in_tail_position = | 4655 const List<Expression*>& expressions_in_tail_position = |
| 4651 function_state_->expressions_in_tail_position(); | 4656 function_state_->expressions_in_tail_position(); |
| 4652 for (int i = 0; i < expressions_in_tail_position.length(); ++i) { | 4657 for (int i = 0; i < expressions_in_tail_position.length(); ++i) { |
| 4653 expressions_in_tail_position[i]->MarkTail(); | 4658 MarkTailPosition(expressions_in_tail_position[i]); |
| 4654 } | 4659 } |
| 4655 return result; | 4660 return result; |
| 4656 } | 4661 } |
| 4657 | 4662 |
| 4658 | 4663 |
| 4659 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( | 4664 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( |
| 4660 SingletonLogger* logger, Scanner::BookmarkScope* bookmark) { | 4665 SingletonLogger* logger, Scanner::BookmarkScope* bookmark) { |
| 4661 // This function may be called on a background thread too; record only the | 4666 // This function may be called on a background thread too; record only the |
| 4662 // main thread preparse times. | 4667 // main thread preparse times. |
| 4663 if (pre_parse_timer_ != NULL) { | 4668 if (pre_parse_timer_ != NULL) { |
| (...skipping 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6869 try_block, target); | 6874 try_block, target); |
| 6870 final_loop = target; | 6875 final_loop = target; |
| 6871 } | 6876 } |
| 6872 | 6877 |
| 6873 return final_loop; | 6878 return final_loop; |
| 6874 } | 6879 } |
| 6875 | 6880 |
| 6876 | 6881 |
| 6877 } // namespace internal | 6882 } // namespace internal |
| 6878 } // namespace v8 | 6883 } // namespace v8 |
| OLD | NEW |