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 library tree_ir.optimization.statement_rewriter; | 5 library tree_ir.optimization.statement_rewriter; |
6 | 6 |
7 import 'optimization.dart' show Pass; | 7 import 'optimization.dart' show Pass; |
8 import '../tree_ir_nodes.dart'; | 8 import '../tree_ir_nodes.dart'; |
9 | 9 |
10 /** | 10 /** |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 return false; | 945 return false; |
946 } | 946 } |
947 | 947 |
948 Expression makeCondition(Expression e, bool polarity) { | 948 Expression makeCondition(Expression e, bool polarity) { |
949 return polarity ? e : new Not(e); | 949 return polarity ? e : new Not(e); |
950 } | 950 } |
951 | 951 |
952 Statement getBranch(If node, bool polarity) { | 952 Statement getBranch(If node, bool polarity) { |
953 return polarity ? node.thenStatement : node.elseStatement; | 953 return polarity ? node.thenStatement : node.elseStatement; |
954 } | 954 } |
| 955 |
| 956 @override |
| 957 Expression visitForeignExpression(ForeignExpression node) { |
| 958 _rewriteList(node.arguments); |
| 959 return node; |
| 960 } |
| 961 |
| 962 @override |
| 963 Statement visitForeignStatement(ForeignStatement node) { |
| 964 _rewriteList(node.arguments); |
| 965 return node; |
| 966 } |
955 } | 967 } |
956 | 968 |
957 /// Result of combining two expressions, with the potential for reverting the | 969 /// Result of combining two expressions, with the potential for reverting the |
958 /// combination. | 970 /// combination. |
959 /// | 971 /// |
960 /// Reverting a combination is done by calling [uncombine]. In this case, | 972 /// Reverting a combination is done by calling [uncombine]. In this case, |
961 /// both the original expressions should remain in the tree, and the [combined] | 973 /// both the original expressions should remain in the tree, and the [combined] |
962 /// expression should be orphaned. | 974 /// expression should be orphaned. |
963 /// | 975 /// |
964 /// Explicitly reverting a combination is necessary to maintain variable | 976 /// Explicitly reverting a combination is necessary to maintain variable |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 IsVariableUsedVisitor(this.variable); | 1038 IsVariableUsedVisitor(this.variable); |
1027 | 1039 |
1028 visitVariableUse(VariableUse node) { | 1040 visitVariableUse(VariableUse node) { |
1029 if (node.variable == variable) { | 1041 if (node.variable == variable) { |
1030 wasFound = true; | 1042 wasFound = true; |
1031 } | 1043 } |
1032 } | 1044 } |
1033 | 1045 |
1034 visitInnerFunction(FunctionDefinition node) {} | 1046 visitInnerFunction(FunctionDefinition node) {} |
1035 } | 1047 } |
OLD | NEW |