labelsToNodes.put(label, cfNode);
}
}
final ControlFlowNode entryNode = labelsToNodes.get(entryLabel);
final ControlFlowEdge entryEdge = new ControlFlowEdge(entryPoint, entryNode, JumpType.Normal);
entryPoint.getOutgoing().add(entryEdge);
entryNode.getIncoming().add(entryEdge);
//
// Create edges.
//
for (final Node node : nodes) {
final List<Node> nodeBody = ((BasicBlock) node).getBody();
final ControlFlowNode source = astNodesToControlFlowNodes.get(node);
//
// Find all branches.
//
for (final Expression e : node.getSelfAndChildrenRecursive(Expression.class)) {
if (!e.isBranch()) {
continue;
}
for (final Label target : e.getBranchTargets()) {
final ControlFlowNode destination = labelsToNodes.get(target);
if (destination != null &&
(destination != source || !nodeBody.isEmpty() && target == nodeBody.get(0))) {
final ControlFlowEdge edge = new ControlFlowEdge(source, destination, JumpType.Normal);
if (!source.getOutgoing().contains(edge)) {
source.getOutgoing().add(edge);
}