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 } | |
967 } | 955 } |
968 | 956 |
969 /// Result of combining two expressions, with the potential for reverting the | 957 /// Result of combining two expressions, with the potential for reverting the |
970 /// combination. | 958 /// combination. |
971 /// | 959 /// |
972 /// Reverting a combination is done by calling [uncombine]. In this case, | 960 /// Reverting a combination is done by calling [uncombine]. In this case, |
973 /// both the original expressions should remain in the tree, and the [combined] | 961 /// both the original expressions should remain in the tree, and the [combined] |
974 /// expression should be orphaned. | 962 /// expression should be orphaned. |
975 /// | 963 /// |
976 /// Explicitly reverting a combination is necessary to maintain variable | 964 /// Explicitly reverting a combination is necessary to maintain variable |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 IsVariableUsedVisitor(this.variable); | 1026 IsVariableUsedVisitor(this.variable); |
1039 | 1027 |
1040 visitVariableUse(VariableUse node) { | 1028 visitVariableUse(VariableUse node) { |
1041 if (node.variable == variable) { | 1029 if (node.variable == variable) { |
1042 wasFound = true; | 1030 wasFound = true; |
1043 } | 1031 } |
1044 } | 1032 } |
1045 | 1033 |
1046 visitInnerFunction(FunctionDefinition node) {} | 1034 visitInnerFunction(FunctionDefinition node) {} |
1047 } | 1035 } |
OLD | NEW |