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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 return false; | 855 return false; |
856 } | 856 } |
857 | 857 |
858 Expression makeCondition(Expression e, bool polarity) { | 858 Expression makeCondition(Expression e, bool polarity) { |
859 return polarity ? e : new Not(e); | 859 return polarity ? e : new Not(e); |
860 } | 860 } |
861 | 861 |
862 Statement getBranch(If node, bool polarity) { | 862 Statement getBranch(If node, bool polarity) { |
863 return polarity ? node.thenStatement : node.elseStatement; | 863 return polarity ? node.thenStatement : node.elseStatement; |
864 } | 864 } |
| 865 |
| 866 @override |
| 867 Expression visitForeignExpression(ForeignExpression node) { |
| 868 _rewriteList(node.arguments); |
| 869 return node; |
| 870 } |
| 871 |
| 872 @override |
| 873 Statement visitForeignStatement(ForeignStatement node) { |
| 874 _rewriteList(node.arguments); |
| 875 return node; |
| 876 } |
865 } | 877 } |
866 | 878 |
867 /// Result of combining two expressions, with the potential for reverting the | 879 /// Result of combining two expressions, with the potential for reverting the |
868 /// combination. | 880 /// combination. |
869 /// | 881 /// |
870 /// Reverting a combination is done by calling [uncombine]. In this case, | 882 /// Reverting a combination is done by calling [uncombine]. In this case, |
871 /// both the original expressions should remain in the tree, and the [combined] | 883 /// both the original expressions should remain in the tree, and the [combined] |
872 /// expression should be orphaned. | 884 /// expression should be orphaned. |
873 /// | 885 /// |
874 /// Explicitly reverting a combination is necessary to maintain variable | 886 /// Explicitly reverting a combination is necessary to maintain variable |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 } | 928 } |
917 | 929 |
918 /// Result of combining two expressions that do not affect reference counting. | 930 /// Result of combining two expressions that do not affect reference counting. |
919 class GenericCombinedExpressions implements CombinedExpressions { | 931 class GenericCombinedExpressions implements CombinedExpressions { |
920 Expression combined; | 932 Expression combined; |
921 | 933 |
922 GenericCombinedExpressions(this.combined); | 934 GenericCombinedExpressions(this.combined); |
923 | 935 |
924 void uncombine() {} | 936 void uncombine() {} |
925 } | 937 } |
OLD | NEW |