Index: pkg/compiler/lib/src/cps_ir/cps_fragment.dart |
diff --git a/pkg/compiler/lib/src/cps_ir/cps_fragment.dart b/pkg/compiler/lib/src/cps_ir/cps_fragment.dart |
index cecad3191c8bbc8f295d11f3cc67b0f8b5d9a3c6..7fc2ae38373fb2bd8cac048dd568cec129d9ae34 100644 |
--- a/pkg/compiler/lib/src/cps_ir/cps_fragment.dart |
+++ b/pkg/compiler/lib/src/cps_ir/cps_fragment.dart |
@@ -314,3 +314,11 @@ class CpsFragment { |
insertBelow(node.parent); |
} |
} |
+ |
+/// Removes [node], unlinking all its references and replaces it with [newNode]. |
+void destroyAndReplace(Expression node, Expression newNode) { |
+ InteriorNode parent = node.parent; |
+ RemovalVisitor.remove(node); |
+ parent.body = newNode; |
+ newNode.parent = parent; |
+} |