1 package Analysis.OwnershipAnalysis;
7 public class HeapRegionNode extends OwnershipNode {
11 protected boolean isSingleObject;
12 protected boolean isFlagged;
13 protected boolean isParameter;
14 protected boolean isNewSummary;
16 protected HashSet<ReferenceEdge> referencers;
18 protected TypeDescriptor type;
20 protected AllocationSite allocSite;
22 protected ReachabilitySet alpha;
23 protected ReachabilitySet alphaNew;
25 protected String description;
29 public HeapRegionNode(Integer id,
30 boolean isSingleObject,
35 AllocationSite allocSite,
36 ReachabilitySet alpha,
39 this.isSingleObject = isSingleObject;
40 this.isFlagged = isFlagged;
41 this.isParameter = isParameter;
42 this.isNewSummary = isNewSummary;
44 this.allocSite = allocSite;
46 this.description = description;
48 referencers = new HashSet<ReferenceEdge>();
49 alphaNew = new ReachabilitySet().makeCanonical();
52 public HeapRegionNode copy() {
53 return new HeapRegionNode(id,
65 public Integer getID() {
70 public boolean equalsIncludingAlpha(HeapRegionNode hrn) {
71 return equals(hrn) && alpha.equals(hrn.alpha);
75 public boolean equals(Object o) {
80 if( !( o instanceof HeapRegionNode) ) {
84 HeapRegionNode hrn = (HeapRegionNode) o;
86 if( !id.equals(hrn.getID() ) ) {
90 assert isSingleObject == hrn.isSingleObject();
91 assert isFlagged == hrn.isFlagged();
92 assert isParameter == hrn.isParameter();
93 assert isNewSummary == hrn.isNewSummary();
94 assert description.equals(hrn.getDescription() );
99 public int hashCode() {
100 return id.intValue()*17;
104 public boolean isSingleObject() {
105 return isSingleObject;
108 public boolean isFlagged() {
112 public boolean isParameter() {
116 public boolean isNewSummary() {
122 public Iterator<ReferenceEdge> iteratorToReferencers() {
123 return referencers.iterator();
126 public Iterator<ReferenceEdge> iteratorToReferencersClone() {
127 HashSet<ReferenceEdge> clone = (HashSet<ReferenceEdge>)referencers.clone();
128 return clone.iterator();
131 public int getNumReferencers() {
132 return referencers.size();
136 public void addReferencer(ReferenceEdge edge) {
139 referencers.add(edge);
142 public void removeReferencer(ReferenceEdge edge) {
144 assert referencers.contains(edge);
146 referencers.remove(edge);
149 public ReferenceEdge getReferenceFrom(OwnershipNode on,
154 Iterator<ReferenceEdge> itrEdge = referencers.iterator();
155 while( itrEdge.hasNext() ) {
156 ReferenceEdge edge = itrEdge.next();
157 if( edge.getSrc().equals(on) &&
158 edge.typeEquals(type) &&
159 edge.fieldEquals(field) ) {
168 public TypeDescriptor getType() {
172 public AllocationSite getAllocationSite() {
177 public void setAlpha(ReachabilitySet alpha) {
181 public ReachabilitySet getAlpha() {
185 public ReachabilitySet getAlphaNew() {
189 public void setAlphaNew(ReachabilitySet alpha) {
190 this.alphaNew = alpha;
193 public void applyAlphaNew() {
194 assert alphaNew != null;
196 alphaNew = new ReachabilitySet().makeCanonical();
200 public String getIDString() {
204 s = "minus" + new Integer(-id).toString();
212 public String getAlphaString() {
213 return alpha.toStringEscapeNewline();
216 public String toString() {
217 return "HRN"+getIDString();
220 // WHY WHY WHY WHY WHY WHY?!
221 public String getDescription() {
222 return new String(description);
223 //return new String( description+" ID "+getIDString() );