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 edge = (ReferenceEdge) o;
65 if( fieldDesc != edge.fieldDesc ) {
69 // Equality of edges is only valid within a graph, so
70 // compare src and dst by reference
71 if( !(src == edge.src) ||
72 !(dst == edge.dst) ) {
80 public boolean equalsIncludingBeta( ReferenceEdge edge ) {
81 return equals( edge ) && beta.equals( edge.beta );
85 public int hashCode() {
88 if( fieldDesc != null ) {
89 hash += fieldDesc.getType().hashCode();
92 hash += src.hashCode()*11;
93 hash += dst.hashCode();
99 public OwnershipNode getSrc() {
103 public void setSrc( OwnershipNode on ) {
108 public HeapRegionNode getDst() {
112 public void setDst( HeapRegionNode hrn ) {
118 public FieldDescriptor getFieldDesc() {
122 public void setFieldDesc( FieldDescriptor fieldDesc ) {
123 this.fieldDesc = fieldDesc;
127 public boolean isInitialParamReflexive() {
128 return isInitialParamReflexive;
130 public void setIsInitialParamReflexive( boolean isInitialParamReflexive ) {
131 this.isInitialParamReflexive = isInitialParamReflexive;
135 public ReachabilitySet getBeta() {
139 public void setBeta( ReachabilitySet beta ) {
144 public ReachabilitySet getBetaNew() {
148 public void setBetaNew( ReachabilitySet beta ) {
153 public void applyBetaNew() {
154 assert betaNew != null;
157 betaNew = new ReachabilitySet().makeCanonical();
161 public String toGraphEdgeString() {
162 String edgeLabel = "";
164 if( fieldDesc != null ) {
165 edgeLabel += fieldDesc.toStringBrief() + "\\n";
168 if( isInitialParamReflexive ) {
169 edgeLabel += "Rflx\\n";
172 edgeLabel += beta.toStringEscapeNewline();