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: sdk/lib/_internal/compiler/implementation/ssa/nodes.dart

Issue 14969004: Implement continue for switch. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comment updated. Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of ssa; 5 part of ssa;
6 6
7 abstract class HVisitor<R> { 7 abstract class HVisitor<R> {
8 R visitAdd(HAdd node); 8 R visitAdd(HAdd node);
9 R visitBailoutTarget(HBailoutTarget node); 9 R visitBailoutTarget(HBailoutTarget node);
10 R visitBitAnd(HBitAnd node); 10 R visitBitAnd(HBitAnd node);
(...skipping 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 int typeCode() => HInstruction.NEGATE_TYPECODE; 1666 int typeCode() => HInstruction.NEGATE_TYPECODE;
1667 bool typeEquals(other) => other is HNegate; 1667 bool typeEquals(other) => other is HNegate;
1668 bool dataEquals(HInstruction other) => true; 1668 bool dataEquals(HInstruction other) => true;
1669 } 1669 }
1670 1670
1671 class HBitNot extends HInvokeUnary { 1671 class HBitNot extends HInvokeUnary {
1672 HBitNot(input, selector) : super(input, selector) { 1672 HBitNot(input, selector) : super(input, selector) {
1673 instructionType = HType.INTEGER; 1673 instructionType = HType.INTEGER;
1674 } 1674 }
1675 accept(HVisitor visitor) => visitor.visitBitNot(this); 1675 accept(HVisitor visitor) => visitor.visitBitNot(this);
1676 1676
1677 UnaryOperation operation(ConstantSystem constantSystem) 1677 UnaryOperation operation(ConstantSystem constantSystem)
1678 => constantSystem.bitNot; 1678 => constantSystem.bitNot;
1679 int typeCode() => HInstruction.BIT_NOT_TYPECODE; 1679 int typeCode() => HInstruction.BIT_NOT_TYPECODE;
1680 bool typeEquals(other) => other is HBitNot; 1680 bool typeEquals(other) => other is HBitNot;
1681 bool dataEquals(HInstruction other) => true; 1681 bool dataEquals(HInstruction other) => true;
1682 } 1682 }
1683 1683
1684 class HExit extends HControlFlow { 1684 class HExit extends HControlFlow {
1685 HExit() : super(const <HInstruction>[]); 1685 HExit() : super(const <HInstruction>[]);
1686 toString() => 'exit'; 1686 toString() => 'exit';
1687 accept(HVisitor visitor) => visitor.visitExit(this); 1687 accept(HVisitor visitor) => visitor.visitExit(this);
1688 } 1688 }
1689 1689
1690 class HGoto extends HControlFlow { 1690 class HGoto extends HControlFlow {
1691 HGoto() : super(const <HInstruction>[]); 1691 HGoto() : super(const <HInstruction>[]);
1692 toString() => 'goto'; 1692 toString() => 'goto';
1693 accept(HVisitor visitor) => visitor.visitGoto(this); 1693 accept(HVisitor visitor) => visitor.visitGoto(this);
1694 } 1694 }
1695 1695
1696 abstract class HJump extends HControlFlow { 1696 abstract class HJump extends HControlFlow {
1697 final TargetElement target; 1697 final TargetElement target;
1698 final LabelElement label; 1698 final LabelElement label;
1699 HJump(this.target) : label = null, super(const <HInstruction>[]); 1699 HJump(this.target) : label = null, super(const <HInstruction>[]);
1700 HJump.toLabel(LabelElement label) 1700 HJump.toLabel(LabelElement label)
1701 : label = label, target = label.target, super(const <HInstruction>[]); 1701 : label = label, target = label.target, super(const <HInstruction>[]);
1702 } 1702 }
1703 1703
1704 class HBreak extends HJump { 1704 class HBreak extends HJump {
1705 HBreak(TargetElement target) : super(target); 1705 /**
1706 HBreak.toLabel(LabelElement label) : super.toLabel(label); 1706 * Signals that this is a special break instruction for the synthetic loop
1707 * generatedfor a switch statement with continue statements. See
1708 * [SsaBuilder.buildComplexSwitchStatement] for detail.
1709 */
1710 final bool breakSwitchContinueLoop;
1711 HBreak(TargetElement target, {bool this.breakSwitchContinueLoop: false})
1712 : super(target);
1713 HBreak.toLabel(LabelElement label)
1714 : breakSwitchContinueLoop = false, super.toLabel(label);
1707 toString() => (label != null) ? 'break ${label.labelName}' : 'break'; 1715 toString() => (label != null) ? 'break ${label.labelName}' : 'break';
1708 accept(HVisitor visitor) => visitor.visitBreak(this); 1716 accept(HVisitor visitor) => visitor.visitBreak(this);
1709 } 1717 }
1710 1718
1711 class HContinue extends HJump { 1719 class HContinue extends HJump {
1712 HContinue(TargetElement target) : super(target); 1720 HContinue(TargetElement target) : super(target);
1713 HContinue.toLabel(LabelElement label) : super.toLabel(label); 1721 HContinue.toLabel(LabelElement label) : super.toLabel(label);
1714 toString() => (label != null) ? 'continue ${label.labelName}' : 'continue'; 1722 toString() => (label != null) ? 'continue ${label.labelName}' : 'continue';
1715 accept(HVisitor visitor) => visitor.visitContinue(this); 1723 accept(HVisitor visitor) => visitor.visitContinue(this);
1716 } 1724 }
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
2461 visitor.visitLabeledBlockInfo(this); 2469 visitor.visitLabeledBlockInfo(this);
2462 } 2470 }
2463 2471
2464 class LoopTypeVisitor extends Visitor { 2472 class LoopTypeVisitor extends Visitor {
2465 const LoopTypeVisitor(); 2473 const LoopTypeVisitor();
2466 int visitNode(Node node) => HLoopBlockInformation.NOT_A_LOOP; 2474 int visitNode(Node node) => HLoopBlockInformation.NOT_A_LOOP;
2467 int visitWhile(While node) => HLoopBlockInformation.WHILE_LOOP; 2475 int visitWhile(While node) => HLoopBlockInformation.WHILE_LOOP;
2468 int visitFor(For node) => HLoopBlockInformation.FOR_LOOP; 2476 int visitFor(For node) => HLoopBlockInformation.FOR_LOOP;
2469 int visitDoWhile(DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; 2477 int visitDoWhile(DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP;
2470 int visitForIn(ForIn node) => HLoopBlockInformation.FOR_IN_LOOP; 2478 int visitForIn(ForIn node) => HLoopBlockInformation.FOR_IN_LOOP;
2479 int visitSwitchStatement(SwitchStatement node) =>
2480 HLoopBlockInformation.SWITCH_CONTINUE_LOOP;
2471 } 2481 }
2472 2482
2473 class HLoopBlockInformation implements HStatementInformation { 2483 class HLoopBlockInformation implements HStatementInformation {
2474 static const int WHILE_LOOP = 0; 2484 static const int WHILE_LOOP = 0;
2475 static const int FOR_LOOP = 1; 2485 static const int FOR_LOOP = 1;
2476 static const int DO_WHILE_LOOP = 2; 2486 static const int DO_WHILE_LOOP = 2;
2477 static const int FOR_IN_LOOP = 3; 2487 static const int FOR_IN_LOOP = 3;
2488 static const int SWITCH_CONTINUE_LOOP = 4;
2478 static const int NOT_A_LOOP = -1; 2489 static const int NOT_A_LOOP = -1;
2479 2490
2480 final int kind; 2491 final int kind;
2481 final HExpressionInformation initializer; 2492 final HExpressionInformation initializer;
2482 final HExpressionInformation condition; 2493 final HExpressionInformation condition;
2483 final HStatementInformation body; 2494 final HStatementInformation body;
2484 final HExpressionInformation updates; 2495 final HExpressionInformation updates;
2485 final TargetElement target; 2496 final TargetElement target;
2486 final List<LabelElement> labels; 2497 final List<LabelElement> labels;
2487 final SourceFileLocation sourcePosition; 2498 final SourceFileLocation sourcePosition;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2604 HBasicBlock get start => expression.start; 2615 HBasicBlock get start => expression.start;
2605 HBasicBlock get end { 2616 HBasicBlock get end {
2606 // We don't create a switch block if there are no cases. 2617 // We don't create a switch block if there are no cases.
2607 assert(!statements.isEmpty); 2618 assert(!statements.isEmpty);
2608 return statements.last.end; 2619 return statements.last.end;
2609 } 2620 }
2610 2621
2611 bool accept(HStatementInformationVisitor visitor) => 2622 bool accept(HStatementInformationVisitor visitor) =>
2612 visitor.visitSwitchInfo(this); 2623 visitor.visitSwitchInfo(this);
2613 } 2624 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/codegen.dart ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698