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

Side by Side Diff: pkg/compiler/lib/src/kernel/kernel_backend_strategy.dart

Issue 2956883002: Handle continue and break in for-in and while loops (Closed)
Patch Set: Updated cf. comments Created 3 years, 5 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 | « no previous file | tests/compiler/dart2js/kernel/compile_from_dill_test.dart » ('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 (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 dart2js.kernel.backend_strategy; 5 library dart2js.kernel.backend_strategy;
6 6
7 import 'package:kernel/ast.dart' as ir; 7 import 'package:kernel/ast.dart' as ir;
8 8
9 import '../backend_strategy.dart'; 9 import '../backend_strategy.dart';
10 import '../closure.dart'; 10 import '../closure.dart';
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 364
365 @override 365 @override
366 JumpTarget getJumpTargetForFor(ir.ForStatement node) { 366 JumpTarget getJumpTargetForFor(ir.ForStatement node) {
367 _ensureJumpMap(node); 367 _ensureJumpMap(node);
368 return _jumpTargetMap[node]; 368 return _jumpTargetMap[node];
369 } 369 }
370 370
371 @override 371 @override
372 JumpTarget getJumpTargetForForIn(ir.ForInStatement node) { 372 JumpTarget getJumpTargetForForIn(ir.ForInStatement node) {
373 _ensureJumpMap(node); 373 _ensureJumpMap(node);
374 return _jumpTargetMap[node.parent]; 374 return _jumpTargetMap[node];
375 } 375 }
376 376
377 @override 377 @override
378 JumpTarget getJumpTargetForWhile(ir.WhileStatement node) { 378 JumpTarget getJumpTargetForWhile(ir.WhileStatement node) {
379 _ensureJumpMap(node); 379 _ensureJumpMap(node);
380 return _jumpTargetMap[node.parent]; 380 return _jumpTargetMap[node];
381 } 381 }
382 382
383 @override 383 @override
384 Local getLocal(ir.VariableDeclaration node) { 384 Local getLocal(ir.VariableDeclaration node) {
385 return _map.putIfAbsent(node, () { 385 return _map.putIfAbsent(node, () {
386 return new KLocal(node.name, currentMember); 386 return new KLocal(node.name, currentMember);
387 }); 387 });
388 } 388 }
389 389
390 @override 390 @override
(...skipping 16 matching lines...) Expand all
407 return jumpTargetMap.putIfAbsent(node, () { 407 return jumpTargetMap.putIfAbsent(node, () {
408 return new KJumpTarget(member, index++); 408 return new KJumpTarget(member, index++);
409 }); 409 });
410 } 410 }
411 411
412 @override 412 @override
413 defaultNode(ir.Node node) => node.visitChildren(this); 413 defaultNode(ir.Node node) => node.visitChildren(this);
414 414
415 bool _canBeBreakTarget(ir.TreeNode node) { 415 bool _canBeBreakTarget(ir.TreeNode node) {
416 // TODO(johnniwinther): Add more. 416 // TODO(johnniwinther): Add more.
417 return node is ir.ForStatement; 417 return node is ir.ForStatement ||
418 node is ir.ForInStatement ||
419 node is ir.WhileStatement;
418 } 420 }
419 421
420 bool _canBeContinueTarget(ir.TreeNode node) { 422 bool _canBeContinueTarget(ir.TreeNode node) {
421 // TODO(johnniwinther): Add more. 423 // TODO(johnniwinther): Add more.
422 return node is ir.ForStatement; 424 return node is ir.ForStatement ||
425 node is ir.ForInStatement ||
426 node is ir.WhileStatement;
423 } 427 }
424 428
425 @override 429 @override
426 visitBreakStatement(ir.BreakStatement node) { 430 visitBreakStatement(ir.BreakStatement node) {
427 // TODO(johnniwinther): Add labels if the enclosing loop is not the implicit 431 // TODO(johnniwinther): Add labels if the enclosing loop is not the implicit
428 // break target. 432 // break target.
429 KJumpTarget target; 433 KJumpTarget target;
430 ir.TreeNode body = node.target.body; 434 ir.TreeNode body = node.target.body;
431 ir.TreeNode parent = node.target.parent; 435 ir.TreeNode parent = node.target.parent;
432 if (_canBeBreakTarget(body)) { 436 if (_canBeBreakTarget(body)) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { 572 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) {
569 return classes.toList() 573 return classes.toList()
570 ..sort((ClassEntity a, ClassEntity b) { 574 ..sort((ClassEntity a, ClassEntity b) {
571 int r = _compareLibraries(a.library, b.library); 575 int r = _compareLibraries(a.library, b.library);
572 if (r != 0) return r; 576 if (r != 0) return r;
573 return _compareNodes( 577 return _compareNodes(
574 a, elementMap.getClassNode(a), b, elementMap.getClassNode(b)); 578 a, elementMap.getClassNode(a), b, elementMap.getClassNode(b));
575 }); 579 });
576 } 580 }
577 } 581 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/kernel/compile_from_dill_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698