| 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 dart2js.cps_ir.shrinking_reductions; | 5 library dart2js.cps_ir.shrinking_reductions; |
| 6 | 6 |
| 7 import 'cps_ir_nodes.dart'; | 7 import 'cps_ir_nodes.dart'; |
| 8 import 'optimizers.dart'; | 8 import 'optimizers.dart'; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 } else if (_isBetaContLin(cont)) { | 485 } else if (_isBetaContLin(cont)) { |
| 486 worklist.add(new _ReductionTask(_ReductionKind.BETA_CONT_LIN, cont)); | 486 worklist.add(new _ReductionTask(_ReductionKind.BETA_CONT_LIN, cont)); |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 } | 489 } |
| 490 } | 490 } |
| 491 } | 491 } |
| 492 | 492 |
| 493 /// Traverses the CPS term and sets node.parent for each visited node. | 493 /// Traverses the CPS term and sets node.parent for each visited node. |
| 494 class ParentVisitor extends RecursiveVisitor { | 494 class ParentVisitor extends RecursiveVisitor { |
| 495 static final ParentVisitor _instance = new ParentVisitor(); |
| 496 static void setParentPointers(Node node) => _instance.visit(node); |
| 497 |
| 495 processFunctionDefinition(FunctionDefinition node) { | 498 processFunctionDefinition(FunctionDefinition node) { |
| 496 node.body.parent = node; | 499 node.body.parent = node; |
| 497 if (node.thisParameter != null) node.thisParameter.parent = node; | 500 if (node.thisParameter != null) node.thisParameter.parent = node; |
| 498 int index = 0; | 501 int index = 0; |
| 499 node.parameters.forEach((Definition parameter) { | 502 node.parameters.forEach((Definition parameter) { |
| 500 parameter.parent = node; | 503 parameter.parent = node; |
| 501 if (parameter is Parameter) parameter.parentIndex = index++; | 504 if (parameter is Parameter) parameter.parentIndex = index++; |
| 502 }); | 505 }); |
| 503 node.returnContinuation.parent = node; | 506 node.returnContinuation.parent = node; |
| 504 node.body.parent = node; | 507 node.body.parent = node; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 } | 739 } |
| 737 | 740 |
| 738 String toString() => "$kind: $node"; | 741 String toString() => "$kind: $node"; |
| 739 } | 742 } |
| 740 | 743 |
| 741 /// A dummy class used solely to mark nodes as deleted once they are removed | 744 /// A dummy class used solely to mark nodes as deleted once they are removed |
| 742 /// from a term. | 745 /// from a term. |
| 743 class _DeletedNode extends Node { | 746 class _DeletedNode extends Node { |
| 744 accept(_) => null; | 747 accept(_) => null; |
| 745 } | 748 } |
| OLD | NEW |