| OLD | NEW |
| 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 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1850 | 1850 |
| 1851 final int kind; | 1851 final int kind; |
| 1852 HLoopBranch(HInstruction condition, [this.kind = CONDITION_FIRST_LOOP]) | 1852 HLoopBranch(HInstruction condition, [this.kind = CONDITION_FIRST_LOOP]) |
| 1853 : super(<HInstruction>[condition]); | 1853 : super(<HInstruction>[condition]); |
| 1854 toString() => 'loop-branch'; | 1854 toString() => 'loop-branch'; |
| 1855 accept(HVisitor visitor) => visitor.visitLoopBranch(this); | 1855 accept(HVisitor visitor) => visitor.visitLoopBranch(this); |
| 1856 | 1856 |
| 1857 bool isDoWhile() { | 1857 bool isDoWhile() { |
| 1858 return identical(kind, DO_WHILE_LOOP); | 1858 return identical(kind, DO_WHILE_LOOP); |
| 1859 } | 1859 } |
| 1860 |
| 1861 HBasicBlock get loopHeader { |
| 1862 HBasicBlock result = isDoWhile() |
| 1863 // In case of a do/while, the successor is a block that avoids |
| 1864 // a critical edge and branchs to the loop header. |
| 1865 ? block.successors[0].successors[0] |
| 1866 : block; |
| 1867 assert(result.isLoopHeader()); |
| 1868 return result; |
| 1869 } |
| 1860 } | 1870 } |
| 1861 | 1871 |
| 1862 class HConstant extends HInstruction { | 1872 class HConstant extends HInstruction { |
| 1863 final Constant constant; | 1873 final Constant constant; |
| 1864 final HType constantType; | 1874 final HType constantType; |
| 1865 HConstant.internal(this.constant, HType this.constantType) | 1875 HConstant.internal(this.constant, HType this.constantType) |
| 1866 : super(<HInstruction>[]); | 1876 : super(<HInstruction>[]); |
| 1867 | 1877 |
| 1868 toString() => 'literal: $constant'; | 1878 toString() => 'literal: $constant'; |
| 1869 accept(HVisitor visitor) => visitor.visitConstant(this); | 1879 accept(HVisitor visitor) => visitor.visitConstant(this); |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2611 if (kind == DO_WHILE_LOOP && condition != null) { | 2621 if (kind == DO_WHILE_LOOP && condition != null) { |
| 2612 return condition.end; | 2622 return condition.end; |
| 2613 } | 2623 } |
| 2614 return body.end; | 2624 return body.end; |
| 2615 } | 2625 } |
| 2616 | 2626 |
| 2617 static int loopType(Node node) { | 2627 static int loopType(Node node) { |
| 2618 return node.accept(const LoopTypeVisitor()); | 2628 return node.accept(const LoopTypeVisitor()); |
| 2619 } | 2629 } |
| 2620 | 2630 |
| 2631 bool isDoWhile() => kind == DO_WHILE_LOOP; |
| 2632 |
| 2621 bool accept(HStatementInformationVisitor visitor) => | 2633 bool accept(HStatementInformationVisitor visitor) => |
| 2622 visitor.visitLoopInfo(this); | 2634 visitor.visitLoopInfo(this); |
| 2623 } | 2635 } |
| 2624 | 2636 |
| 2625 class HIfBlockInformation implements HStatementInformation { | 2637 class HIfBlockInformation implements HStatementInformation { |
| 2626 final HExpressionInformation condition; | 2638 final HExpressionInformation condition; |
| 2627 final HStatementInformation thenGraph; | 2639 final HStatementInformation thenGraph; |
| 2628 final HStatementInformation elseGraph; | 2640 final HStatementInformation elseGraph; |
| 2629 HIfBlockInformation(this.condition, | 2641 HIfBlockInformation(this.condition, |
| 2630 this.thenGraph, | 2642 this.thenGraph, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2696 HBasicBlock get start => expression.start; | 2708 HBasicBlock get start => expression.start; |
| 2697 HBasicBlock get end { | 2709 HBasicBlock get end { |
| 2698 // We don't create a switch block if there are no cases. | 2710 // We don't create a switch block if there are no cases. |
| 2699 assert(!statements.isEmpty); | 2711 assert(!statements.isEmpty); |
| 2700 return statements.last.end; | 2712 return statements.last.end; |
| 2701 } | 2713 } |
| 2702 | 2714 |
| 2703 bool accept(HStatementInformationVisitor visitor) => | 2715 bool accept(HStatementInformationVisitor visitor) => |
| 2704 visitor.visitSwitchInfo(this); | 2716 visitor.visitSwitchInfo(this); |
| 2705 } | 2717 } |
| OLD | NEW |