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

Side by Side Diff: pkg/analyzer2dart/lib/src/cps_generator.dart

Issue 846353002: Dart2dart: Support for-loop variables captured in loop body. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer2dart.cps_generator; 5 library analyzer2dart.cps_generator;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 8
9 import 'package:compiler/src/dart_types.dart' as dart2js; 9 import 'package:compiler/src/dart_types.dart' as dart2js;
10 import 'package:compiler/src/elements/elements.dart' as dart2js; 10 import 'package:compiler/src/elements/elements.dart' as dart2js;
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 return irBuilder.buildMapLiteral( 436 return irBuilder.buildMapLiteral(
437 type, 437 type,
438 node.entries.map((e) => e.key), 438 node.entries.map((e) => e.key),
439 node.entries.map((e) => e.value), 439 node.entries.map((e) => e.value),
440 build); 440 build);
441 } 441 }
442 442
443 @override 443 @override
444 visitForStatement(ForStatement node) { 444 visitForStatement(ForStatement node) {
445 // TODO(johnniwinther): Support `for` as a jump target. 445 // TODO(johnniwinther): Support `for` as a jump target.
446 List<dart2js.LocalElement> loopVariables = <dart2js.LocalElement>[];
446 SubbuildFunction buildInitializer; 447 SubbuildFunction buildInitializer;
447 if (node.variables != null) { 448 if (node.variables != null) {
448 buildInitializer = subbuild(node.variables); 449 buildInitializer = subbuild(node.variables);
450 for (VariableDeclaration variable in node.variables.variables) {
451 loopVariables.add(converter.convertElement(variable.element));
452 }
449 } else { 453 } else {
450 buildInitializer = subbuild(node.initialization); 454 buildInitializer = subbuild(node.initialization);
451 } 455 }
452 irBuilder.buildFor(buildInitializer: buildInitializer, 456 irBuilder.buildFor(buildInitializer: buildInitializer,
453 buildCondition: subbuild(node.condition), 457 buildCondition: subbuild(node.condition),
454 buildBody: subbuild(node.body), 458 buildBody: subbuild(node.body),
455 buildUpdate: subbuildSequence(node.updaters)); 459 buildUpdate: subbuildSequence(node.updaters),
460 loopVariables: loopVariables);
456 } 461 }
457 462
458 @override 463 @override
459 visitWhileStatement(WhileStatement node) { 464 visitWhileStatement(WhileStatement node) {
460 // TODO(johnniwinther): Support `while` as a jump target. 465 // TODO(johnniwinther): Support `while` as a jump target.
461 irBuilder.buildWhile(buildCondition: subbuild(node.condition), 466 irBuilder.buildWhile(buildCondition: subbuild(node.condition),
462 buildBody: subbuild(node.body)); 467 buildBody: subbuild(node.body));
463 } 468 }
464 469
465 @override 470 @override
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 return irBuilder.buildTypeOperator( 521 return irBuilder.buildTypeOperator(
517 visit(node.expression), 522 visit(node.expression),
518 converter.convertType(node.type.type), 523 converter.convertType(node.type.type),
519 isTypeTest: false); 524 isTypeTest: false);
520 } 525 }
521 } 526 }
522 527
523 class NullClosureVariableInfo extends ClosureVariableInfo { 528 class NullClosureVariableInfo extends ClosureVariableInfo {
524 Iterable get capturedVariables => const []; 529 Iterable get capturedVariables => const [];
525 } 530 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart » ('j') | pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698