Search in sources :

Example 6 with FinallyBlock

use of org.eclipse.n4js.n4JS.FinallyBlock in project n4js by eclipse.

the class ControlFlowGraphFactory method getEnteringFinallyBlock.

private static FinallyBlock getEnteringFinallyBlock(Node catchNode) {
    if (catchNode.name.equals(NodeNames.FINALLY)) {
        ControlFlowElement cfe = catchNode.getDelegatedControlFlowElement();
        EObject cfeContainer = cfe.eContainer();
        return (FinallyBlock) cfeContainer;
    }
    return null;
}
Also used : FinallyBlock(org.eclipse.n4js.n4JS.FinallyBlock) EObject(org.eclipse.emf.ecore.EObject) ControlFlowElement(org.eclipse.n4js.n4JS.ControlFlowElement)

Example 7 with FinallyBlock

use of org.eclipse.n4js.n4JS.FinallyBlock in project n4js by eclipse.

the class ControlFlowGraphFactory method connectToJumpTarget.

private static void connectToJumpTarget(ComplexNodeMapper cnMapper, Node jumpNode, JumpToken jumpToken) {
    Pair<Node, ControlFlowType> catcher = CatchNodeFinder.find(jumpToken, jumpNode, cnMapper);
    if (catcher == null) {
        String jumpTokenStr = getJumpTokenDetailString(jumpToken, jumpNode);
        System.err.println("Could not find catching node for jump token '" + jumpTokenStr + "'");
        return;
    }
    Node catchNode = catcher.getKey();
    ControlFlowType newEdgeType = catcher.getValue();
    FinallyBlock enteringFinallyBlock = getEnteringFinallyBlock(catchNode);
    boolean isExitingFinallyBlock = isExitingFinallyBlock(cnMapper, jumpNode);
    if (enteringFinallyBlock != null || isExitingFinallyBlock) {
        boolean equalEdgeExistsAlready = equalEdgeExistsAlready(jumpNode, jumpToken, catchNode);
        if (!equalEdgeExistsAlready) {
            EdgeUtils.connectCF(jumpNode, catchNode, jumpToken);
        }
    } else {
        EdgeUtils.connectCF(jumpNode, catchNode, newEdgeType);
    }
    if (enteringFinallyBlock != null) {
        // Iff finally block was entered abruptly, jump on from exit of finally block
        Block block = enteringFinallyBlock.getBlock();
        ComplexNode cnBlock = cnMapper.get(block);
        Node exitFinallyBlock = cnBlock.getExit();
        connectToJumpTarget(cnMapper, exitFinallyBlock, jumpToken);
    }
}
Also used : ControlFlowType(org.eclipse.n4js.flowgraphs.ControlFlowType) FinallyBlock(org.eclipse.n4js.n4JS.FinallyBlock) ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) ComplexNode(org.eclipse.n4js.flowgraphs.model.ComplexNode) RepresentingNode(org.eclipse.n4js.flowgraphs.model.RepresentingNode) DelegatingNode(org.eclipse.n4js.flowgraphs.model.DelegatingNode) Node(org.eclipse.n4js.flowgraphs.model.Node) FinallyBlock(org.eclipse.n4js.n4JS.FinallyBlock) Block(org.eclipse.n4js.n4JS.Block)

Aggregations

FinallyBlock (org.eclipse.n4js.n4JS.FinallyBlock)7 ComplexNode (org.eclipse.n4js.flowgraphs.model.ComplexNode)3 Block (org.eclipse.n4js.n4JS.Block)3 CatchBlock (org.eclipse.n4js.n4JS.CatchBlock)3 ControlFlowElement (org.eclipse.n4js.n4JS.ControlFlowElement)3 EObject (org.eclipse.emf.ecore.EObject)2 Node (org.eclipse.n4js.flowgraphs.model.Node)2 LinkedList (java.util.LinkedList)1 EPackage (org.eclipse.emf.ecore.EPackage)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 ControlFlowType (org.eclipse.n4js.flowgraphs.ControlFlowType)1 CatchToken (org.eclipse.n4js.flowgraphs.model.CatchToken)1 DelegatingNode (org.eclipse.n4js.flowgraphs.model.DelegatingNode)1 HelperNode (org.eclipse.n4js.flowgraphs.model.HelperNode)1 RepresentingNode (org.eclipse.n4js.flowgraphs.model.RepresentingNode)1 AdditiveExpression (org.eclipse.n4js.n4JS.AdditiveExpression)1 Annotation (org.eclipse.n4js.n4JS.Annotation)1 AnnotationList (org.eclipse.n4js.n4JS.AnnotationList)1 Argument (org.eclipse.n4js.n4JS.Argument)1 ArrayBindingPattern (org.eclipse.n4js.n4JS.ArrayBindingPattern)1