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

Side by Side Diff: src/rewriter.cc

Issue 1177053006: [es6] Fix completion values of for loops with lexical variables (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: offline feedback Created 5 years, 6 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/prettyprinter.cc ('k') | test/mjsunit/es6/block-for.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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/ast.h" 7 #include "src/ast.h"
8 #include "src/parser.h" 8 #include "src/parser.h"
9 #include "src/rewriter.h" 9 #include "src/rewriter.h"
10 #include "src/scopes.h" 10 #include "src/scopes.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 void Processor::VisitBlock(Block* node) { 77 void Processor::VisitBlock(Block* node) {
78 // An initializer block is the rewritten form of a variable declaration 78 // An initializer block is the rewritten form of a variable declaration
79 // with initialization expressions. The initializer block contains the 79 // with initialization expressions. The initializer block contains the
80 // list of assignments corresponding to the initialization expressions. 80 // list of assignments corresponding to the initialization expressions.
81 // While unclear from the spec (ECMA-262, 3rd., 12.2), the value of 81 // While unclear from the spec (ECMA-262, 3rd., 12.2), the value of
82 // a variable declaration with initialization expression is 'undefined' 82 // a variable declaration with initialization expression is 'undefined'
83 // with some JS VMs: For instance, using smjs, print(eval('var x = 7')) 83 // with some JS VMs: For instance, using smjs, print(eval('var x = 7'))
84 // returns 'undefined'. To obtain the same behavior with v8, we need 84 // returns 'undefined'. To obtain the same behavior with v8, we need
85 // to prevent rewriting in that case. 85 // to prevent rewriting in that case.
86 if (!node->is_initializer_block()) Process(node->statements()); 86 if (!node->ignore_completion_value()) Process(node->statements());
87 } 87 }
88 88
89 89
90 void Processor::VisitExpressionStatement(ExpressionStatement* node) { 90 void Processor::VisitExpressionStatement(ExpressionStatement* node) {
91 // Rewrite : <x>; -> .result = <x>; 91 // Rewrite : <x>; -> .result = <x>;
92 if (!is_set_ && !node->expression()->IsThrow()) { 92 if (!is_set_ && !node->expression()->IsThrow()) {
93 node->set_expression(SetResult(node->expression())); 93 node->set_expression(SetResult(node->expression()));
94 if (!in_try_) is_set_ = true; 94 if (!in_try_) is_set_ = true;
95 } 95 }
96 } 96 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 body->Add(result_statement, info->zone()); 243 body->Add(result_statement, info->zone());
244 } 244 }
245 } 245 }
246 246
247 return true; 247 return true;
248 } 248 }
249 249
250 250
251 } // namespace internal 251 } // namespace internal
252 } // namespace v8 252 } // namespace v8
OLDNEW
« no previous file with comments | « src/prettyprinter.cc ('k') | test/mjsunit/es6/block-for.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698