| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart2js.ir_builder_task; | 5 library dart2js.ir_builder_task; |
| 6 | 6 |
| 7 import '../closure.dart' as closurelib; | 7 import '../closure.dart' as closurelib; |
| 8 import '../closure.dart' hide ClosureScope; | 8 import '../closure.dart' hide ClosureScope; |
| 9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
| 10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
| (...skipping 2792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2803 /// Perform simple post-processing on the initial CPS-translated root term. | 2803 /// Perform simple post-processing on the initial CPS-translated root term. |
| 2804 /// | 2804 /// |
| 2805 /// This pass performs backend-independent post-processing on the translated | 2805 /// This pass performs backend-independent post-processing on the translated |
| 2806 /// term. It is implemented separately from the optimization passes because | 2806 /// term. It is implemented separately from the optimization passes because |
| 2807 /// it is required for correctness of the implementation. | 2807 /// it is required for correctness of the implementation. |
| 2808 /// | 2808 /// |
| 2809 /// It performs the following translations: | 2809 /// It performs the following translations: |
| 2810 /// - Replace [ir.LetPrim] binding a [ir.NonTailThrow] with a [ir.Throw] | 2810 /// - Replace [ir.LetPrim] binding a [ir.NonTailThrow] with a [ir.Throw] |
| 2811 /// expression. | 2811 /// expression. |
| 2812 class CleanupPass extends ir.RecursiveVisitor { | 2812 class CleanupPass extends ir.RecursiveVisitor { |
| 2813 RemovalVisitor _remover = new RemovalVisitor(); | |
| 2814 | |
| 2815 ir.Expression replacementFor(ir.Expression expression) { | 2813 ir.Expression replacementFor(ir.Expression expression) { |
| 2816 if (expression != null && expression is ir.LetPrim) { | 2814 if (expression != null && expression is ir.LetPrim) { |
| 2817 ir.Primitive primitive = expression.primitive; | 2815 ir.Primitive primitive = expression.primitive; |
| 2818 if (primitive is ir.NonTailThrow) { | 2816 if (primitive is ir.NonTailThrow) { |
| 2819 _remover.visit(expression); | 2817 ir.RemovalVisitor.remove(expression); |
| 2820 return new ir.Throw(primitive.value.definition); | 2818 return new ir.Throw(primitive.value.definition); |
| 2821 } | 2819 } |
| 2822 } | 2820 } |
| 2823 return expression; | 2821 return expression; |
| 2824 } | 2822 } |
| 2825 | 2823 |
| 2826 processFunctionDefinition(ir.FunctionDefinition node) { | 2824 processFunctionDefinition(ir.FunctionDefinition node) { |
| 2827 node.body = replacementFor(node.body); | 2825 node.body = replacementFor(node.body); |
| 2828 } | 2826 } |
| 2829 | 2827 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2852 } | 2850 } |
| 2853 | 2851 |
| 2854 processSetStatic(ir.SetStatic node) { | 2852 processSetStatic(ir.SetStatic node) { |
| 2855 node.body = replacementFor(node.body); | 2853 node.body = replacementFor(node.body); |
| 2856 } | 2854 } |
| 2857 | 2855 |
| 2858 processContinuation(ir.Continuation node) { | 2856 processContinuation(ir.Continuation node) { |
| 2859 node.body = replacementFor(node.body); | 2857 node.body = replacementFor(node.body); |
| 2860 } | 2858 } |
| 2861 } | 2859 } |
| 2862 | |
| 2863 /// Visit a just-deleted subterm and unlink all [Reference]s in it. | |
| 2864 class RemovalVisitor extends ir.RecursiveVisitor { | |
| 2865 processReference(ir.Reference reference) { | |
| 2866 reference.unlink(); | |
| 2867 } | |
| 2868 } | |
| OLD | NEW |