Properly use transitive closure of allocation sites when resolving
[IRC.git] / Robust / src / Analysis / OwnershipAnalysis / HeapRegionNode.java
1 package Analysis.OwnershipAnalysis;
2
3 import IR.*;
4 import IR.Flat.*;
5 import java.util.*;
6
7 public class HeapRegionNode extends OwnershipNode {
8
9     protected Integer id;
10
11     protected boolean isSingleObject;
12     protected boolean isFlagged;
13     protected boolean isNewSummary;
14
15     protected HashSet<TempDescriptor> memberFields;
16     protected HashSet<OwnershipNode>  referencers;
17
18     protected AllocationSite allocSite;
19
20     protected String description;
21
22
23
24     public HeapRegionNode( Integer        id,
25                            boolean        isSingleObject,
26                            boolean        isFlagged,
27                            boolean        isNewSummary,
28                            AllocationSite allocSite,
29                            String         description ) {
30         this.id = id;
31         this.isSingleObject = isSingleObject;
32         this.isFlagged      = isFlagged;
33         this.isNewSummary   = isNewSummary;
34         this.allocSite      = allocSite;
35         this.description    = description;
36
37         referencers  = new HashSet<OwnershipNode>();
38         memberFields = new HashSet<TempDescriptor>();
39     }
40
41     public HeapRegionNode copy() {
42         return new HeapRegionNode( id,
43                                    isSingleObject,
44                                    isFlagged,
45                                    isNewSummary,
46                                    allocSite,
47                                    description );
48     }
49
50
51     public Integer getID() {
52         return id;
53     }
54
55     public boolean equals( HeapRegionNode hrn ) {
56         assert hrn != null;
57
58         return id.equals( hrn.getID() )            &&
59             isSingleObject == hrn.isSingleObject() &&
60             isFlagged      == hrn.isFlagged()      &&
61             isNewSummary   == hrn.isNewSummary()   &&
62             description.equals( hrn.getDescription() );
63     }
64
65
66
67     public boolean isSingleObject() {
68         return isSingleObject;
69     }
70
71     public boolean isFlagged() {
72         return isFlagged;
73     }
74
75     public boolean isNewSummary() {
76         return isNewSummary;
77     }
78
79
80
81     public Iterator iteratorToReferencers() {
82         return referencers.iterator();
83     }
84
85     public Iterator iteratorToReferencersClone() {
86         HashSet hs = (HashSet) referencers.clone();
87         return hs.iterator();
88     }
89
90     public void addReferencer( OwnershipNode on ) {
91         assert on != null;
92
93         referencers.add( on );
94     }
95
96     public void removeReferencer( OwnershipNode on ) {
97         assert on != null;
98         assert referencers.contains( on );
99
100         referencers.remove( on );
101     }
102
103     public boolean isReferencedBy( OwnershipNode on ) {
104         assert on != null;
105         return referencers.contains( on );
106     }
107
108
109     public AllocationSite getAllocationSite() {
110         return allocSite;
111     }
112
113     public String getIDString() {
114         return id.toString();
115     }
116
117     public String toString() {
118         return "HRN"+getIDString();
119     }
120
121     // WHY WHY WHY WHY WHY WHY?!
122     public String getDescription() {
123         return new String( description );
124         //return new String( description+" ID "+getIDString() );
125     }
126 }