Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/parsing/rewriter.cc

Issue 1643903003: [generators] Desugar yield*. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Refer to ResumeMode Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/preparser.h ('k') | test/mjsunit/es6/generators-iteration.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/rewriter.h" 5 #include "src/parsing/rewriter.h"
6 6
7 #include "src/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/parsing/parser.h" 9 #include "src/parsing/parser.h"
10 10
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 void Processor::VisitTryFinallyStatement(TryFinallyStatement* node) { 218 void Processor::VisitTryFinallyStatement(TryFinallyStatement* node) {
219 // Rewrite both try and finally block (in reverse order). 219 // Rewrite both try and finally block (in reverse order).
220 bool set_after = is_set_; 220 bool set_after = is_set_;
221 is_set_ = true; // Don't normally need to assign in finally block. 221 is_set_ = true; // Don't normally need to assign in finally block.
222 Visit(node->finally_block()); 222 Visit(node->finally_block());
223 node->set_finally_block(replacement_->AsBlock()); 223 node->set_finally_block(replacement_->AsBlock());
224 { // Save .result value at the beginning of the finally block and restore it 224 { // Save .result value at the beginning of the finally block and restore it
225 // at the end again: ".backup = .result; ...; .result = .backup" 225 // at the end again: ".backup = .result; ...; .result = .backup"
226 // This is necessary because the finally block does not normally contribute 226 // This is necessary because the finally block does not normally contribute
227 // to the completion value. 227 // to the completion value.
228 CHECK(scope() != nullptr);
228 Variable* backup = scope()->NewTemporary( 229 Variable* backup = scope()->NewTemporary(
229 factory()->ast_value_factory()->dot_result_string()); 230 factory()->ast_value_factory()->dot_result_string());
230 Expression* backup_proxy = factory()->NewVariableProxy(backup); 231 Expression* backup_proxy = factory()->NewVariableProxy(backup);
231 Expression* result_proxy = factory()->NewVariableProxy(result_); 232 Expression* result_proxy = factory()->NewVariableProxy(result_);
232 Expression* save = factory()->NewAssignment( 233 Expression* save = factory()->NewAssignment(
233 Token::ASSIGN, backup_proxy, result_proxy, RelocInfo::kNoPosition); 234 Token::ASSIGN, backup_proxy, result_proxy, RelocInfo::kNoPosition);
234 Expression* restore = factory()->NewAssignment( 235 Expression* restore = factory()->NewAssignment(
235 Token::ASSIGN, result_proxy, backup_proxy, RelocInfo::kNoPosition); 236 Token::ASSIGN, result_proxy, backup_proxy, RelocInfo::kNoPosition);
236 node->finally_block()->statements()->InsertAt( 237 node->finally_block()->statements()->InsertAt(
237 0, factory()->NewExpressionStatement(save, RelocInfo::kNoPosition), 238 0, factory()->NewExpressionStatement(save, RelocInfo::kNoPosition),
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 processor.SetResult(undef), expr->position()); 395 processor.SetResult(undef), expr->position());
395 body->Add(completion, factory->zone()); 396 body->Add(completion, factory->zone());
396 } 397 }
397 } 398 }
398 return true; 399 return true;
399 } 400 }
400 401
401 402
402 } // namespace internal 403 } // namespace internal
403 } // namespace v8 404 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/preparser.h ('k') | test/mjsunit/es6/generators-iteration.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698