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;
}
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);
}
}
Aggregations