Search in sources :

Example 1 with RepresentingNode

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

the class PathWalkerGuide method visitNode.

@Override
public void visitNode(Node node) {
    if (node instanceof RepresentingNode) {
        ControlFlowElement cfeEnd = node.getRepresentedControlFlowElement();
        if (lastVisitedNode != null) {
            ControlFlowElement cfeStart = lastVisitedNode.getRepresentedControlFlowElement();
            FlowEdge edge = new FlowEdge(cfeStart, cfeEnd, cfTypes);
            walker.visit(edge);
        }
        cfTypes.clear();
        walker.visit(cfeEnd);
        lastVisitedNode = node;
    }
}
Also used : FlowEdge(org.eclipse.n4js.flowgraphs.FlowEdge) ControlFlowEdge(org.eclipse.n4js.flowgraphs.model.ControlFlowEdge) RepresentingNode(org.eclipse.n4js.flowgraphs.model.RepresentingNode) ControlFlowElement(org.eclipse.n4js.n4JS.ControlFlowElement)

Example 2 with RepresentingNode

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

the class BranchWalker method visit.

@Override
protected final void visit(Node node) {
    if (node instanceof RepresentingNode) {
        lastRN = node;
        ControlFlowElement cfe = node.getRepresentedControlFlowElement();
        visit(cfe);
        return;
    }
    if (this.getContainer() == node.getControlFlowElement()) {
        ControlFlowElement cfe = node.getControlFlowElement();
        if (lastRN == null) {
            enterContainer(cfe);
        } else {
            exitContainer(cfe);
        }
        lastRN = node;
    }
}
Also used : RepresentingNode(org.eclipse.n4js.flowgraphs.model.RepresentingNode) ControlFlowElement(org.eclipse.n4js.n4JS.ControlFlowElement)

Example 3 with RepresentingNode

use of org.eclipse.n4js.flowgraphs.model.RepresentingNode 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;
}
Also used : HelperNode(org.eclipse.n4js.flowgraphs.model.HelperNode) ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) HelperNode(org.eclipse.n4js.flowgraphs.model.HelperNode) RepresentingNode(org.eclipse.n4js.flowgraphs.model.RepresentingNode) Node(org.eclipse.n4js.flowgraphs.model.Node) RepresentingNode(org.eclipse.n4js.flowgraphs.model.RepresentingNode) CatchToken(org.eclipse.n4js.flowgraphs.model.CatchToken)

Example 4 with RepresentingNode

use of org.eclipse.n4js.flowgraphs.model.RepresentingNode 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;
}
Also used : ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) RepresentingNode(org.eclipse.n4js.flowgraphs.model.RepresentingNode) Node(org.eclipse.n4js.flowgraphs.model.Node) RepresentingNode(org.eclipse.n4js.flowgraphs.model.RepresentingNode)

Example 5 with RepresentingNode

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

the class EmptyStatementFactory method buildComplexNode.

static ComplexNode buildComplexNode(ReentrantASTIterator astpp, Statement 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;
}
Also used : ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) RepresentingNode(org.eclipse.n4js.flowgraphs.model.RepresentingNode) Node(org.eclipse.n4js.flowgraphs.model.Node) RepresentingNode(org.eclipse.n4js.flowgraphs.model.RepresentingNode)

Aggregations

RepresentingNode (org.eclipse.n4js.flowgraphs.model.RepresentingNode)13 ComplexNode (org.eclipse.n4js.flowgraphs.model.ComplexNode)8 Node (org.eclipse.n4js.flowgraphs.model.Node)8 HelperNode (org.eclipse.n4js.flowgraphs.model.HelperNode)6 LinkedList (java.util.LinkedList)5 ControlFlowElement (org.eclipse.n4js.n4JS.ControlFlowElement)5 ControlFlowEdge (org.eclipse.n4js.flowgraphs.model.ControlFlowEdge)3 HashSet (java.util.HashSet)2 FlowEdge (org.eclipse.n4js.flowgraphs.FlowEdge)2 CatchToken (org.eclipse.n4js.flowgraphs.model.CatchToken)2 ControlFlowType (org.eclipse.n4js.flowgraphs.ControlFlowType)1 JumpToken (org.eclipse.n4js.flowgraphs.model.JumpToken)1 BindingElement (org.eclipse.n4js.n4JS.BindingElement)1 VariableDeclarationOrBinding (org.eclipse.n4js.n4JS.VariableDeclarationOrBinding)1