public class HeapRegionNode extends OwnershipNode {
- protected Integer id;
+ protected Integer id;
- protected boolean isSingleObject;
- protected boolean isFlagged;
- protected boolean isNewSummary;
+ protected boolean isSingleObject;
+ protected boolean isFlagged;
+ protected boolean isParameter;
+ protected boolean isNewSummary;
- protected HashSet<TempDescriptor> memberFields;
- protected HashSet<OwnershipNode> referencers;
+ protected HashSet<ReferenceEdge> referencers;
- protected AllocationSite allocSite;
+ protected TypeDescriptor type;
- protected ReachabilitySet alpha;
- protected ReachabilitySet alphaNew;
+ protected AllocationSite allocSite;
- protected String description;
+ protected ReachabilitySet alpha;
+ protected ReachabilitySet alphaNew;
+ protected String description;
- public HeapRegionNode( Integer id,
- boolean isSingleObject,
- boolean isFlagged,
- boolean isNewSummary,
- AllocationSite allocSite,
- ReachabilitySet alpha,
- String description ) {
- this.id = id;
- this.isSingleObject = isSingleObject;
- this.isFlagged = isFlagged;
- this.isNewSummary = isNewSummary;
- this.allocSite = allocSite;
- this.alpha = alpha;
- this.description = description;
- alphaNew = new ReachabilitySet();
- alphaNew = alphaNew.makeCanonical();
+ public HeapRegionNode(Integer id,
+ boolean isSingleObject,
+ boolean isFlagged,
+ boolean isParameter,
+ boolean isNewSummary,
+ TypeDescriptor type,
+ AllocationSite allocSite,
+ ReachabilitySet alpha,
+ String description) {
+ this.id = id;
+ this.isSingleObject = isSingleObject;
+ this.isFlagged = isFlagged;
+ this.isParameter = isParameter;
+ this.isNewSummary = isNewSummary;
+ this.type = type;
+ this.allocSite = allocSite;
+ this.alpha = alpha;
+ this.description = description;
- referencers = new HashSet<OwnershipNode>();
- memberFields = new HashSet<TempDescriptor>();
+ referencers = new HashSet<ReferenceEdge>();
+ alphaNew = new ReachabilitySet().makeCanonical();
+ }
+
+ public HeapRegionNode copy() {
+ return new HeapRegionNode(id,
+ isSingleObject,
+ isFlagged,
+ isParameter,
+ isNewSummary,
+ type,
+ allocSite,
+ alpha,
+ description);
+ }
+
+
+ public Integer getID() {
+ return id;
+ }
+
+
+ public boolean equalsIncludingAlpha(HeapRegionNode hrn) {
+ return equals(hrn) && alpha.equals(hrn.alpha);
+ }
+
+
+ public boolean equals(Object o) {
+ if( o == null ) {
+ return false;
}
- public HeapRegionNode copy() {
- return new HeapRegionNode( id,
- isSingleObject,
- isFlagged,
- isNewSummary,
- allocSite,
- alpha,
- description );
+ if( !( o instanceof HeapRegionNode) ) {
+ return false;
}
+ HeapRegionNode hrn = (HeapRegionNode) o;
- public Integer getID() {
- return id;
+ if( !id.equals(hrn.getID() ) ) {
+ return false;
}
+ assert isSingleObject == hrn.isSingleObject();
+ assert isFlagged == hrn.isFlagged();
+ assert isParameter == hrn.isParameter();
+ assert isNewSummary == hrn.isNewSummary();
+ assert description.equals(hrn.getDescription() );
- public boolean equals( HeapRegionNode hrn ) {
- assert hrn != null;
+ return true;
+ }
- return id.equals( hrn.getID() ) &&
- isSingleObject == hrn.isSingleObject() &&
- isFlagged == hrn.isFlagged() &&
- isNewSummary == hrn.isNewSummary() &&
- alpha.equals( hrn.getAlpha() ) &&
- description.equals( hrn.getDescription() );
- }
+ public int hashCode() {
+ return id.intValue()*17;
+ }
+ public boolean isSingleObject() {
+ return isSingleObject;
+ }
- public boolean isSingleObject() {
- return isSingleObject;
- }
+ public boolean isFlagged() {
+ return isFlagged;
+ }
- public boolean isFlagged() {
- return isFlagged;
- }
+ public boolean isParameter() {
+ return isParameter;
+ }
- public boolean isNewSummary() {
- return isNewSummary;
- }
+ public boolean isNewSummary() {
+ return isNewSummary;
+ }
- public Iterator iteratorToReferencers() {
- return referencers.iterator();
- }
+ public Iterator<ReferenceEdge> iteratorToReferencers() {
+ return referencers.iterator();
+ }
- public Iterator iteratorToReferencersClone() {
- HashSet hs = (HashSet) referencers.clone();
- return hs.iterator();
- }
+ public Iterator<ReferenceEdge> iteratorToReferencersClone() {
+ HashSet<ReferenceEdge> clone = (HashSet<ReferenceEdge>)referencers.clone();
+ return clone.iterator();
+ }
- public void addReferencer( OwnershipNode on ) {
- assert on != null;
+ public int getNumReferencers() {
+ return referencers.size();
+ }
- referencers.add( on );
- }
- public void removeReferencer( OwnershipNode on ) {
- assert on != null;
- assert referencers.contains( on );
+ public void addReferencer(ReferenceEdge edge) {
+ assert edge != null;
- referencers.remove( on );
- }
+ referencers.add(edge);
+ }
- public boolean isReferencedBy( OwnershipNode on ) {
- assert on != null;
- return referencers.contains( on );
- }
+ public void removeReferencer(ReferenceEdge edge) {
+ assert edge != null;
+ assert referencers.contains(edge);
+
+ referencers.remove(edge);
+ }
+ public ReferenceEdge getReferenceFrom(OwnershipNode on,
+ TypeDescriptor type,
+ String field) {
+ assert on != null;
- public AllocationSite getAllocationSite() {
- return allocSite;
+ Iterator<ReferenceEdge> itrEdge = referencers.iterator();
+ while( itrEdge.hasNext() ) {
+ ReferenceEdge edge = itrEdge.next();
+ if( edge.getSrc().equals(on) &&
+ edge.typeEquals(type) &&
+ edge.fieldEquals(field) ) {
+ return edge;
+ }
}
+ return null;
+ }
- public void setAlpha( ReachabilitySet alpha ) {
- this.alpha = alpha;
- }
- public ReachabilitySet getAlpha() {
- return alpha;
- }
+ public TypeDescriptor getType() {
+ return type;
+ }
- public ReachabilitySet getAlphaNew() {
- return alphaNew;
- }
+ public AllocationSite getAllocationSite() {
+ return allocSite;
+ }
- public void setAlphaNew( ReachabilitySet alpha ) {
- this.alphaNew = alpha;
- }
- public void applyAlphaNew() {
- assert alphaNew != null;
+ public void setAlpha(ReachabilitySet alpha) {
+ this.alpha = alpha;
+ }
- alpha = alphaNew;
+ public ReachabilitySet getAlpha() {
+ return alpha;
+ }
- alphaNew = new ReachabilitySet();
- alphaNew = alphaNew.makeCanonical();
- }
+ public ReachabilitySet getAlphaNew() {
+ return alphaNew;
+ }
+ public void setAlphaNew(ReachabilitySet alpha) {
+ this.alphaNew = alpha;
+ }
- public String getIDString() {
- return id.toString();
- }
+ public void applyAlphaNew() {
+ assert alphaNew != null;
+ alpha = alphaNew;
+ alphaNew = new ReachabilitySet().makeCanonical();
+ }
- public String getAlphaString() {
- return alpha.toStringEscapeNewline();
- }
- public String toString() {
- return "HRN"+getIDString();
- }
+ public String getIDString() {
+ String s;
- // WHY WHY WHY WHY WHY WHY?!
- public String getDescription() {
- return new String( description );
- //return new String( description+" ID "+getIDString() );
+ if( id < 0 ) {
+ s = "minus" + new Integer(-id).toString();
+ } else {
+ s = id.toString();
}
+
+ return s;
+ }
+
+ public String getAlphaString( boolean hideSubsetReachability ) {
+ return alpha.toStringEscapeNewline(hideSubsetReachability);
+ }
+
+ public String toString() {
+ return "HRN"+getIDString();
+ }
+
+ // WHY WHY WHY WHY WHY WHY?!
+ public String getDescription() {
+ return new String(description);
+ //return new String( description+" ID "+getIDString() );
+ }
}