Fixed bug that heap regions from allocation sites are properly passed
[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     public HeapRegionNode( Integer id,
10                            boolean isSingleObject,
11                            boolean isFlagged,
12                            boolean isNewSummary,
13                            String  description ) {
14         this.id = id;
15         this.isSingleObject = isSingleObject;
16         this.isFlagged      = isFlagged;
17         this.isNewSummary   = isNewSummary;
18         this.description    = description;
19
20         referencers           = new HashSet<OwnershipNode>();
21         //analysisRegionAliases = new HashSet<TempDescriptor>();
22         memberFields          = new HashSet<TempDescriptor>();
23     }
24
25     public HeapRegionNode copy() {
26         return new HeapRegionNode( id,
27                                    isSingleObject,
28                                    isFlagged,
29                                    isNewSummary,
30                                    description );
31     }
32
33
34     /////////////////
35     // equality  
36     /////////////////
37     protected Integer id;
38
39     public Integer getID() {
40         return id;
41     }
42
43     public boolean equals( HeapRegionNode hrn ) {
44         assert hrn != null;
45
46         return id.equals( hrn.getID() )            &&
47             isSingleObject == hrn.isSingleObject() &&
48             isFlagged      == hrn.isFlagged()      &&
49             isNewSummary   == hrn.isNewSummary()   &&
50             description.equals( hrn.getDescription() );
51     }
52     /////////////////
53     // end equality  
54     /////////////////
55
56
57     
58     /////////////////
59     // predicates
60     /////////////////
61     boolean isSingleObject;
62     public boolean isSingleObject() {
63         return isSingleObject;
64     }
65
66     boolean isFlagged;
67     public boolean isFlagged() {
68         return isFlagged;
69     }
70
71     boolean isNewSummary;
72     public boolean isNewSummary() {
73         return isNewSummary;
74     }
75     ///////////////////
76     // end predicates 
77     ///////////////////
78
79
80
81     ///////////////////////////////////////////
82     // interface with larger graph
83     ///////////////////////////////////////////
84     protected HashSet<TempDescriptor> memberFields;
85     protected HashSet<OwnershipNode>  referencers;
86
87     public Iterator iteratorToReferencers() {
88         return referencers.iterator();
89     }
90
91     public Iterator iteratorToReferencersClone() {
92         HashSet hs = (HashSet) referencers.clone();
93         return hs.iterator();
94     }
95
96     public void addReferencer( OwnershipNode on ) {
97         assert on != null;
98
99         referencers.add( on );
100     }
101
102     public void removeReferencer( OwnershipNode on ) {
103         assert on != null;
104         assert referencers.contains( on );
105
106         referencers.remove( on );
107     }
108
109     public boolean isReferencedBy( OwnershipNode on ) {
110         assert on != null;
111         return referencers.contains( on );
112     }
113     ///////////////////////////////////////////////
114     // end interface with larger graph
115     ///////////////////////////////////////////////
116
117
118
119
120     ///////////////////////////////////////////////
121     // analysis interface
122     ///////////////////////////////////////////////
123     /*
124     protected HashSet<TempDescriptor> analysisRegionAliases;
125
126     public void addAnalysisRegionAlias( TempDescriptor td ) {
127         assert td != null;
128         assert !analysisRegionAliases.contains( td );
129         
130         analysisRegionAliases.add( td );
131     }
132
133     public Iterator iteratorToAnalysisRegionAliases() {
134         return analysisRegionAliases.iterator();
135     }
136     */
137     ///////////////////////////////////////////////
138     // end analysis interface
139     ///////////////////////////////////////////////
140
141
142     // for writing out
143     String description;
144
145     public String getIDString() {
146         return id.toString();
147     }
148
149     public String toString() {
150         return "HRN"+getIDString();
151     }
152
153     public String getDescription() {
154         return description;
155     }
156 }