| OLD | NEW |
| 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 part of tree_ir.optimization; | 5 part of tree_ir.optimization; |
| 6 | 6 |
| 7 /// Rewrites [WhileTrue] statements with an [If] body into a [WhileCondition], | 7 /// Rewrites [WhileTrue] statements with an [If] body into a [WhileCondition], |
| 8 /// in situations where only one of the branches contains a [Continue] to the | 8 /// in situations where only one of the branches contains a [Continue] to the |
| 9 /// loop. Schematically: | 9 /// loop. Schematically: |
| 10 /// | 10 /// |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 Statement visitLabeledStatement(LabeledStatement node) { | 38 Statement visitLabeledStatement(LabeledStatement node) { |
| 39 node.body = visitStatement(node.body); | 39 node.body = visitStatement(node.body); |
| 40 node.next = visitStatement(node.next); | 40 node.next = visitStatement(node.next); |
| 41 return node; | 41 return node; |
| 42 } | 42 } |
| 43 | 43 |
| 44 Statement visitAssign(Assign node) { | 44 Statement visitAssign(Assign node) { |
| 45 // Clean up redundant assignments left behind in the previous phase. | 45 // Clean up redundant assignments left behind in the previous phase. |
| 46 Expression def = node.definition; | 46 Expression value = node.value; |
| 47 if (def is VariableUse && node.variable == def.variable) { | 47 if (value is VariableUse && node.variable == value.variable) { |
| 48 --node.variable.readCount; | 48 --node.variable.readCount; |
| 49 --node.variable.writeCount; | 49 --node.variable.writeCount; |
| 50 return visitStatement(node.next); | 50 return visitStatement(node.next); |
| 51 } | 51 } |
| 52 visitExpression(node.definition); | 52 visitExpression(node.value); |
| 53 node.next = visitStatement(node.next); | 53 node.next = visitStatement(node.next); |
| 54 return node; | 54 return node; |
| 55 } | 55 } |
| 56 | 56 |
| 57 Statement visitReturn(Return node) { | 57 Statement visitReturn(Return node) { |
| 58 visitExpression(node.value); | 58 visitExpression(node.value); |
| 59 return node; | 59 return node; |
| 60 } | 60 } |
| 61 | 61 |
| 62 Statement visitBreak(Break node) { | 62 Statement visitBreak(Break node) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 136 } |
| 137 | 137 |
| 138 Statement visitSetField(SetField node) { | 138 Statement visitSetField(SetField node) { |
| 139 visitExpression(node.object); | 139 visitExpression(node.object); |
| 140 visitExpression(node.value); | 140 visitExpression(node.value); |
| 141 node.next = visitStatement(node.next); | 141 node.next = visitStatement(node.next); |
| 142 return node; | 142 return node; |
| 143 } | 143 } |
| 144 | 144 |
| 145 } | 145 } |
| OLD | NEW |