int CFAnalysis::reduceNode(Flow& flow, Label lab) { Flow inFlow=flow.inEdges(lab); Flow outFlow=flow.outEdges(lab); /* description of essential operations: * inedges: (n_i,b) * outedge: (b,n2) * remove(n_i,b) * remove(b,n2) * insert(n1,n2) */ if(inFlow.size()==0 && outFlow.size()==0) return 0; if(inFlow.size()==0 || outFlow.size()==0) { Flow edges=inFlow+outFlow; flow.deleteEdges(edges); return 1; } for(Flow::iterator initer=inFlow.begin();initer!=inFlow.end();++initer) { for(Flow::iterator outiter=outFlow.begin();outiter!=outFlow.end();++outiter) { Edge e1=*initer; Edge e2=*outiter; Edge newEdge=Edge(e1.source,e1.types(),e2.target); flow.erase(e1); flow.erase(e2); flow.insert(newEdge); } } return 1; }
size_t CFAnalysis::deleteFunctionCallLocalEdges(Flow& flow) { return flow.deleteEdges(EDGE_LOCAL); }