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() {
66 public boolean equals( Object o ) {
71 if( !( o instanceof HeapRegionNode) ) {
75 HeapRegionNode hrn = (HeapRegionNode) o;
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() );
85 public int hashCode() {
91 public boolean isSingleObject() {
92 return isSingleObject;
95 public boolean isFlagged() {
99 public boolean isNewSummary() {
105 public Iterator iteratorToReferencers() {
106 return referencers.iterator();
109 public Iterator iteratorToReferencersClone() {
110 HashSet hs = (HashSet) referencers.clone();
111 return hs.iterator();
114 public void addReferencer( OwnershipNode on ) {
117 referencers.add( on );
120 public void removeReferencer( OwnershipNode on ) {
122 assert referencers.contains( on );
124 referencers.remove( on );
127 public boolean isReferencedBy( OwnershipNode on ) {
129 return referencers.contains( on );
133 public AllocationSite getAllocationSite() {
138 public void setAlpha( ReachabilitySet alpha ) {
142 public ReachabilitySet getAlpha() {
146 public ReachabilitySet getAlphaNew() {
150 public void setAlphaNew( ReachabilitySet alpha ) {
151 this.alphaNew = alpha;
154 public void applyAlphaNew() {
155 assert alphaNew != null;
159 alphaNew = new ReachabilitySet();
160 alphaNew = alphaNew.makeCanonical();
164 public String getIDString() {
165 return id.toString();
168 public String getAlphaString() {
169 return alpha.toStringEscapeNewline();
172 public String toString() {
173 return "HRN"+getIDString();
176 // WHY WHY WHY WHY WHY WHY?!
177 public String getDescription() {
178 return new String( description );
179 //return new String( description+" ID "+getIDString() );