use of org.eclipse.n4js.flowgraphs.model.ComplexNode in project n4js by eclipse.
the class StandardCFEFactory method buildComplexNode.
private static ComplexNode buildComplexNode(ReentrantASTIterator astpp, ControlFlowElement cfe, boolean isRepresenting) {
ComplexNode cNode = new ComplexNode(astpp.container(), cfe);
HelperNode entryNode = new HelperNode(NodeNames.ENTRY, astpp.pos(), cfe);
List<Node> argumentNodes = CFEChildren.get(astpp, cfe);
Node exitNode;
String extName;
if (argumentNodes.isEmpty()) {
entryNode = null;
extName = NodeNames.ENTRY_EXIT;
} else {
extName = NodeNames.EXIT;
}
if (isRepresenting) {
exitNode = new RepresentingNode(extName, astpp.pos(), cfe);
} else {
exitNode = new HelperNode(extName, astpp.pos(), cfe);
}
cNode.addNode(entryNode);
for (Node arg : argumentNodes) cNode.addNode(arg);
cNode.addNode(exitNode);
List<Node> nodes = new LinkedList<>();
nodes.add(entryNode);
nodes.addAll(argumentNodes);
nodes.add(exitNode);
cNode.connectInternalSucc(nodes);
if (argumentNodes.isEmpty()) {
cNode.setEntryNode(exitNode);
} else {
cNode.setEntryNode(entryNode);
}
cNode.setExitNode(exitNode);
return cNode;
}
use of org.eclipse.n4js.flowgraphs.model.ComplexNode in project n4js by eclipse.
the class GraphVisitorAnalysis method forwardAnalysis.
/**
* see {@link N4JSFlowAnalyser#accept(GraphVisitor...)}
*/
public void forwardAnalysis(FlowAnalyser[] flowAnalysers) {
if (forwardAnalysisDone) {
throw new IllegalStateException("Forward analysis can be performed only once.");
}
List<GraphVisitorInternal> graphVisitors = getGraphVisitors(flowAnalysers, TraverseDirection.Forward);
GraphVisitorGuideInternal guide = new GraphVisitorGuideInternal(flowAnalyzer, graphVisitors);
guide.init();
for (ControlFlowElement container : cfg.getAllContainers()) {
ComplexNode cnContainer = cfg.getComplexNode(container);
guide.walkthroughForward(cnContainer);
}
guide.terminate();
forwardAnalysisDone = true;
}
use of org.eclipse.n4js.flowgraphs.model.ComplexNode in project n4js by eclipse.
the class VariableDeclarationFactory method buildComplexNode.
static ComplexNode buildComplexNode(ReentrantASTIterator astpp, VariableDeclaration vd) {
ComplexNode cNode = new ComplexNode(astpp.container(), vd);
HelperNode entryNode = new HelperNode(NodeNames.ENTRY, astpp.pos(), vd);
Node expressionNode = null;
if (vd.getExpression() != null) {
expressionNode = DelegatingNodeFactory.create(astpp, NodeNames.EXPRESSION, vd, vd.getExpression());
}
Node exitNode = new RepresentingNode(NodeNames.EXIT, astpp.pos(), vd);
cNode.addNode(entryNode);
cNode.addNode(expressionNode);
cNode.addNode(exitNode);
List<Node> nodes = new LinkedList<>();
nodes.add(entryNode);
nodes.add(expressionNode);
nodes.add(exitNode);
cNode.connectInternalSucc(nodes);
if (vd.eContainer() instanceof BindingElement) {
// In this case, the expression is the default value
// TODO: improve this: find out if this is true or false
cNode.connectInternalSucc(entryNode, exitNode);
}
cNode.setEntryNode(entryNode);
cNode.setExitNode(exitNode);
return cNode;
}
Aggregations