| 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 logical expressions to be more compact in the Tree IR. | 7 /// Rewrites logical expressions to be more compact in the Tree IR. |
| 8 /// | 8 /// |
| 9 /// In this class an expression is said to occur in "boolean context" if | 9 /// In this class an expression is said to occur in "boolean context" if |
| 10 /// its result is immediately applied to boolean conversion. | 10 /// its result is immediately applied to boolean conversion. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 /// Statement to be executed next by natural fallthrough. Although fallthrough | 59 /// Statement to be executed next by natural fallthrough. Although fallthrough |
| 60 /// is not introduced in this phase, we need to reason about fallthrough when | 60 /// is not introduced in this phase, we need to reason about fallthrough when |
| 61 /// evaluating the benefit of swapping the branches of an [If]. | 61 /// evaluating the benefit of swapping the branches of an [If]. |
| 62 Statement fallthrough; | 62 Statement fallthrough; |
| 63 | 63 |
| 64 void rewriteExecutableDefinition(ExecutableDefinition root) { | 64 void rewriteExecutableDefinition(ExecutableDefinition root) { |
| 65 root.body = visitStatement(root.body); | 65 root.body = visitStatement(root.body); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void rewriteConstructorDefinition(ConstructorDefinition root) { |
| 69 if (root.isAbstract) return; |
| 70 List<Initializer> initializers = root.initializers; |
| 71 for (int i = 0; i < initializers.length; ++i) { |
| 72 initializers[i] = visitExpression(initializers[i]); |
| 73 } |
| 74 root.body = visitStatement(root.body); |
| 75 } |
| 76 |
| 77 Expression visitFieldInitializer(FieldInitializer node) { |
| 78 node.body = visitStatement(node.body); |
| 79 return node; |
| 80 } |
| 81 |
| 82 visitSuperInitializer(SuperInitializer node) { |
| 83 List<Statement> arguments = node.arguments; |
| 84 for (int i = 0; i < arguments.length; ++i) { |
| 85 arguments[i] = visitStatement(arguments[i]); |
| 86 } |
| 87 return node; |
| 88 } |
| 89 |
| 68 Statement visitLabeledStatement(LabeledStatement node) { | 90 Statement visitLabeledStatement(LabeledStatement node) { |
| 69 Statement savedFallthrough = fallthrough; | 91 Statement savedFallthrough = fallthrough; |
| 70 fallthrough = node.next; | 92 fallthrough = node.next; |
| 71 node.body = visitStatement(node.body); | 93 node.body = visitStatement(node.body); |
| 72 fallthrough = savedFallthrough; | 94 fallthrough = savedFallthrough; |
| 73 node.next = visitStatement(node.next); | 95 node.next = visitStatement(node.next); |
| 74 return node; | 96 return node; |
| 75 } | 97 } |
| 76 | 98 |
| 77 Statement visitAssign(Assign node) { | 99 Statement visitAssign(Assign node) { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 } | 461 } |
| 440 | 462 |
| 441 /// Destructively updates each entry of [l] with the result of visiting it. | 463 /// Destructively updates each entry of [l] with the result of visiting it. |
| 442 void _rewriteList(List<Expression> l) { | 464 void _rewriteList(List<Expression> l) { |
| 443 for (int i = 0; i < l.length; i++) { | 465 for (int i = 0; i < l.length; i++) { |
| 444 l[i] = visitExpression(l[i]); | 466 l[i] = visitExpression(l[i]); |
| 445 } | 467 } |
| 446 } | 468 } |
| 447 } | 469 } |
| 448 | 470 |
| OLD | NEW |