1 package Analysis.OwnershipAnalysis;
7 public class ReferenceEdgeProperties {
9 // a null field descriptor means "any field"
10 protected FieldDescriptor fieldDesc;
12 protected boolean isInitialParamReflexive;
14 protected ReachabilitySet beta;
15 protected ReachabilitySet betaNew;
17 protected OwnershipNode src;
18 protected HeapRegionNode dst;
20 public ReferenceEdgeProperties() {
21 this( null, false, null );
24 public ReferenceEdgeProperties( FieldDescriptor fieldDesc,
25 boolean isInitialParamReflexive,
26 ReachabilitySet beta ) {
28 this.fieldDesc = fieldDesc;
29 this.isInitialParamReflexive = isInitialParamReflexive;
34 this.beta = new ReachabilitySet();
35 this.beta = this.beta.makeCanonical();
38 // these members are set by higher-level code
39 // when this ReferenceEdgeProperties object is
44 // when edges are not undergoing a transitional operation
45 // that is changing beta info, betaNew is always empty
46 betaNew = new ReachabilitySet();
47 betaNew = betaNew.makeCanonical();
51 public OwnershipNode getSrc() {
55 public void setSrc( OwnershipNode on ) {
60 public HeapRegionNode getDst() {
64 public void setDst( HeapRegionNode hrn ) {
70 // copying does not copy source and destination members! or betaNew
71 public ReferenceEdgeProperties copy() {
72 return new ReferenceEdgeProperties( fieldDesc,
73 isInitialParamReflexive,
78 public FieldDescriptor getFieldDesc() {
82 public void setFieldDesc( FieldDescriptor fieldDesc ) {
83 this.fieldDesc = fieldDesc;
88 public boolean isInitialParamReflexive() {
89 return isInitialParamReflexive;
91 public void setIsInitialParamReflexive( boolean isInitialParamReflexive ) {
92 this.isInitialParamReflexive = isInitialParamReflexive;
96 public ReachabilitySet getBeta() {
100 public void setBeta( ReachabilitySet beta ) {
105 public ReachabilitySet getBetaNew() {
109 public void setBetaNew( ReachabilitySet beta ) {
114 public void applyBetaNew() {
115 assert betaNew != null;
119 betaNew = new ReachabilitySet();
120 betaNew = betaNew.makeCanonical();
124 public boolean equals( Object o ) {
129 if( !(o instanceof ReferenceEdgeProperties) ) {
133 ReferenceEdgeProperties rep = (ReferenceEdgeProperties) o;
135 // field descriptors maintain the invariant that they are reference comparable
136 return fieldDesc == rep.fieldDesc &&
137 isInitialParamReflexive == rep.isInitialParamReflexive &&
138 beta.equals( rep.beta );
141 public int hashCode() {
143 if( fieldDesc != null ) {
144 hash += fieldDesc.getType().hashCode();
146 hash += beta.hashCode();
151 public String getBetaString() {
152 return beta.toStringEscapeNewline();
155 public String toEdgeLabelString() {
156 String edgeLabel = "";
157 if( fieldDesc != null ) {
158 edgeLabel += fieldDesc.toStringBrief() + "\\n";
160 if( isInitialParamReflexive ) {
161 edgeLabel += "Rflx\\n";
163 edgeLabel += getBetaString();