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 4452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4463 // - Any return statement inside the body will have its argument wrapped | 4463 // - Any return statement inside the body will have its argument wrapped |
4464 // in a "done" iterator result object. | 4464 // in a "done" iterator result object. |
4465 // - If the generator terminates for whatever reason, we must close it. | 4465 // - If the generator terminates for whatever reason, we must close it. |
4466 // Hence the finally clause. | 4466 // Hence the finally clause. |
4467 | 4467 |
4468 Block* try_block = | 4468 Block* try_block = |
4469 factory()->NewBlock(nullptr, 3, false, RelocInfo::kNoPosition); | 4469 factory()->NewBlock(nullptr, 3, false, RelocInfo::kNoPosition); |
4470 | 4470 |
4471 { | 4471 { |
4472 ZoneList<Expression*>* arguments = | 4472 ZoneList<Expression*>* arguments = |
4473 new (zone()) ZoneList<Expression*>(0, zone()); | 4473 new (zone()) ZoneList<Expression*>(2, zone()); |
| 4474 arguments->Add(factory()->NewThisFunction(pos), zone()); |
| 4475 arguments->Add( |
| 4476 ThisExpression(scope_, factory(), RelocInfo::kNoPosition), zone()); |
4474 CallRuntime* allocation = factory()->NewCallRuntime( | 4477 CallRuntime* allocation = factory()->NewCallRuntime( |
4475 Runtime::kCreateJSGeneratorObject, arguments, pos); | 4478 Runtime::kCreateJSGeneratorObject, arguments, pos); |
| 4479 |
4476 VariableProxy* init_proxy = factory()->NewVariableProxy( | 4480 VariableProxy* init_proxy = factory()->NewVariableProxy( |
4477 function_state_->generator_object_variable()); | 4481 function_state_->generator_object_variable()); |
4478 Assignment* assignment = factory()->NewAssignment( | 4482 Assignment* assignment = factory()->NewAssignment( |
4479 Token::INIT, init_proxy, allocation, RelocInfo::kNoPosition); | 4483 Token::INIT, init_proxy, allocation, RelocInfo::kNoPosition); |
4480 VariableProxy* get_proxy = factory()->NewVariableProxy( | 4484 VariableProxy* get_proxy = factory()->NewVariableProxy( |
4481 function_state_->generator_object_variable()); | 4485 function_state_->generator_object_variable()); |
4482 Yield* yield = | 4486 Yield* yield = |
4483 factory()->NewYield(get_proxy, assignment, RelocInfo::kNoPosition); | 4487 factory()->NewYield(get_proxy, assignment, RelocInfo::kNoPosition); |
4484 try_block->statements()->Add( | 4488 try_block->statements()->Add( |
4485 factory()->NewExpressionStatement(yield, RelocInfo::kNoPosition), | 4489 factory()->NewExpressionStatement(yield, RelocInfo::kNoPosition), |
(...skipping 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6787 try_block, target); | 6791 try_block, target); |
6788 final_loop = target; | 6792 final_loop = target; |
6789 } | 6793 } |
6790 | 6794 |
6791 return final_loop; | 6795 return final_loop; |
6792 } | 6796 } |
6793 | 6797 |
6794 | 6798 |
6795 } // namespace internal | 6799 } // namespace internal |
6796 } // namespace v8 | 6800 } // namespace v8 |
OLD | NEW |