08502304f90a84cda4dfaeb2b0a040211b2d340f
[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
61     public boolean equals( HeapRegionNode hrn ) {
62         assert hrn != null;
63
64         return id.equals( hrn.getID() )            &&
65             isSingleObject == hrn.isSingleObject() &&
66             isFlagged      == hrn.isFlagged()      &&
67             isNewSummary   == hrn.isNewSummary()   &&
68             alpha.equals( hrn.getAlpha() )         &&
69             description.equals( hrn.getDescription() );
70     }
71
72
73
74     public boolean isSingleObject() {
75         return isSingleObject;
76     }
77
78     public boolean isFlagged() {
79         return isFlagged;
80     }
81
82     public boolean isNewSummary() {
83         return isNewSummary;
84     }
85
86
87
88     public Iterator iteratorToReferencers() {
89         return referencers.iterator();
90     }
91
92     public Iterator iteratorToReferencersClone() {
93         HashSet hs = (HashSet) referencers.clone();
94         return hs.iterator();
95     }
96
97     public void addReferencer( OwnershipNode on ) {
98         assert on != null;
99
100         referencers.add( on );
101     }
102
103     public void removeReferencer( OwnershipNode on ) {
104         assert on != null;
105         assert referencers.contains( on );
106
107         referencers.remove( on );
108     }
109
110     public boolean isReferencedBy( OwnershipNode on ) {
111         assert on != null;
112         return referencers.contains( on );
113     }
114
115
116     public AllocationSite getAllocationSite() {
117         return allocSite;
118     }
119
120
121     public void setAlpha( ReachabilitySet alpha ) {
122         this.alpha = alpha;
123     }
124
125     public ReachabilitySet getAlpha() {
126         return alpha;
127     }
128
129
130     public String getIDString() {
131         return id.toString();
132     }
133
134     public String getAlphaString() {
135         return alpha.toStringEscapeNewline();
136     }
137
138     public String toString() {
139         return "HRN"+getIDString();
140     }
141
142     // WHY WHY WHY WHY WHY WHY?!
143     public String getDescription() {
144         return new String( description );
145         //return new String( description+" ID "+getIDString() );
146     }
147 }