* Traverses the call graph in preorder. This function can be used for * building optionally modified tree clones. This is the boilerplate code * for this scenario: * * callTree.traverse(function(node, parentClone) { * var nodeClone = cloneNode(node); * if (parentClone) *
(f)
| 1120 | * The second parameter is the result of calling 'f' on the parent node. |
| 1121 | */ |
| 1122 | traverse(f) { |
| 1123 | const pairsToProcess = new ConsArray(); |
| 1124 | pairsToProcess.concat([{ node: this.root_, param: null }]); |
| 1125 | while (!pairsToProcess.atEnd()) { |
| 1126 | const pair = pairsToProcess.next(); |
| 1127 | const node = pair.node; |
| 1128 | const newParam = f(node, pair.param); |
| 1129 | const morePairsToProcess = []; |
| 1130 | node.forEachChild((child) => { |
| 1131 | morePairsToProcess.push({ node: child, param: newParam }); |
| 1132 | }); |
| 1133 | pairsToProcess.concat(morePairsToProcess); |
| 1134 | } |
| 1135 | } |
| 1136 | |
| 1137 | /** |
| 1138 | * Performs an indepth call graph traversal. |
no test coverage detected