OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class HValidator extends HInstructionVisitor { | 5 class HValidator extends HInstructionVisitor { |
6 bool isValid = true; | 6 bool isValid = true; |
7 HGraph graph; | 7 HGraph graph; |
8 | 8 |
9 void visitGraph(HGraph visitee) { | 9 void visitGraph(HGraph visitee) { |
10 graph = visitee; | 10 graph = visitee; |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 if (block.last is HIf && block.successors.length != 2) { | 33 if (block.last is HIf && block.successors.length != 2) { |
34 markInvalid("If node without two successors"); | 34 markInvalid("If node without two successors"); |
35 } | 35 } |
36 if (block.last is HConditionalBranch && block.successors.length != 2) { | 36 if (block.last is HConditionalBranch && block.successors.length != 2) { |
37 markInvalid("Conditional node without two successors"); | 37 markInvalid("Conditional node without two successors"); |
38 } | 38 } |
39 if (block.last is HGoto && block.successors.length != 1) { | 39 if (block.last is HGoto && block.successors.length != 1) { |
40 markInvalid("Goto node without one successor"); | 40 markInvalid("Goto node without one successor"); |
41 } | 41 } |
| 42 if (block.last is HJump && block.successors.length != 1) { |
| 43 markInvalid("Break or continue node without one successor"); |
| 44 } |
42 if (block.last is HReturn && | 45 if (block.last is HReturn && |
43 (block.successors.length != 1 || !block.successors[0].isExitBlock())) { | 46 (block.successors.length != 1 || !block.successors[0].isExitBlock())) { |
44 markInvalid("Return node with > 1 succesor or not going to exit-block"); | 47 markInvalid("Return node with > 1 succesor or not going to exit-block"); |
45 } | 48 } |
46 if (block.last is HExit && !block.successors.isEmpty()) { | 49 if (block.last is HExit && !block.successors.isEmpty()) { |
47 markInvalid("Exit block with successor"); | 50 markInvalid("Exit block with successor"); |
48 } | 51 } |
49 if (block.last is HThrow && !block.successors.isEmpty()) { | 52 if (block.last is HThrow && !block.successors.isEmpty()) { |
50 markInvalid("Throw block with successor"); | 53 markInvalid("Throw block with successor"); |
51 } | 54 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 markInvalid("Instruction in wrong block"); | 170 markInvalid("Instruction in wrong block"); |
168 } | 171 } |
169 if (!hasCorrectInputs()) { | 172 if (!hasCorrectInputs()) { |
170 markInvalid("Incorrect inputs"); | 173 markInvalid("Incorrect inputs"); |
171 } | 174 } |
172 if (!hasCorrectUses()) { | 175 if (!hasCorrectUses()) { |
173 markInvalid("Incorrect uses"); | 176 markInvalid("Incorrect uses"); |
174 } | 177 } |
175 } | 178 } |
176 } | 179 } |
OLD | NEW |