use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.
the class BranchWalker method visit.
@Override
protected final void visit(Node start, Node end, ControlFlowEdge edge) {
pEdgeTypes.add(edge.cfType);
if (end instanceof RepresentingNode || this.getContainer() == end.getControlFlowElement()) {
ControlFlowElement endCFE = end.getRepresentedControlFlowElement();
endCFE = endCFE == null ? end.getControlFlowElement() : endCFE;
if (lastRN != null) {
ControlFlowElement startCFE = lastRN.getRepresentedControlFlowElement();
startCFE = startCFE == null ? lastRN.getControlFlowElement() : startCFE;
FlowEdge flowEdge = new FlowEdge(startCFE, endCFE, pEdgeTypes);
visit(flowEdge);
pEdgeTypes.clear();
} else {
HashSet<EdgeInfo> edgeInfos = new HashSet<>();
addPredecedingRepNodes(this, edgeInfos, new EdgeInfo(this));
for (EdgeInfo edgeInfo : edgeInfos) {
ControlFlowElement startCFE = edgeInfo.startNode.getRepresentedControlFlowElement();
startCFE = startCFE == null ? edgeInfo.startNode.getControlFlowElement() : startCFE;
FlowEdge flowEdge = new FlowEdge(startCFE, endCFE, edgeInfo.pEdgeTypes);
edgeInfo.edgeOwner.visit(flowEdge);
}
pEdgeTypes.clear();
}
}
}
use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.
the class CFEMapper method map.
/**
* Maps the given {@link EObject} to another {@link EObject} which will be used in the control flow graph. This
* method invokes the internal mapping methods repeatedly until a fixpoint is reached.
*/
public static ControlFlowElement map(ControlFlowElement eObj) {
ControlFlowElement eObjTmp = eObj;
ControlFlowElement lastEObj = null;
while (eObjTmp != null) {
lastEObj = eObjTmp;
eObjTmp = mapInternal(eObjTmp);
}
return lastEObj;
}
use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.
the class CatchNodeFinder method find.
/**
* @return the node to which the given {@code jumpNode} jumps via the given {@link JumpToken}. Can return null.
*/
static Pair<Node, ControlFlowType> find(JumpToken jumpToken, Node jumpNode, ComplexNodeMapper cnMapper) {
CatchEvaluator catchEvaluator = getCatchEvaluator(jumpToken);
ControlFlowElement cfe = jumpNode.getControlFlowElement();
cfe = skipContainers(cfe);
ControlFlowElement lastCFE = null;
while (cfe != null) {
Pair<Node, ControlFlowType> catcher = findCatchNode(jumpToken, cfe, lastCFE, catchEvaluator, cnMapper);
if (catcher != null)
return catcher;
lastCFE = cfe;
cfe = getContainer(cfe);
}
return null;
}
use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.
the class ControlFlowGraphFactory method connectNode.
/**
* Connects all nodes based on
* <ul>
* <li/>the delegating nodes, and
* <li/>the internal successor information of each node.
* </ul>
*/
private static void connectNode(ComplexNodeMapper cnMapper, Node mNode) {
Node internalStartNode = mNode;
ControlFlowElement subASTElem = mNode.getDelegatedControlFlowElement();
if (subASTElem != null) {
ComplexNode subCN = cnMapper.get(subASTElem);
if (subCN != null) {
// can be null in case of malformed AST
EdgeUtils.connectCF(mNode, subCN.getEntry());
internalStartNode = subCN.getExit();
}
}
Set<Node> internalSuccs = mNode.getInternalSuccessors();
for (Node internalSucc : internalSuccs) {
ControlFlowType cfType = mNode.getInternalSuccessorControlFlowType(internalSucc);
EdgeUtils.connectCF(internalStartNode, internalSucc, cfType);
}
}
use of org.eclipse.n4js.n4JS.ControlFlowElement 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;
}
Aggregations