equals() and hashCode() methods are bunk
[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 ReachabilitySet alpha;
21     protected ReachabilitySet alphaNew;
22
23     protected String description;
24
25
26
27     public HeapRegionNode( Integer         id,
28                            boolean         isSingleObject,
29                            boolean         isFlagged,
30                            boolean         isNewSummary,
31                            AllocationSite  allocSite,
32                            ReachabilitySet alpha,
33                            String          description ) {
34         this.id = id;
35         this.isSingleObject = isSingleObject;
36         this.isFlagged      = isFlagged;
37         this.isNewSummary   = isNewSummary;
38         this.allocSite      = allocSite;
39         this.alpha          = alpha;
40         this.description    = description;
41
42         alphaNew = new ReachabilitySet();
43         alphaNew = alphaNew.makeCanonical();
44
45         referencers  = new HashSet<OwnershipNode>();
46         memberFields = new HashSet<TempDescriptor>();
47     }
48
49     public HeapRegionNode copy() {
50         return new HeapRegionNode( id,
51                                    isSingleObject,
52                                    isFlagged,
53                                    isNewSummary,
54                                    allocSite,
55                                    alpha,
56                                    description );
57     }
58
59
60     public Integer getID() {
61         return id;
62     }
63
64
65     /*
66     public boolean equals( Object o ) {
67         if( o == null ) {
68             return false;
69         }
70
71         if( !( o instanceof HeapRegionNode) ) {
72             return false;
73         }
74
75         HeapRegionNode hrn = (HeapRegionNode) o;
76
77         return id.equals( hrn.getID() )            &&
78             isSingleObject == hrn.isSingleObject() &&
79             isFlagged      == hrn.isFlagged()      &&
80             isNewSummary   == hrn.isNewSummary()   &&
81             alpha.equals( hrn.getAlpha() )         &&
82             description.equals( hrn.getDescription() );
83     }
84
85     public int hashCode() {
86         return id.intValue();
87     }
88     */
89
90
91     public boolean isSingleObject() {
92         return isSingleObject;
93     }
94
95     public boolean isFlagged() {
96         return isFlagged;
97     }
98
99     public boolean isNewSummary() {
100         return isNewSummary;
101     }
102
103
104
105     public Iterator iteratorToReferencers() {
106         return referencers.iterator();
107     }
108
109     public Iterator iteratorToReferencersClone() {
110         HashSet hs = (HashSet) referencers.clone();
111         return hs.iterator();
112     }
113
114     public void addReferencer( OwnershipNode on ) {
115         assert on != null;
116
117         referencers.add( on );
118     }
119
120     public void removeReferencer( OwnershipNode on ) {
121         assert on != null;
122         assert referencers.contains( on );
123
124         referencers.remove( on );
125     }
126
127     public boolean isReferencedBy( OwnershipNode on ) {
128         assert on != null;
129         return referencers.contains( on );
130     }
131
132
133     public AllocationSite getAllocationSite() {
134         return allocSite;
135     }
136
137
138     public void setAlpha( ReachabilitySet alpha ) {
139         this.alpha = alpha;
140     }
141
142     public ReachabilitySet getAlpha() {
143         return alpha;
144     }
145
146     public ReachabilitySet getAlphaNew() {
147         return alphaNew;
148     }
149
150     public void setAlphaNew( ReachabilitySet alpha ) {
151         this.alphaNew = alpha;
152     }
153
154     public void applyAlphaNew() {
155         assert alphaNew != null;
156
157         alpha = alphaNew;
158
159         alphaNew = new ReachabilitySet();
160         alphaNew = alphaNew.makeCanonical();
161     }
162
163
164     public String getIDString() {
165         return id.toString();
166     }
167
168     public String getAlphaString() {
169         return alpha.toStringEscapeNewline();
170     }
171
172     public String toString() {
173         return "HRN"+getIDString();
174     }
175
176     // WHY WHY WHY WHY WHY WHY?!
177     public String getDescription() {
178         return new String( description );
179         //return new String( description+" ID "+getIDString() );
180     }
181 }