1 package Analysis.Pointer;
4 import Analysis.Pointer.AllocFactory.AllocNode;
7 public class GraphManip {
8 static MySet<Edge> genEdges(TempDescriptor tmp, HashSet<AllocNode> dstSet) {
9 MySet<Edge> edgeset=new MySet<Edge>();
10 for(AllocNode node:dstSet) {
11 edgeset.add(new Edge(tmp, node));
16 static MySet<Edge> genEdges(HashSet<AllocNode> srcSet, FieldDescriptor fd, HashSet<AllocNode> dstSet) {
17 MySet<Edge> edgeset=new MySet<Edge>();
18 for(AllocNode srcnode:srcSet) {
19 for(AllocNode dstnode:dstSet) {
20 edgeset.add(new Edge(srcnode, fd, dstnode, Edge.NEW));
26 static MySet<Edge> getDiffEdges(Delta delta, TempDescriptor tmp) {
27 MySet<Edge> edges=new MySet<Edge>();
28 MySet<Edge> removeedges=delta.varedgeremove.get(tmp);
30 for(Edge e:delta.basevaredge.get(tmp)) {
31 if (removeedges==null||!removeedges.contains(e))
34 if (delta.varedgeadd.containsKey(tmp))
35 for(Edge e:delta.varedgeadd.get(tmp)) {
41 static MySet<Edge> getEdges(Graph graph, Delta delta, TempDescriptor tmp) {
42 MySet<Edge> edges=new MySet<Edge>();
43 MySet<Edge> removeedges=delta.varedgeremove.get(tmp);
45 for(Edge e:graph.getEdges(tmp)) {
46 if (removeedges==null||!removeedges.contains(e))
49 if (delta.varedgeadd.containsKey(tmp))
50 for(Edge e:delta.varedgeadd.get(tmp)) {
56 static MySet<Edge> getEdges(Graph graph, Delta delta, HashSet<AllocNode> srcNodes, FieldDescriptor fd) {
57 MySet<Edge> nodes=new MySet<Edge>();
58 for(AllocNode node:srcNodes) {
59 MySet<Edge> removeedges=delta.heapedgeremove.get(node);
60 for(Edge e:graph.getEdges(node)) {
61 if (e.fd==fd&&(removeedges==null||!removeedges.contains(e)))
64 if (delta.heapedgeadd.containsKey(node))
65 for(Edge e:delta.heapedgeadd.get(node)) {
73 static MySet<Edge> getEdges(Graph graph, Delta delta, AllocNode node) {
74 MySet<Edge> nodes=new MySet<Edge>();
75 MySet<Edge> removeedges=delta.heapedgeremove.get(node);
76 for(Edge e:graph.getEdges(node)) {
77 if ((removeedges==null||!removeedges.contains(e)))
80 if (delta.heapedgeadd.containsKey(node))
81 for(Edge e:delta.heapedgeadd.get(node)) {
88 static HashSet<AllocNode> getDiffNodes(Delta delta, TempDescriptor tmp) {
89 HashSet<AllocNode> nodes=new HashSet<AllocNode>();
90 MySet<Edge> removeedges=delta.varedgeremove.get(tmp);
92 for(Edge e:delta.basevaredge.get(tmp)) {
93 if (removeedges==null||!removeedges.contains(e))
96 if (delta.varedgeadd.containsKey(tmp))
97 for(Edge e:delta.varedgeadd.get(tmp)) {
103 static HashSet<AllocNode> getNodes(Graph graph, Delta delta, TempDescriptor tmp) {
104 HashSet<AllocNode> nodes=new HashSet<AllocNode>();
105 MySet<Edge> removeedges=delta.varedgeremove.get(tmp);
107 for(Edge e:graph.getEdges(tmp)) {
108 if (removeedges==null||!removeedges.contains(e))
111 if (delta.varedgeadd.containsKey(tmp))
112 for(Edge e:delta.varedgeadd.get(tmp)) {
118 static HashSet<AllocNode> getDiffNodes(Delta delta, HashSet<AllocNode> srcNodes, FieldDescriptor fd) {
119 HashSet<AllocNode> nodes=new HashSet<AllocNode>();
120 for(AllocNode node:srcNodes) {
121 MySet<Edge> removeedges=delta.heapedgeremove.get(node);
122 for(Edge e:delta.baseheapedge.get(node)) {
123 if (e.fd==fd&&(removeedges==null||!removeedges.contains(e)))
126 if (delta.heapedgeadd.containsKey(node))
127 for(Edge e:delta.heapedgeadd.get(node)) {
135 static MySet<Edge> getDiffEdges(Delta delta, HashSet<AllocNode> srcNodes) {
136 MySet<Edge> newedges=new MySet<Edge>();
137 for(Map.Entry<AllocNode, MySet<Edge>> entry:delta.baseheapedge.entrySet()) {
138 AllocNode node=entry.getKey();
139 if (srcNodes.contains(node)) {
140 MySet<Edge> edges=entry.getValue();
141 MySet<Edge> removeedges=delta.heapedgeremove.get(node);
143 if (!removeedges.contains(e)) {
149 for(Map.Entry<AllocNode, MySet<Edge>> entry:delta.heapedgeadd.entrySet()) {
150 AllocNode node=entry.getKey();
151 if (srcNodes.contains(node)) {
152 MySet<Edge> edges=entry.getValue();
153 newedges.addAll(edges);
159 static MySet<Edge> makeOld(MySet<Edge> edgesin) {
160 MySet<Edge> edgeset=new MySet<Edge>();
161 for(Edge e:edgesin) {
162 edgeset.add(e.makeOld());
167 static HashSet<AllocNode> getNodes(Graph graph, Delta delta, HashSet<AllocNode> srcNodes, FieldDescriptor fd) {
168 HashSet<AllocNode> nodes=new HashSet<AllocNode>();
169 for(AllocNode node:srcNodes) {
170 MySet<Edge> removeedges=delta.heapedgeremove.get(node);
171 for(Edge e:graph.getEdges(node)) {
172 if (e.fd==fd&&(removeedges==null||!removeedges.contains(e)))
175 if (delta.heapedgeadd.containsKey(node))
176 for(Edge e:delta.heapedgeadd.get(node)) {