use of org.eclipse.n4js.flowgraphs.model.Node in project n4js by eclipse.
the class SuccessorPredecessorAnalysis method getPredecessorsSkipInternal.
/**
* see {@link N4JSFlowAnalyser#getPredecessorsSkipInternal(ControlFlowElement)}
*/
public Set<ControlFlowElement> getPredecessorsSkipInternal(ControlFlowElement cfe) {
NextEdgesProvider nextEdgesProvider = new NextEdgesProvider.Backward();
Node nextNode = getNextNode(cfe, true, nextEdgesProvider);
Set<ControlFlowElement> predecessors = getNextCFEs(nextEdgesProvider, cfe, nextNode);
return predecessors;
}
use of org.eclipse.n4js.flowgraphs.model.Node in project n4js by eclipse.
the class GuardStructureFactory method getCondition.
/**
* @return the top {@link Expression} of a {@link GuardStructure}, or null.
*/
private static Expression getCondition(ControlFlowEdge edge) {
Expression condition = null;
Node previousNode = edge.start;
ControlFlowElement previousCFE = previousNode.getControlFlowElement();
if (previousCFE instanceof ConditionalExpression) {
ConditionalExpression ce = (ConditionalExpression) previousCFE;
condition = ce.getExpression();
} else if (previousCFE instanceof BinaryLogicalExpression) {
BinaryLogicalExpression ble = (BinaryLogicalExpression) previousCFE;
condition = ble.getLhs();
} else if (previousCFE instanceof IfStatement) {
IfStatement is = (IfStatement) previousCFE;
condition = is.getExpression();
} else if (previousCFE instanceof WhileStatement) {
WhileStatement ws = (WhileStatement) previousCFE;
condition = ws.getExpression();
} else if (previousCFE instanceof DoStatement) {
DoStatement ws = (DoStatement) previousCFE;
condition = ws.getExpression();
} else if (previousCFE instanceof ForStatement) {
ForStatement ws = (ForStatement) previousCFE;
condition = ws.getExpression();
}
return condition;
}
use of org.eclipse.n4js.flowgraphs.model.Node 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.Node in project n4js by eclipse.
the class EdgeGuideQueue method isJoinGroup.
private boolean isJoinGroup(EdgeGuide eg1, EdgeGuide eg2) {
Node nextN1 = eg1.getNextNode();
Node nextN2 = eg2.getNextNode();
boolean isJoinGroup = nextN1 == nextN2 && eg1.finallyContext.equals(eg2.finallyContext);
return isJoinGroup;
}
use of org.eclipse.n4js.flowgraphs.model.Node in project n4js by eclipse.
the class EdgeGuideQueue method compareASTPosition.
private static int compareASTPosition(EdgeGuide eg1, EdgeGuide eg2) {
Node nextNode1 = eg1.getNextNode();
Node nextNode2 = eg2.getNextNode();
int p2 = nextNode2.astPosition;
int p1 = nextNode1.astPosition;
boolean isForward = eg1.edgeProvider.isForward();
int posDiff = (isForward) ? p1 - p2 : p2 - p1;
return posDiff;
}
Aggregations