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

Side by Side Diff: src/compiler/ast-loop-assignment-analyzer.cc

Issue 1309813007: [es6] implement destructuring assignment (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove facilities for rewriting the expression multiple ways Created 5 years 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/ast-loop-assignment-analyzer.h" 5 #include "src/compiler/ast-loop-assignment-analyzer.h"
6 #include "src/compiler.h" 6 #include "src/compiler.h"
7 #include "src/parsing/parser.h" 7 #include "src/parsing/parser.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 } 281 }
282 282
283 283
284 void ALAA::VisitCountOperation(CountOperation* e) { 284 void ALAA::VisitCountOperation(CountOperation* e) {
285 Expression* l = e->expression(); 285 Expression* l = e->expression();
286 Visit(l); 286 Visit(l);
287 if (l->IsVariableProxy()) AnalyzeAssignment(l->AsVariableProxy()->var()); 287 if (l->IsVariableProxy()) AnalyzeAssignment(l->AsVariableProxy()->var());
288 } 288 }
289 289
290 290
291 void ALAA::VisitRewritableExpression(RewritableExpression* expr) {
292 Visit(expr->expression());
293 }
294
295
291 void ALAA::AnalyzeAssignment(Variable* var) { 296 void ALAA::AnalyzeAssignment(Variable* var) {
292 if (!loop_stack_.empty() && var->IsStackAllocated()) { 297 if (!loop_stack_.empty() && var->IsStackAllocated()) {
293 loop_stack_.back()->Add(GetVariableIndex(info()->scope(), var)); 298 loop_stack_.back()->Add(GetVariableIndex(info()->scope(), var));
294 } 299 }
295 } 300 }
296 301
297 302
298 int ALAA::GetVariableIndex(Scope* scope, Variable* var) { 303 int ALAA::GetVariableIndex(Scope* scope, Variable* var) {
299 CHECK(var->IsStackAllocated()); 304 CHECK(var->IsStackAllocated());
300 if (var->is_this()) return 0; 305 if (var->is_this()) return 0;
301 if (var->IsParameter()) return 1 + var->index(); 306 if (var->IsParameter()) return 1 + var->index();
302 return 1 + scope->num_parameters() + var->index(); 307 return 1 + scope->num_parameters() + var->index();
303 } 308 }
304 309
305 310
306 int LoopAssignmentAnalysis::GetAssignmentCountForTesting(Scope* scope, 311 int LoopAssignmentAnalysis::GetAssignmentCountForTesting(Scope* scope,
307 Variable* var) { 312 Variable* var) {
308 int count = 0; 313 int count = 0;
309 int var_index = AstLoopAssignmentAnalyzer::GetVariableIndex(scope, var); 314 int var_index = AstLoopAssignmentAnalyzer::GetVariableIndex(scope, var);
310 for (size_t i = 0; i < list_.size(); i++) { 315 for (size_t i = 0; i < list_.size(); i++) {
311 if (list_[i].second->Contains(var_index)) count++; 316 if (list_[i].second->Contains(var_index)) count++;
312 } 317 }
313 return count; 318 return count;
314 } 319 }
315 } // namespace compiler 320 } // namespace compiler
316 } // namespace internal 321 } // namespace internal
317 } // namespace v8 322 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698