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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/ast-literal-reindexer.h" | 9 #include "src/ast-literal-reindexer.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 return factory->NewSuperCallReference( | 782 return factory->NewSuperCallReference( |
783 ThisExpression(scope, factory, pos)->AsVariableProxy(), new_target_proxy, | 783 ThisExpression(scope, factory, pos)->AsVariableProxy(), new_target_proxy, |
784 this_function_proxy, pos); | 784 this_function_proxy, pos); |
785 } | 785 } |
786 | 786 |
787 | 787 |
788 Expression* ParserTraits::NewTargetExpression(Scope* scope, | 788 Expression* ParserTraits::NewTargetExpression(Scope* scope, |
789 AstNodeFactory* factory, | 789 AstNodeFactory* factory, |
790 int pos) { | 790 int pos) { |
791 static const int kNewTargetStringLength = 10; | 791 static const int kNewTargetStringLength = 10; |
792 return scope->NewUnresolved( | 792 auto proxy = scope->NewUnresolved( |
793 factory, parser_->ast_value_factory()->new_target_string(), | 793 factory, parser_->ast_value_factory()->new_target_string(), |
794 Variable::NORMAL, pos, pos + kNewTargetStringLength); | 794 Variable::NORMAL, pos, pos + kNewTargetStringLength); |
| 795 proxy->set_is_new_target(); |
| 796 return proxy; |
795 } | 797 } |
796 | 798 |
797 | 799 |
798 Expression* ParserTraits::DefaultConstructor(bool call_super, Scope* scope, | 800 Expression* ParserTraits::DefaultConstructor(bool call_super, Scope* scope, |
799 int pos, int end_pos, | 801 int pos, int end_pos, |
800 LanguageMode mode) { | 802 LanguageMode mode) { |
801 return parser_->DefaultConstructor(call_super, scope, pos, end_pos, mode); | 803 return parser_->DefaultConstructor(call_super, scope, pos, end_pos, mode); |
802 } | 804 } |
803 | 805 |
804 | 806 |
(...skipping 2867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3672 return loop; | 3674 return loop; |
3673 } | 3675 } |
3674 } else { | 3676 } else { |
3675 init = parsing_result.BuildInitializationBlock( | 3677 init = parsing_result.BuildInitializationBlock( |
3676 IsLexicalVariableMode(parsing_result.descriptor.mode) | 3678 IsLexicalVariableMode(parsing_result.descriptor.mode) |
3677 ? &lexical_bindings | 3679 ? &lexical_bindings |
3678 : nullptr, | 3680 : nullptr, |
3679 CHECK_OK); | 3681 CHECK_OK); |
3680 } | 3682 } |
3681 } else { | 3683 } else { |
3682 Scanner::Location lhs_location = scanner()->peek_location(); | 3684 int lhs_beg_pos = peek_position(); |
3683 Expression* expression = ParseExpression(false, CHECK_OK); | 3685 Expression* expression = ParseExpression(false, CHECK_OK); |
| 3686 int lhs_end_pos = scanner()->location().end_pos; |
3684 ForEachStatement::VisitMode mode; | 3687 ForEachStatement::VisitMode mode; |
3685 bool accept_OF = expression->IsVariableProxy(); | 3688 bool accept_OF = expression->IsVariableProxy(); |
3686 is_let_identifier_expression = | 3689 is_let_identifier_expression = |
3687 expression->IsVariableProxy() && | 3690 expression->IsVariableProxy() && |
3688 expression->AsVariableProxy()->raw_name() == | 3691 expression->AsVariableProxy()->raw_name() == |
3689 ast_value_factory()->let_string(); | 3692 ast_value_factory()->let_string(); |
3690 | 3693 |
3691 if (CheckInOrOf(accept_OF, &mode, ok)) { | 3694 if (CheckInOrOf(accept_OF, &mode, ok)) { |
3692 if (!*ok) return nullptr; | 3695 if (!*ok) return nullptr; |
3693 expression = this->CheckAndRewriteReferenceExpression( | 3696 expression = this->CheckAndRewriteReferenceExpression( |
3694 expression, lhs_location, MessageTemplate::kInvalidLhsInFor, | 3697 expression, lhs_beg_pos, lhs_end_pos, |
3695 CHECK_OK); | 3698 MessageTemplate::kInvalidLhsInFor, CHECK_OK); |
3696 | 3699 |
3697 ForEachStatement* loop = | 3700 ForEachStatement* loop = |
3698 factory()->NewForEachStatement(mode, labels, stmt_pos); | 3701 factory()->NewForEachStatement(mode, labels, stmt_pos); |
3699 Target target(&this->target_stack_, loop); | 3702 Target target(&this->target_stack_, loop); |
3700 | 3703 |
3701 Expression* enumerable = ParseExpression(true, CHECK_OK); | 3704 Expression* enumerable = ParseExpression(true, CHECK_OK); |
3702 Expect(Token::RPAREN, CHECK_OK); | 3705 Expect(Token::RPAREN, CHECK_OK); |
3703 | 3706 |
3704 Statement* body = ParseSubStatement(NULL, CHECK_OK); | 3707 Statement* body = ParseSubStatement(NULL, CHECK_OK); |
3705 InitializeForEachStatement(loop, expression, enumerable, body); | 3708 InitializeForEachStatement(loop, expression, enumerable, body); |
3706 scope_ = saved_scope; | 3709 scope_ = saved_scope; |
3707 for_scope->set_end_position(scanner()->location().end_pos); | 3710 for_scope->set_end_position(scanner()->location().end_pos); |
3708 for_scope = for_scope->FinalizeBlockScope(); | 3711 for_scope = for_scope->FinalizeBlockScope(); |
3709 DCHECK(for_scope == NULL); | 3712 DCHECK(for_scope == NULL); |
3710 // Parsed for-in loop. | 3713 // Parsed for-in loop. |
3711 return loop; | 3714 return loop; |
3712 | 3715 |
3713 } else { | 3716 } else { |
3714 init = | 3717 init = factory()->NewExpressionStatement(expression, lhs_beg_pos); |
3715 factory()->NewExpressionStatement(expression, lhs_location.beg_pos); | |
3716 } | 3718 } |
3717 } | 3719 } |
3718 } | 3720 } |
3719 | 3721 |
3720 // Standard 'for' loop | 3722 // Standard 'for' loop |
3721 ForStatement* loop = factory()->NewForStatement(labels, stmt_pos); | 3723 ForStatement* loop = factory()->NewForStatement(labels, stmt_pos); |
3722 Target target(&this->target_stack_, loop); | 3724 Target target(&this->target_stack_, loop); |
3723 | 3725 |
3724 // Parsed initializer at this point. | 3726 // Parsed initializer at this point. |
3725 // Detect attempts at 'let' declarations in sloppy mode. | 3727 // Detect attempts at 'let' declarations in sloppy mode. |
(...skipping 2289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6015 Expression* Parser::SpreadCallNew(Expression* function, | 6017 Expression* Parser::SpreadCallNew(Expression* function, |
6016 ZoneList<v8::internal::Expression*>* args, | 6018 ZoneList<v8::internal::Expression*>* args, |
6017 int pos) { | 6019 int pos) { |
6018 args->InsertAt(0, function, zone()); | 6020 args->InsertAt(0, function, zone()); |
6019 | 6021 |
6020 return factory()->NewCallRuntime( | 6022 return factory()->NewCallRuntime( |
6021 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 6023 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
6022 } | 6024 } |
6023 } // namespace internal | 6025 } // namespace internal |
6024 } // namespace v8 | 6026 } // namespace v8 |
OLD | NEW |