use of org.eclipse.n4js.flowgraphs.model.ComplexNode in project n4js by eclipse.
the class GraphVisitorAnalysis method backwardAnalysis.
/**
* see {@link N4JSFlowAnalyser#accept(GraphVisitor...)}
*/
public void backwardAnalysis(FlowAnalyser[] flowAnalysers) {
if (!forwardAnalysisDone) {
throw new IllegalStateException("Forward analysis must be performed first.");
}
List<GraphVisitorInternal> graphVisitors = getGraphVisitors(flowAnalysers, TraverseDirection.Backward);
GraphVisitorGuideInternal guide = new GraphVisitorGuideInternal(flowAnalyzer, graphVisitors);
guide.init();
for (ControlFlowElement container : cfg.getAllContainers()) {
ComplexNode cnContainer = cfg.getComplexNode(container);
guide.walkthroughBackward(cnContainer);
}
guide.terminate();
}
use of org.eclipse.n4js.flowgraphs.model.ComplexNode in project n4js by eclipse.
the class DirectPathAnalyses method getPath.
/**
* @return a path from cfeFrom to cfeTo that does not include over cfeNotVia
*/
public Path getPath(ControlFlowElement cfeFrom, ControlFlowElement cfeTo, ControlFlowElement cfeNotVia) {
ComplexNode cnStart = cfg.getComplexNode(cfeFrom);
ComplexNode cnEnd = cfg.getComplexNode(cfeTo);
Node nStart = cnStart.getRepresent();
Node nEnd = cnEnd.getRepresent();
Node nNotVia = null;
if (cfeNotVia != null) {
ComplexNode cnNotVia = cfg.getComplexNode(cfeNotVia);
nNotVia = cnNotVia.getRepresent();
}
Path path = buildPath(nStart, nEnd, nNotVia);
return path;
}
use of org.eclipse.n4js.flowgraphs.model.ComplexNode in project n4js by eclipse.
the class EdgeGuide method getFirstEdgeGuides.
static List<EdgeGuide> getFirstEdgeGuides(ComplexNode cn, NextEdgesProvider edgeProvider, Collection<BranchWalkerInternal> activatedPaths) {
List<EdgeGuide> nextEGs = new LinkedList<>();
Node node = edgeProvider.getStartNode(cn);
List<ControlFlowEdge> nextEdges = edgeProvider.getNextEdges(node);
Iterator<ControlFlowEdge> nextEdgeIt = nextEdges.iterator();
if (nextEdges.size() == 1) {
ControlFlowEdge nextEdge = nextEdgeIt.next();
EdgeGuide eg = new EdgeGuide(edgeProvider.copy(), nextEdge, activatedPaths);
eg.deadContext.update(eg.getPrevNode());
nextEGs.add(eg);
}
if (nextEdges.size() > 1) {
while (nextEdgeIt.hasNext()) {
ControlFlowEdge nextEdge = nextEdgeIt.next();
Collection<BranchWalkerInternal> forkedPaths = new HashSet<>();
for (BranchWalkerInternal aPath : activatedPaths) {
BranchWalkerInternal forkedPath = aPath.callFork();
forkedPaths.add(forkedPath);
}
EdgeGuide eg = new EdgeGuide(edgeProvider.copy(), nextEdge, forkedPaths);
eg.deadContext.update(eg.getPrevNode());
nextEGs.add(eg);
}
}
return nextEGs;
}
use of org.eclipse.n4js.flowgraphs.model.ComplexNode in project n4js by eclipse.
the class ConditionalExpressionFactory method buildComplexNode.
static ComplexNode buildComplexNode(ReentrantASTIterator astpp, ConditionalExpression condExpr) {
ComplexNode cNode = new ComplexNode(astpp.container(), condExpr);
HelperNode entryNode = new HelperNode(NodeNames.ENTRY, astpp.pos(), condExpr);
Node conditionNode = DelegatingNodeFactory.createOrHelper(astpp, NodeNames.CONDITION, condExpr, condExpr.getExpression());
HelperNode conditionForkNode = new HelperNode(NodeNames.CONDITION_FORK, astpp.pos(), condExpr);
Node thenNode = DelegatingNodeFactory.createOrHelper(astpp, NodeNames.THEN, condExpr, condExpr.getTrueExpression());
Node elseNode = DelegatingNodeFactory.createOrHelper(astpp, NodeNames.ELSE, condExpr, condExpr.getFalseExpression());
Node exitNode = new RepresentingNode(NodeNames.EXIT, astpp.pos(), condExpr);
cNode.addNode(entryNode);
cNode.addNode(conditionNode);
cNode.addNode(conditionForkNode);
cNode.addNode(thenNode);
cNode.addNode(elseNode);
cNode.addNode(exitNode);
cNode.connectInternalSucc(entryNode, conditionNode, conditionForkNode);
cNode.connectInternalSucc(ControlFlowType.IfTrue, conditionForkNode, thenNode);
cNode.connectInternalSucc(thenNode, exitNode);
cNode.connectInternalSucc(ControlFlowType.IfFalse, conditionForkNode, elseNode);
cNode.connectInternalSucc(elseNode, exitNode);
// catch for short-circuits
thenNode.addCatchToken(new CatchToken(ControlFlowType.IfTrue));
// catch for short-circuits
elseNode.addCatchToken(new CatchToken(ControlFlowType.IfFalse));
cNode.setEntryNode(entryNode);
cNode.setExitNode(exitNode);
return cNode;
}
use of org.eclipse.n4js.flowgraphs.model.ComplexNode in project n4js by eclipse.
the class DebuggerStatementFactory method buildComplexNode.
static ComplexNode buildComplexNode(ReentrantASTIterator astpp, DebuggerStatement empty) {
ComplexNode cNode = new ComplexNode(astpp.container(), empty);
Node entryAndExitNode = new RepresentingNode(NodeNames.ENTRY_EXIT, astpp.pos(), empty);
cNode.addNode(entryAndExitNode);
cNode.setEntryNode(entryAndExitNode);
cNode.setExitNode(entryAndExitNode);
return cNode;
}
Aggregations