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