/** Does a conversion of the fork container class to a set of block starts */ ArrayDeque<ParallelBlockStart> convertForksToBlockStarts(ArrayDeque<Fork> parallelForks) { // Walk through and convert forks to parallel block starts, and find heads that point to them ArrayDeque<ParallelBlockStart> output = new ArrayDeque<ParallelBlockStart>(); for (Fork f : parallelForks) { // Do processing to assign heads to flowsegments ParallelBlockStart start = new ParallelBlockStart(); start.forkStart = f.forkStart; start.unvisited = new ArrayDeque<FlowNode>(); // Add the nodes to the parallel starts here for (FlowPiece fp : f.following) { if (fp.isLeaf()) { // Forks are never leaves start.unvisited.add(((FlowSegment)fp).visited.get(0)); } } output.add(start); } return output; }
/** * Invoked when we start entering a parallel block (walking from head of the flow, so we see the block end first) * @param endNode Node where parents merge (final end node for the parallel block) * @param parents Parent nodes that end here * @return FlowNode myNext node to visit */ FlowNode hitParallelEnd(BlockEndNode endNode, List<FlowNode> parents, Collection<FlowNode> blackList) { BlockStartNode start = endNode.getStartNode(); ArrayDeque<FlowNode> branches = new ArrayDeque<FlowNode>(); for (FlowNode f : parents) { if (!blackList.contains(f)) { branches.addFirst(f); } } FlowNode output = null; if (branches.size() > 0) { // Push another branch start ParallelBlockStart parallelBlockStart = new ParallelBlockStart(start); output = branches.pop(); parallelBlockStart.unvisited = branches; if (currentParallelStart != null) { parallelBlockStartStack.push(currentParallelStart); } currentParallelStart = parallelBlockStart; currentParallelStartNode = start; } return output; }