use of org.eclipse.n4js.flowgraphs.model.ControlFlowEdge in project n4js by eclipse.
the class EdgeGuideWorklist method getAllVisitedNodes.
/**
* @return a set of all visited nodes
*/
Set<Node> getAllVisitedNodes(ComplexNode cn, NextEdgesProvider edgeProvider) {
Set<Node> allVisitedNodes = new HashSet<>();
for (ControlFlowEdge edge : allVisitedEdges) {
allVisitedNodes.add(edge.start);
allVisitedNodes.add(edge.end);
}
allVisitedNodes.add(edgeProvider.getStartNode(cn));
return allVisitedNodes;
}
use of org.eclipse.n4js.flowgraphs.model.ControlFlowEdge in project n4js by eclipse.
the class EdgeGuide method getNextEdgeGuides.
List<EdgeGuide> getNextEdgeGuides() {
List<EdgeGuide> nextEGs = new LinkedList<>();
List<ControlFlowEdge> nextEdges = edgeProvider.getNextEdges(getNextNode());
nextEdges = finallyContext.filterEdges(nextEdges);
Iterator<ControlFlowEdge> nextEdgeIt = nextEdges.iterator();
boolean deadAliveChange = false;
if (nextEdges.size() == 0) {
for (BranchWalkerInternal aPath : getBranchIterable()) {
aPath.deactivate();
}
}
if (nextEdges.size() == 1) {
deadAliveChange = isDeadAliveChange(nextEdges.get(0));
if (!deadAliveChange) {
ControlFlowEdge nextEdge = nextEdgeIt.next();
edge = nextEdge;
finallyContext.update(edgeProvider, edge);
setBranchWalkersReachability();
nextEGs.add(this);
}
}
if (deadAliveChange || nextEdges.size() > 1) {
while (nextEdgeIt.hasNext()) {
ControlFlowEdge nextEdge = nextEdgeIt.next();
Collection<BranchWalkerInternal> forkedPaths = new HashSet<>();
for (BranchWalkerInternal aPath : getBranchIterable()) {
BranchWalkerInternal forkedPath = aPath.callFork();
aPath.deactivate();
if (forkedPath != null) {
forkedPaths.add(forkedPath);
}
}
NextEdgesProvider epCopy = edgeProvider.copy();
EdgeGuide edgeGuide = new EdgeGuide(epCopy, nextEdge, forkedPaths, finallyContext, deadContext);
nextEGs.add(edgeGuide);
}
}
return nextEGs;
}
use of org.eclipse.n4js.flowgraphs.model.ControlFlowEdge in project n4js by eclipse.
the class GraphVisitorGuideInternal method callVisitOnEdge.
/**
* This method must be kept in sync with {@link #callVisitOnNode(EdgeGuide, Node)}
*/
private void callVisitOnEdge(Node lastVisitNode, EdgeGuide currEdgeGuide, Node visitNode) {
ControlFlowEdge egEdge = currEdgeGuide.getEdge();
ControlFlowEdge visitedEdge = currEdgeGuide.getEdge();
if (!guideWorklist.edgeVisited(egEdge)) {
for (GraphVisitorInternal visitor : visitors) {
visitor.callVisit(lastVisitNode, visitNode, visitedEdge);
}
}
for (GraphVisitorInternal walker : visitors) {
List<BranchWalkerInternal> activatedPaths = walker.activateRequestedExplorers();
currEdgeGuide.addActiveBranches(activatedPaths);
}
for (Iterator<BranchWalkerInternal> branchWalkerIt = currEdgeGuide.getBranchIterable().iterator(); branchWalkerIt.hasNext(); ) {
BranchWalkerInternal branchWalker = branchWalkerIt.next();
branchWalker.callVisit(lastVisitNode, visitNode, visitedEdge);
if (!branchWalker.isActive()) {
branchWalkerIt.remove();
}
}
}
use of org.eclipse.n4js.flowgraphs.model.ControlFlowEdge in project n4js by eclipse.
the class BranchWalker method visit.
@Override
protected final void visit(Node start, Node end, ControlFlowEdge edge) {
pEdgeTypes.add(edge.cfType);
if (end instanceof RepresentingNode || this.getContainer() == end.getControlFlowElement()) {
ControlFlowElement endCFE = end.getRepresentedControlFlowElement();
endCFE = endCFE == null ? end.getControlFlowElement() : endCFE;
if (lastRN != null) {
ControlFlowElement startCFE = lastRN.getRepresentedControlFlowElement();
startCFE = startCFE == null ? lastRN.getControlFlowElement() : startCFE;
FlowEdge flowEdge = new FlowEdge(startCFE, endCFE, pEdgeTypes);
visit(flowEdge);
pEdgeTypes.clear();
} else {
HashSet<EdgeInfo> edgeInfos = new HashSet<>();
addPredecedingRepNodes(this, edgeInfos, new EdgeInfo(this));
for (EdgeInfo edgeInfo : edgeInfos) {
ControlFlowElement startCFE = edgeInfo.startNode.getRepresentedControlFlowElement();
startCFE = startCFE == null ? edgeInfo.startNode.getControlFlowElement() : startCFE;
FlowEdge flowEdge = new FlowEdge(startCFE, endCFE, edgeInfo.pEdgeTypes);
edgeInfo.edgeOwner.visit(flowEdge);
}
pEdgeTypes.clear();
}
}
}
use of org.eclipse.n4js.flowgraphs.model.ControlFlowEdge in project n4js by eclipse.
the class ControlFlowGraphFactory method removeNode.
private static void removeNode(ComplexNode cn, Node mNode) {
ControlFlowEdge e1 = mNode.pred.first();
ControlFlowEdge e2 = mNode.succ.first();
Node pred = e1.start;
Node succ = e2.end;
EdgeUtils.removeCF(e1);
EdgeUtils.removeCF(e2);
cn.removeNodeChecks(mNode);
cn.removeNode(mNode);
for (Node intPred : mNode.getInternalPredecessors()) {
intPred.removeInternalSuccessor(mNode);
}
for (Node intSucc : mNode.getInternalSuccessors()) {
intSucc.removeInternalPredecessor(mNode);
}
mNode.getInternalPredecessors().clear();
mNode.getInternalSuccessors().clear();
EdgeUtils.connectCF(pred, succ);
}
Aggregations