Search in sources :

Example 1 with DelegatingNode

use of org.eclipse.n4js.flowgraphs.model.DelegatingNode in project n4js by eclipse.

the class DelegatingNodeFactory method create.

/**
 * Returns control flow after the delegate {@link ControlFlowElement} was visited.
 *
 * @return a new {@link DelegatingNode} instance
 */
static DelegatingNode create(ReentrantASTIterator astpp, String name, ControlFlowElement parent, ControlFlowElement delegate) {
    if (delegate == null) {
        return null;
    }
    DelegatingNode node = new DelegatingNode(name, astpp.pos(), parent, delegate);
    astpp.visitUtil(delegate);
    return node;
}
Also used : DelegatingNode(org.eclipse.n4js.flowgraphs.model.DelegatingNode)

Example 2 with DelegatingNode

use of org.eclipse.n4js.flowgraphs.model.DelegatingNode in project n4js by eclipse.

the class CFEChildren method addDelegatingNode.

static Node addDelegatingNode(ReentrantASTIterator astIter, List<Node> cfc, String name, ControlFlowElement cfe, ControlFlowElement delegate) {
    if (delegate != null) {
        DelegatingNode delegatingNode = DelegatingNodeFactory.create(astIter, name, cfe, delegate);
        cfc.add(delegatingNode);
        return delegatingNode;
    }
    return null;
}
Also used : DelegatingNode(org.eclipse.n4js.flowgraphs.model.DelegatingNode)

Example 3 with DelegatingNode

use of org.eclipse.n4js.flowgraphs.model.DelegatingNode in project n4js by eclipse.

the class AbstractCaseClauseFactory method buildComplexNode.

static ComplexNode buildComplexNode(ReentrantASTIterator astpp, AbstractCaseClause abstrCaseClause) {
    ComplexNode cNode = new ComplexNode(astpp.container(), abstrCaseClause);
    Node entryNode = new HelperNode(NodeNames.ENTRY, astpp.pos(), abstrCaseClause);
    List<Node> stmtNodes = new LinkedList<>();
    Node caseConditionNode = null;
    if (abstrCaseClause instanceof CaseClause) {
        CaseClause caseClause = (CaseClause) abstrCaseClause;
        caseConditionNode = DelegatingNodeFactory.create(astpp, NodeNames.CONDITION, caseClause, caseClause.getExpression());
    }
    EList<Statement> stmts = abstrCaseClause.getStatements();
    for (int i = 0; i < stmts.size(); i++) {
        Statement stmt = stmts.get(i);
        Node blockNode = new DelegatingNode("stmt_" + i, astpp.pos(), abstrCaseClause, stmt);
        stmtNodes.add(blockNode);
        astpp.visitUtil(blockNode.getDelegatedControlFlowElement());
    }
    Node exitNode = new HelperNode(NodeNames.EXIT, astpp.pos(), abstrCaseClause);
    cNode.addNode(entryNode);
    cNode.addNode(caseConditionNode);
    for (Node blockNode : stmtNodes) cNode.addNode(blockNode);
    cNode.addNode(exitNode);
    List<Node> nodes = new LinkedList<>();
    nodes.add(entryNode);
    nodes.add(caseConditionNode);
    nodes.addAll(stmtNodes);
    nodes.add(exitNode);
    cNode.connectInternalSucc(nodes);
    cNode.setEntryNode(entryNode);
    cNode.setExitNode(exitNode);
    return cNode;
}
Also used : HelperNode(org.eclipse.n4js.flowgraphs.model.HelperNode) ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) Statement(org.eclipse.n4js.n4JS.Statement) ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) DelegatingNode(org.eclipse.n4js.flowgraphs.model.DelegatingNode) HelperNode(org.eclipse.n4js.flowgraphs.model.HelperNode) Node(org.eclipse.n4js.flowgraphs.model.Node) CaseClause(org.eclipse.n4js.n4JS.CaseClause) AbstractCaseClause(org.eclipse.n4js.n4JS.AbstractCaseClause) DelegatingNode(org.eclipse.n4js.flowgraphs.model.DelegatingNode) LinkedList(java.util.LinkedList)

Aggregations

DelegatingNode (org.eclipse.n4js.flowgraphs.model.DelegatingNode)3 LinkedList (java.util.LinkedList)1 ComplexNode (org.eclipse.n4js.flowgraphs.model.ComplexNode)1 HelperNode (org.eclipse.n4js.flowgraphs.model.HelperNode)1 Node (org.eclipse.n4js.flowgraphs.model.Node)1 AbstractCaseClause (org.eclipse.n4js.n4JS.AbstractCaseClause)1 CaseClause (org.eclipse.n4js.n4JS.CaseClause)1 Statement (org.eclipse.n4js.n4JS.Statement)1