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<ReferenceEdge> referencers;
17 protected AllocationSite allocSite;
19 protected ReachabilitySet alpha;
20 protected ReachabilitySet alphaNew;
22 protected String description;
26 public HeapRegionNode( Integer id,
27 boolean isSingleObject,
30 AllocationSite allocSite,
31 ReachabilitySet alpha,
32 String description ) {
34 this.isSingleObject = isSingleObject;
35 this.isFlagged = isFlagged;
36 this.isNewSummary = isNewSummary;
37 this.allocSite = allocSite;
39 this.description = description;
41 referencers = new HashSet<ReferenceEdge>();
42 alphaNew = new ReachabilitySet().makeCanonical();
45 public HeapRegionNode copy() {
46 return new HeapRegionNode( id,
56 public Integer getID() {
61 public boolean equals( Object o ) {
66 if( !( o instanceof HeapRegionNode) ) {
70 HeapRegionNode hrn = (HeapRegionNode) o;
72 return id.equals( hrn.getID() ) &&
73 isSingleObject == hrn.isSingleObject() &&
74 isFlagged == hrn.isFlagged() &&
75 isNewSummary == hrn.isNewSummary() &&
76 alpha.equals( hrn.getAlpha() ) &&
77 description.equals( hrn.getDescription() );
80 public int hashCode() {
85 public boolean isSingleObject() {
86 return isSingleObject;
89 public boolean isFlagged() {
93 public boolean isNewSummary() {
99 public Iterator<ReferenceEdge> iteratorToReferencers() {
100 return referencers.iterator();
103 public Iterator<ReferenceEdge> iteratorToReferencersClone() {
104 HashSet<ReferenceEdge> clone = (HashSet<ReferenceEdge>) referencers.clone();
105 return clone.iterator();
108 public void addReferencer( ReferenceEdge edge ) {
111 referencers.add( edge );
114 public void removeReferencer( ReferenceEdge edge ) {
116 assert referencers.contains( edge );
118 referencers.remove( edge );
121 public ReferenceEdge getReferenceFrom( OwnershipNode on,
122 FieldDescriptor fd ) {
125 Iterator<ReferenceEdge> itrEdge = referencers.iterator();
126 while( itrEdge.hasNext() ) {
127 ReferenceEdge edge = itrEdge.next();
128 if( edge.getSrc().equals( on ) &&
129 edge.getFieldDesc() == fd ) {
138 public AllocationSite getAllocationSite() {
143 public void setAlpha( ReachabilitySet alpha ) {
147 public ReachabilitySet getAlpha() {
151 public ReachabilitySet getAlphaNew() {
155 public void setAlphaNew( ReachabilitySet alpha ) {
156 this.alphaNew = alpha;
159 public void applyAlphaNew() {
160 assert alphaNew != null;
164 alphaNew = new ReachabilitySet();
165 alphaNew = alphaNew.makeCanonical();
169 public String getIDString() {
170 return id.toString();
173 public String getAlphaString() {
174 return alpha.toStringEscapeNewline();
177 public String toString() {
178 return "HRN"+getIDString();
181 // WHY WHY WHY WHY WHY WHY?!
182 public String getDescription() {
183 return new String( description );
184 //return new String( description+" ID "+getIDString() );