1 package Analysis.OwnershipAnalysis;
7 public class HeapRegionNode extends OwnershipNode {
11 protected boolean isSingleObject;
12 protected boolean isFlagged;
13 protected boolean isNewSummary;
15 protected HashSet<TempDescriptor> memberFields;
16 protected HashSet<OwnershipNode> referencers;
18 protected AllocationSite allocSite;
20 protected ReachabilitySet alpha;
21 protected ReachabilitySet alphaNew;
23 protected String description;
27 public HeapRegionNode( Integer id,
28 boolean isSingleObject,
31 AllocationSite allocSite,
32 ReachabilitySet alpha,
33 String description ) {
35 this.isSingleObject = isSingleObject;
36 this.isFlagged = isFlagged;
37 this.isNewSummary = isNewSummary;
38 this.allocSite = allocSite;
40 this.description = description;
42 alphaNew = new ReachabilitySet();
43 alphaNew = alphaNew.makeCanonical();
45 referencers = new HashSet<OwnershipNode>();
46 memberFields = new HashSet<TempDescriptor>();
49 public HeapRegionNode copy() {
50 return new HeapRegionNode( id,
60 public Integer getID() {
65 public boolean equals( Object o ) {
70 if( !( o instanceof HeapRegionNode) ) {
74 HeapRegionNode hrn = (HeapRegionNode) o;
76 return id.equals( hrn.getID() ) &&
77 isSingleObject == hrn.isSingleObject() &&
78 isFlagged == hrn.isFlagged() &&
79 isNewSummary == hrn.isNewSummary() &&
80 alpha.equals( hrn.getAlpha() ) &&
81 description.equals( hrn.getDescription() );
84 public int hashCode() {
90 public boolean isSingleObject() {
91 return isSingleObject;
94 public boolean isFlagged() {
98 public boolean isNewSummary() {
104 public Iterator iteratorToReferencers() {
105 return referencers.iterator();
108 public Iterator iteratorToReferencersClone() {
109 HashSet hs = (HashSet) referencers.clone();
110 return hs.iterator();
113 public void addReferencer( OwnershipNode on ) {
116 referencers.add( on );
119 public void removeReferencer( OwnershipNode on ) {
121 assert referencers.contains( on );
123 referencers.remove( on );
126 public boolean isReferencedBy( OwnershipNode on ) {
128 return referencers.contains( on );
132 public AllocationSite getAllocationSite() {
137 public void setAlpha( ReachabilitySet alpha ) {
141 public ReachabilitySet getAlpha() {
145 public ReachabilitySet getAlphaNew() {
149 public void setAlphaNew( ReachabilitySet alpha ) {
150 this.alphaNew = alpha;
153 public void applyAlphaNew() {
154 assert alphaNew != null;
158 alphaNew = new ReachabilitySet();
159 alphaNew = alphaNew.makeCanonical();
163 public String getIDString() {
164 return id.toString();
167 public String getAlphaString() {
168 return alpha.toStringEscapeNewline();
171 public String toString() {
172 return "HRN"+getIDString();
175 // WHY WHY WHY WHY WHY WHY?!
176 public String getDescription() {
177 return new String( description );
178 //return new String( description+" ID "+getIDString() );