1e28f9045410f029f1cf67a5c358773f16c512c1
[IRC.git] / Robust / src / Analysis / OwnershipAnalysis / HeapRegionNode.java
1 package Analysis.OwnershipAnalysis;
2
3 import IR.*;
4 import IR.Flat.*;
5 import java.util.*;
6
7 public class HeapRegionNode extends OwnershipNode {
8
9     protected Integer id;
10
11     protected boolean isSingleObject;
12     protected boolean isFlagged;
13     protected boolean isNewSummary;
14
15     protected HashSet<TempDescriptor> memberFields;
16     protected HashSet<OwnershipNode>  referencers;
17
18     protected AllocationSite allocSite;
19
20     protected ReachabilitySet alpha;
21
22     protected String description;
23
24
25
26     public HeapRegionNode( Integer         id,
27                            boolean         isSingleObject,
28                            boolean         isFlagged,
29                            boolean         isNewSummary,
30                            AllocationSite  allocSite,
31                            ReachabilitySet alpha,
32                            String          description ) {
33         this.id = id;
34         this.isSingleObject = isSingleObject;
35         this.isFlagged      = isFlagged;
36         this.isNewSummary   = isNewSummary;
37         this.allocSite      = allocSite;
38         this.alpha          = alpha;
39         this.description    = description;
40
41         referencers  = new HashSet<OwnershipNode>();
42         memberFields = new HashSet<TempDescriptor>();
43     }
44
45     public HeapRegionNode copy() {
46         return new HeapRegionNode( id,
47                                    isSingleObject,
48                                    isFlagged,
49                                    isNewSummary,
50                                    allocSite,
51                                    alpha,
52                                    description );
53     }
54
55
56     public Integer getID() {
57         return id;
58     }
59
60     public boolean equals( HeapRegionNode hrn ) {
61         assert hrn != null;
62
63         return id.equals( hrn.getID() )            &&
64             isSingleObject == hrn.isSingleObject() &&
65             isFlagged      == hrn.isFlagged()      &&
66             isNewSummary   == hrn.isNewSummary()   &&
67             description.equals( hrn.getDescription() );
68     }
69
70
71
72     public boolean isSingleObject() {
73         return isSingleObject;
74     }
75
76     public boolean isFlagged() {
77         return isFlagged;
78     }
79
80     public boolean isNewSummary() {
81         return isNewSummary;
82     }
83
84
85
86     public Iterator iteratorToReferencers() {
87         return referencers.iterator();
88     }
89
90     public Iterator iteratorToReferencersClone() {
91         HashSet hs = (HashSet) referencers.clone();
92         return hs.iterator();
93     }
94
95     public void addReferencer( OwnershipNode on ) {
96         assert on != null;
97
98         referencers.add( on );
99     }
100
101     public void removeReferencer( OwnershipNode on ) {
102         assert on != null;
103         assert referencers.contains( on );
104
105         referencers.remove( on );
106     }
107
108     public boolean isReferencedBy( OwnershipNode on ) {
109         assert on != null;
110         return referencers.contains( on );
111     }
112
113
114     public AllocationSite getAllocationSite() {
115         return allocSite;
116     }
117
118
119     public ReachabilitySet getAlpha() {
120         return alpha;
121     }
122
123
124     public String getIDString() {
125         return id.toString();
126     }
127
128     public String getAlphaString() {
129         return alpha.toStringEscapeNewline();
130     }
131
132     public String toString() {
133         return "HRN"+getIDString();
134     }
135
136     // WHY WHY WHY WHY WHY WHY?!
137     public String getDescription() {
138         return new String( description );
139         //return new String( description+" ID "+getIDString() );
140     }
141 }