| 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 part of dart2js.cps_ir.optimizers; | 5 part of dart2js.cps_ir.optimizers; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * [ShrinkingReducer] applies shrinking reductions to CPS terms as described | 8 * [ShrinkingReducer] applies shrinking reductions to CPS terms as described |
| 9 * in 'Compiling with Continuations, Continued' by Andrew Kennedy. | 9 * in 'Compiling with Continuations, Continued' by Andrew Kennedy. |
| 10 */ | 10 */ |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 } | 481 } |
| 482 } | 482 } |
| 483 } | 483 } |
| 484 | 484 |
| 485 /// Traverses the CPS term and sets node.parent for each visited node. | 485 /// Traverses the CPS term and sets node.parent for each visited node. |
| 486 class ParentVisitor extends RecursiveVisitor { | 486 class ParentVisitor extends RecursiveVisitor { |
| 487 processFunctionDefinition(FunctionDefinition node) { | 487 processFunctionDefinition(FunctionDefinition node) { |
| 488 node.body.parent = node; | 488 node.body.parent = node; |
| 489 if (node.thisParameter != null) node.thisParameter.parent = node; |
| 489 int index = 0; | 490 int index = 0; |
| 490 node.parameters.forEach((Definition parameter) { | 491 node.parameters.forEach((Definition parameter) { |
| 491 parameter.parent = node; | 492 parameter.parent = node; |
| 492 if (parameter is Parameter) parameter.parentIndex = index++; | 493 if (parameter is Parameter) parameter.parentIndex = index++; |
| 493 }); | 494 }); |
| 494 } | 495 } |
| 495 | 496 |
| 496 processRunnableBody(RunnableBody node) { | 497 processRunnableBody(RunnableBody node) { |
| 497 node.returnContinuation.parent = node; | 498 node.returnContinuation.parent = node; |
| 498 node.body.parent = node; | 499 node.body.parent = node; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 } | 709 } |
| 709 | 710 |
| 710 String toString() => "$kind: $node"; | 711 String toString() => "$kind: $node"; |
| 711 } | 712 } |
| 712 | 713 |
| 713 /// A dummy class used solely to mark nodes as deleted once they are removed | 714 /// A dummy class used solely to mark nodes as deleted once they are removed |
| 714 /// from a term. | 715 /// from a term. |
| 715 class _DeletedNode extends Node { | 716 class _DeletedNode extends Node { |
| 716 accept(_) => null; | 717 accept(_) => null; |
| 717 } | 718 } |
| OLD | NEW |