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 3190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3201 } | 3201 } |
3202 | 3202 |
3203 // each = result.value | 3203 // each = result.value |
3204 { | 3204 { |
3205 Expression* value_literal = factory()->NewStringLiteral( | 3205 Expression* value_literal = factory()->NewStringLiteral( |
3206 ast_value_factory()->value_string(), RelocInfo::kNoPosition); | 3206 ast_value_factory()->value_string(), RelocInfo::kNoPosition); |
3207 Expression* result_proxy = factory()->NewVariableProxy(result); | 3207 Expression* result_proxy = factory()->NewVariableProxy(result); |
3208 Expression* result_value = factory()->NewProperty( | 3208 Expression* result_value = factory()->NewProperty( |
3209 result_proxy, value_literal, RelocInfo::kNoPosition); | 3209 result_proxy, value_literal, RelocInfo::kNoPosition); |
3210 assign_each = factory()->NewAssignment(Token::ASSIGN, each, result_value, | 3210 assign_each = factory()->NewAssignment(Token::ASSIGN, each, result_value, |
3211 each->position()); | 3211 RelocInfo::kNoPosition); |
3212 } | 3212 } |
3213 | 3213 |
3214 for_of->Initialize(each, subject, body, | 3214 for_of->Initialize(each, subject, body, |
3215 assign_iterator, | 3215 assign_iterator, |
3216 next_result, | 3216 next_result, |
3217 result_done, | 3217 result_done, |
3218 assign_each); | 3218 assign_each); |
3219 } else { | 3219 } else { |
3220 stmt->Initialize(each, subject, body); | 3220 stmt->Initialize(each, subject, body); |
3221 } | 3221 } |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3585 factory()->NewBlock(NULL, 3, false, RelocInfo::kNoPosition); | 3585 factory()->NewBlock(NULL, 3, false, RelocInfo::kNoPosition); |
3586 | 3586 |
3587 auto each_initialization_block = | 3587 auto each_initialization_block = |
3588 factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition); | 3588 factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition); |
3589 { | 3589 { |
3590 DCHECK(parsing_result.declarations.length() == 1); | 3590 DCHECK(parsing_result.declarations.length() == 1); |
3591 DeclarationParsingResult::Declaration decl = | 3591 DeclarationParsingResult::Declaration decl = |
3592 parsing_result.declarations[0]; | 3592 parsing_result.declarations[0]; |
3593 auto descriptor = parsing_result.descriptor; | 3593 auto descriptor = parsing_result.descriptor; |
3594 descriptor.declaration_pos = RelocInfo::kNoPosition; | 3594 descriptor.declaration_pos = RelocInfo::kNoPosition; |
| 3595 descriptor.initialization_pos = RelocInfo::kNoPosition; |
3595 decl.initializer = factory()->NewVariableProxy(temp); | 3596 decl.initializer = factory()->NewVariableProxy(temp); |
3596 | 3597 |
3597 PatternRewriter::DeclareAndInitializeVariables( | 3598 PatternRewriter::DeclareAndInitializeVariables( |
3598 each_initialization_block, &descriptor, &decl, | 3599 each_initialization_block, &descriptor, &decl, |
3599 IsLexicalVariableMode(descriptor.mode) ? &lexical_bindings | 3600 IsLexicalVariableMode(descriptor.mode) ? &lexical_bindings |
3600 : nullptr, | 3601 : nullptr, |
3601 CHECK_OK); | 3602 CHECK_OK); |
3602 } | 3603 } |
3603 | 3604 |
3604 body_block->AddStatement(each_initialization_block, zone()); | 3605 body_block->AddStatement(each_initialization_block, zone()); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3681 Statement* body = ParseSubStatement(NULL, CHECK_OK); | 3682 Statement* body = ParseSubStatement(NULL, CHECK_OK); |
3682 InitializeForEachStatement(loop, expression, enumerable, body); | 3683 InitializeForEachStatement(loop, expression, enumerable, body); |
3683 scope_ = saved_scope; | 3684 scope_ = saved_scope; |
3684 for_scope->set_end_position(scanner()->location().end_pos); | 3685 for_scope->set_end_position(scanner()->location().end_pos); |
3685 for_scope = for_scope->FinalizeBlockScope(); | 3686 for_scope = for_scope->FinalizeBlockScope(); |
3686 DCHECK(for_scope == NULL); | 3687 DCHECK(for_scope == NULL); |
3687 // Parsed for-in loop. | 3688 // Parsed for-in loop. |
3688 return loop; | 3689 return loop; |
3689 | 3690 |
3690 } else { | 3691 } else { |
3691 init = factory()->NewExpressionStatement(expression, position()); | 3692 init = |
| 3693 factory()->NewExpressionStatement(expression, lhs_location.beg_pos); |
3692 } | 3694 } |
3693 } | 3695 } |
3694 } | 3696 } |
3695 | 3697 |
3696 // Standard 'for' loop | 3698 // Standard 'for' loop |
3697 ForStatement* loop = factory()->NewForStatement(labels, stmt_pos); | 3699 ForStatement* loop = factory()->NewForStatement(labels, stmt_pos); |
3698 Target target(&this->target_stack_, loop); | 3700 Target target(&this->target_stack_, loop); |
3699 | 3701 |
3700 // Parsed initializer at this point. | 3702 // Parsed initializer at this point. |
3701 // Detect attempts at 'let' declarations in sloppy mode. | 3703 // Detect attempts at 'let' declarations in sloppy mode. |
(...skipping 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5935 Expression* Parser::SpreadCallNew(Expression* function, | 5937 Expression* Parser::SpreadCallNew(Expression* function, |
5936 ZoneList<v8::internal::Expression*>* args, | 5938 ZoneList<v8::internal::Expression*>* args, |
5937 int pos) { | 5939 int pos) { |
5938 args->InsertAt(0, function, zone()); | 5940 args->InsertAt(0, function, zone()); |
5939 | 5941 |
5940 return factory()->NewCallRuntime( | 5942 return factory()->NewCallRuntime( |
5941 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 5943 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
5942 } | 5944 } |
5943 } // namespace internal | 5945 } // namespace internal |
5944 } // namespace v8 | 5946 } // namespace v8 |
OLD | NEW |