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

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

Issue 1968753004: [cleanup] Split ForOf and ForIn AST nodes apart as they share little (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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/crankshaft/typing.cc ('k') | no next file » | 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/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 3094 matching lines...) Expand 10 before | Expand all | Expand 10 after
3105 scope_); 3105 scope_);
3106 auto block = 3106 auto block =
3107 factory()->NewBlock(nullptr, 2, false, RelocInfo::kNoPosition); 3107 factory()->NewBlock(nullptr, 2, false, RelocInfo::kNoPosition);
3108 block->statements()->Add(factory()->NewExpressionStatement( 3108 block->statements()->Add(factory()->NewExpressionStatement(
3109 assign_each, RelocInfo::kNoPosition), 3109 assign_each, RelocInfo::kNoPosition),
3110 zone()); 3110 zone());
3111 block->statements()->Add(body, zone()); 3111 block->statements()->Add(body, zone());
3112 body = block; 3112 body = block;
3113 each = factory()->NewVariableProxy(temp); 3113 each = factory()->NewVariableProxy(temp);
3114 } 3114 }
3115 stmt->Initialize(each, subject, body); 3115 stmt->AsForInStatement()->Initialize(each, subject, body);
3116 } 3116 }
3117 } 3117 }
3118 3118
3119 void Parser::InitializeForOfStatement(ForOfStatement* for_of, Expression* each, 3119 void Parser::InitializeForOfStatement(ForOfStatement* for_of, Expression* each,
3120 Expression* iterable, Statement* body, 3120 Expression* iterable, Statement* body,
3121 int next_result_pos) { 3121 int next_result_pos) {
3122 Variable* iterator = 3122 Variable* iterator =
3123 scope_->NewTemporary(ast_value_factory()->dot_iterator_string()); 3123 scope_->NewTemporary(ast_value_factory()->dot_iterator_string());
3124 Variable* result = 3124 Variable* result =
3125 scope_->NewTemporary(ast_value_factory()->dot_result_string()); 3125 scope_->NewTemporary(ast_value_factory()->dot_result_string());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3162 Expression* result_value = factory()->NewProperty( 3162 Expression* result_value = factory()->NewProperty(
3163 result_proxy, value_literal, RelocInfo::kNoPosition); 3163 result_proxy, value_literal, RelocInfo::kNoPosition);
3164 assign_each = factory()->NewAssignment(Token::ASSIGN, each, result_value, 3164 assign_each = factory()->NewAssignment(Token::ASSIGN, each, result_value,
3165 RelocInfo::kNoPosition); 3165 RelocInfo::kNoPosition);
3166 if (each->IsArrayLiteral() || each->IsObjectLiteral()) { 3166 if (each->IsArrayLiteral() || each->IsObjectLiteral()) {
3167 assign_each = PatternRewriter::RewriteDestructuringAssignment( 3167 assign_each = PatternRewriter::RewriteDestructuringAssignment(
3168 this, assign_each->AsAssignment(), scope_); 3168 this, assign_each->AsAssignment(), scope_);
3169 } 3169 }
3170 } 3170 }
3171 3171
3172 for_of->Initialize(each, iterable, body, iterator, assign_iterator, 3172 for_of->Initialize(body, iterator, assign_iterator, next_result, result_done,
3173 next_result, result_done, assign_each); 3173 assign_each);
3174 } 3174 }
3175 3175
3176 Statement* Parser::DesugarLexicalBindingsInForStatement( 3176 Statement* Parser::DesugarLexicalBindingsInForStatement(
3177 Scope* inner_scope, VariableMode mode, ZoneList<const AstRawString*>* names, 3177 Scope* inner_scope, VariableMode mode, ZoneList<const AstRawString*>* names,
3178 ForStatement* loop, Statement* init, Expression* cond, Statement* next, 3178 ForStatement* loop, Statement* init, Expression* cond, Statement* next,
3179 Statement* body, bool* ok) { 3179 Statement* body, bool* ok) {
3180 // ES6 13.7.4.8 specifies that on each loop iteration the let variables are 3180 // ES6 13.7.4.8 specifies that on each loop iteration the let variables are
3181 // copied into a new environment. Moreover, the "next" statement must be 3181 // copied into a new environment. Moreover, the "next" statement must be
3182 // evaluated not in the environment of the just completed iteration but in 3182 // evaluated not in the environment of the just completed iteration but in
3183 // that of the upcoming one. We achieve this with the following desugaring. 3183 // that of the upcoming one. We achieve this with the following desugaring.
(...skipping 3632 matching lines...) Expand 10 before | Expand all | Expand 10 after
6816 try_block, target); 6816 try_block, target);
6817 final_loop = target; 6817 final_loop = target;
6818 } 6818 }
6819 6819
6820 return final_loop; 6820 return final_loop;
6821 } 6821 }
6822 6822
6823 6823
6824 } // namespace internal 6824 } // namespace internal
6825 } // namespace v8 6825 } // namespace v8
OLDNEW
« no previous file with comments | « src/crankshaft/typing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698