1 package Analysis.OwnershipAnalysis;
7 public class ReferenceEdge {
10 // a null field descriptor means "any field"
11 protected FieldDescriptor fieldDesc;
13 protected boolean isInitialParamReflexive;
15 protected ReachabilitySet beta;
16 protected ReachabilitySet betaNew;
18 protected OwnershipNode src;
19 protected HeapRegionNode dst;
22 public ReferenceEdge( OwnershipNode src,
24 FieldDescriptor fieldDesc,
25 boolean isInitialParamReflexive,
26 ReachabilitySet beta ) {
30 this.fieldDesc = fieldDesc;
31 this.isInitialParamReflexive = isInitialParamReflexive;
36 this.beta = new ReachabilitySet().makeCanonical();
39 // when edges are not undergoing a transitional operation
40 // that is changing beta info, betaNew is always empty
41 betaNew = new ReachabilitySet().makeCanonical();
45 public ReferenceEdge copy() {
46 return new ReferenceEdge( src,
49 isInitialParamReflexive,
54 public boolean equals( Object o ) {
59 if( !(o instanceof ReferenceEdge) ) {
63 ReferenceEdge re = (ReferenceEdge) o;
65 // field descriptors maintain the invariant that they are reference comparable
66 return fieldDesc == re.fieldDesc &&
67 isInitialParamReflexive == re.isInitialParamReflexive &&
68 src.equals ( re.src ) &&
69 dst.equals ( re.dst ) &&
70 beta.equals( re.beta );
73 public int hashCode() {
76 if( fieldDesc != null ) {
77 hash += fieldDesc.getType().hashCode();
80 if( isInitialParamReflexive ) {
84 hash += src.hashCode();
86 hash += dst.hashCode();
88 hash += beta.hashCode();
94 public OwnershipNode getSrc() {
98 public void setSrc( OwnershipNode on ) {
103 public HeapRegionNode getDst() {
107 public void setDst( HeapRegionNode hrn ) {
113 public FieldDescriptor getFieldDesc() {
117 public void setFieldDesc( FieldDescriptor fieldDesc ) {
118 this.fieldDesc = fieldDesc;
122 public boolean isInitialParamReflexive() {
123 return isInitialParamReflexive;
125 public void setIsInitialParamReflexive( boolean isInitialParamReflexive ) {
126 this.isInitialParamReflexive = isInitialParamReflexive;
130 public ReachabilitySet getBeta() {
134 public void setBeta( ReachabilitySet beta ) {
139 public ReachabilitySet getBetaNew() {
143 public void setBetaNew( ReachabilitySet beta ) {
148 public void applyBetaNew() {
149 assert betaNew != null;
152 betaNew = new ReachabilitySet().makeCanonical();
157 public String getBetaString() {
158 return beta.toStringEscapeNewline();
162 public String toGraphEdgeString() {
163 String edgeLabel = "";
165 if( fieldDesc != null ) {
166 edgeLabel += fieldDesc.toStringBrief() + "\\n";
169 if( isInitialParamReflexive ) {
170 edgeLabel += "Rflx\\n";
173 edgeLabel += beta.toStringEscapeNewline();