| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 cps_ir.cps_fragment; | 5 library cps_ir.cps_fragment; |
| 6 | 6 |
| 7 import 'cps_ir_nodes.dart'; | 7 import 'cps_ir_nodes.dart'; |
| 8 import '../constants/values.dart'; | 8 import '../constants/values.dart'; |
| 9 import '../universe/selector.dart' show Selector; | 9 import '../universe/selector.dart' show Selector; |
| 10 import '../types/types.dart' show TypeMask; | 10 import '../types/types.dart' show TypeMask; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 /// Removes [node], unlinking all its references and replaces it with [newNode]. | 342 /// Removes [node], unlinking all its references and replaces it with [newNode]. |
| 343 void destroyAndReplace(Expression node, Expression newNode) { | 343 void destroyAndReplace(Expression node, Expression newNode) { |
| 344 InteriorNode parent = node.parent; | 344 InteriorNode parent = node.parent; |
| 345 RemovalVisitor.remove(node); | 345 RemovalVisitor.remove(node); |
| 346 parent.body = newNode; | 346 parent.body = newNode; |
| 347 newNode.parent = parent; | 347 newNode.parent = parent; |
| 348 } | 348 } |
| 349 |
| 350 /// Removes all [Refinement] uses of a given primitive that has no effective |
| 351 /// uses. |
| 352 void destroyRefinementsOfDeadPrimitive(Primitive prim) { |
| 353 while (prim.firstRef != null) { |
| 354 Refinement refine = prim.firstRef.parent; |
| 355 destroyRefinementsOfDeadPrimitive(refine); |
| 356 LetPrim letPrim = refine.parent; |
| 357 InteriorNode parent = letPrim.parent; |
| 358 parent.body = letPrim.body; |
| 359 letPrim.body.parent = parent; |
| 360 prim.firstRef.unlink(); |
| 361 } |
| 362 } |
| OLD | NEW |