use of com.jopdesign.common.code.ControlFlowGraph.VirtualNode in project jop by jop-devel.
the class SuperGraph method incomingEdgesOf.
/**
* The incoming edges are generated as follows:
* <ul>
* <li/>return node: superedge returning to the caller
* <li/>entry node: superedge invoking the node's method
* <li/>other: intraprocedural CFG edge
* </ul>
* @param node
* @return
*/
public Iterable<SuperGraphEdge> incomingEdgesOf(SuperGraphNode node) {
CFGNode cfgNode = node.getCFGNode();
if (cfgNode instanceof ReturnNode) {
/* return node: incoming edges are callgraph return edges */
final ReturnNode retNode = (ReturnNode) cfgNode;
Set<SuperEdge> cgReturnEdges = superGraph.incomingEdgesOf(node.getContextCFG());
return new Filter<SuperGraphEdge>() {
@Override
protected boolean include(SuperGraphEdge e) {
if (!(e instanceof SuperReturnEdge))
return false;
SuperReturnEdge retEdge = (SuperReturnEdge) e;
return retEdge.getReturnNode().equals(retNode);
}
}.<SuperGraphEdge>filter(cgReturnEdges);
} else if (cfgNode instanceof VirtualNode && ((VirtualNode) cfgNode).getKind() == VirtualNodeKind.ENTRY) {
/* entry node: superedge invoking the node's method */
Set<SuperEdge> cgInvokeEdges = superGraph.incomingEdgesOf(node.getContextCFG());
return new Filter<SuperGraphEdge>() {
@Override
protected boolean include(SuperGraphEdge e) {
return (e instanceof SuperInvokeEdge);
}
}.<SuperGraphEdge>filter(cgInvokeEdges);
} else {
/* standard edges: incoming edges of cfg node */
return liftCFGEdges(node.getContextCFG(), node.getContextCFG().getCfg().incomingEdgesOf(cfgNode));
}
}
use of com.jopdesign.common.code.ControlFlowGraph.VirtualNode in project jop by jop-devel.
the class SuperGraph method outgoingEdgesOf.
/**
* The outgoing edges are generated as follows:
* <ul>
* <li/>invoke node: superedge invoking the callee
* <li/>exit node: superedge returning to the caller
* <li/>other: intraprocedural CFG edge
* </ul>
* @param node
* @return
*/
public Iterable<SuperGraphEdge> outgoingEdgesOf(SuperGraphNode node) {
CFGNode cfgNode = node.getCFGNode();
if (cfgNode instanceof InvokeNode) {
/* invoke node: outgoing SuperInvoke edges */
final InvokeNode invNode = (InvokeNode) cfgNode;
Set<SuperEdge> outgoingInvokeEdges = superGraph.outgoingEdgesOf(node.getContextCFG());
return new Filter<SuperGraphEdge>() {
@Override
protected boolean include(SuperGraphEdge e) {
if (!(e instanceof SuperInvokeEdge))
return false;
SuperInvokeEdge invoke = (SuperInvokeEdge) e;
return invoke.getInvokeNode().equals(invNode);
}
}.<SuperGraphEdge>filter(outgoingInvokeEdges);
} else if (cfgNode instanceof VirtualNode && ((VirtualNode) cfgNode).getKind() == VirtualNodeKind.EXIT) {
/* exit node: outgoing SuperReturn edges */
Set<SuperEdge> outgoingReturnEdges = superGraph.outgoingEdgesOf(node.getContextCFG());
return new Filter<SuperGraphEdge>() {
@Override
protected boolean include(SuperGraphEdge e) {
return (e instanceof SuperReturnEdge);
}
}.<SuperGraphEdge>filter(outgoingReturnEdges);
} else {
/* standard edges: outgoing edges of cfg node */
Set<CFGEdge> outgoingCFGEdges = node.getContextCFG().getCfg().outgoingEdgesOf(cfgNode);
return liftCFGEdges(node.getContextCFG(), outgoingCFGEdges);
}
}
Aggregations