| 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 /** | 7 /** |
| 8 * Performs the following transformations on the tree: | 8 * Performs the following transformations on the tree: |
| 9 * - Assignment propagation | 9 * - Assignment propagation |
| 10 * - If-to-conditional conversion | 10 * - If-to-conditional conversion |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 Expression visitReifyRuntimeType(ReifyRuntimeType node) { | 502 Expression visitReifyRuntimeType(ReifyRuntimeType node) { |
| 503 node.value = visitExpression(node.value); | 503 node.value = visitExpression(node.value); |
| 504 return node; | 504 return node; |
| 505 } | 505 } |
| 506 | 506 |
| 507 Expression visitReadTypeVariable(ReadTypeVariable node) { | 507 Expression visitReadTypeVariable(ReadTypeVariable node) { |
| 508 node.target = visitExpression(node.target); | 508 node.target = visitExpression(node.target); |
| 509 return node; | 509 return node; |
| 510 } | 510 } |
| 511 | 511 |
| 512 @override |
| 513 Expression visitTypeExpression(TypeExpression node) { |
| 514 for (int i = node.arguments.length - 1; i >= 0; --i) { |
| 515 node.arguments[i] = visitExpression(node.arguments[i]); |
| 516 } |
| 517 return node; |
| 518 } |
| 519 |
| 512 /// If [s] and [t] are similar statements we extract their subexpressions | 520 /// If [s] and [t] are similar statements we extract their subexpressions |
| 513 /// and returns a new statement of the same type using expressions combined | 521 /// and returns a new statement of the same type using expressions combined |
| 514 /// with the [combine] callback. For example: | 522 /// with the [combine] callback. For example: |
| 515 /// | 523 /// |
| 516 /// combineStatements(Return E1, Return E2) = Return combine(E1, E2) | 524 /// combineStatements(Return E1, Return E2) = Return combine(E1, E2) |
| 517 /// | 525 /// |
| 518 /// If [combine] returns E1 then the unified statement is equivalent to [s], | 526 /// If [combine] returns E1 then the unified statement is equivalent to [s], |
| 519 /// and if [combine] returns E2 the unified statement is equivalence to [t]. | 527 /// and if [combine] returns E2 the unified statement is equivalence to [t]. |
| 520 /// | 528 /// |
| 521 /// It is guaranteed that no side effects occur between the beginning of the | 529 /// It is guaranteed that no side effects occur between the beginning of the |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 } | 677 } |
| 670 | 678 |
| 671 Expression makeCondition(Expression e, bool polarity) { | 679 Expression makeCondition(Expression e, bool polarity) { |
| 672 return polarity ? e : new Not(e); | 680 return polarity ? e : new Not(e); |
| 673 } | 681 } |
| 674 | 682 |
| 675 Statement getBranch(If node, bool polarity) { | 683 Statement getBranch(If node, bool polarity) { |
| 676 return polarity ? node.thenStatement : node.elseStatement; | 684 return polarity ? node.thenStatement : node.elseStatement; |
| 677 } | 685 } |
| 678 } | 686 } |
| OLD | NEW |